Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Binder ¶
type Binder interface {
Start(ws *websocket.Conn, store *SessionStore) error
}
Binder creates tunnleing session for each client connection.
type BinderAcceptMessage ¶
type BinderAcceptMessage struct {
Event string `json:"event"`
SessionID string `json:"session_id"`
PeerAddress string `json:"peer_address"`
}
BinderAcceptMessage is a model of a JSON message sent via websocket on client connection.
type Session ¶
type Session interface {
// PeerAddr returns the network address of a connected peer. This must be
// invariant throughout the entire lifetime of a session.
PeerAddr() net.Addr
// Start starts a tunneling session through given websocket channel.
Start(ws *websocket.Conn) error
// Close closes client connection. This cancels tunneling session.
Close() error
}
Session is an abstraction of a tunneling session.
type SessionStore ¶
SessionStore is a concurrent storage of sessions.
func (*SessionStore) Add ¶
func (store *SessionStore) Add(sess Session) string
Add adds a new session to store and returns a token ID for the session. The session can later be retrieved using the token for only a single time.
func (*SessionStore) Get ¶
func (store *SessionStore) Get(peer net.Addr) Session
Get returns the session connected with given peer. Nil is returned if no such session in store.
func (*SessionStore) Remove ¶
func (store *SessionStore) Remove(sess Session)
Remove removes sess from store.
func (*SessionStore) Resolve ¶
func (store *SessionStore) Resolve(id string) Session
Resolve returns a session associated to given token ID. Nil is returned if the token is invalid. Token is invalidated after calling this function.