Documentation ¶
Index ¶
- Constants
- Variables
- func Pack(payload interface{}) ([]byte, error)
- func ReadMsgInto(c conn.Conn, msg Message) (err error)
- func UnpackInterfaceField(interfaceField, deserializeInto interface{}) error
- func UnpackInto(buffer []byte, msg Message) (err error)
- func WriteMsg(c conn.Conn, msg interface{}) (err error)
- type Auth
- type AuthResp
- type Bind
- type BindResp
- type Envelope
- type HTTPOptions
- type Message
- type StartProxy
- type TCPOptions
- type TLSOptions
- type Unbind
- type UnbindResp
Constants ¶
const Version = "1"
Variables ¶
var TypeMap map[string]reflect.Type
Functions ¶
func UnpackInterfaceField ¶
func UnpackInterfaceField(interfaceField, deserializeInto interface{}) error
UnpackInterfaceField allows the caller to unpack anything that is specified in the protocol as an interface{} This includes the all Extra fields and the Options for a Bind. This is one of the most awful hacks in the whole library. The trouble is that anything that is passed as an empty interface in the protocol will be deserialized into a map[string]interface{}. So in order to get them in the form we want, we write them out as JSON again and then read them back in with the now-known proper type for deserializion
func UnpackInto ¶
Types ¶
type Auth ¶
type Auth struct { Version []string // protocol versions supported, ordered by preference ClientId string // empty for new sessions Extra interface{} // clients may add whatever data the like to auth messages }
When a client opens a new control channel to the server it must start by sending an Auth message.
type AuthResp ¶
type AuthResp struct { Version string // protocol version chosen ClientId string Error string Extra interface{} }
A server responds to an Auth message with an AuthResp message over the control channel.
If Error is not the empty string the server has indicated it will not accept the new session and will close the connection.
The server response includes a unique ClientId that is used to associate and authenticate future proxy connections via the same field in RegProxy messages.
type Bind ¶
type Bind struct { Protocol string // the protocol to bind Options interface{} // options for the bind - protocol dependent Extra interface{} // anything extra the application wants to send }
A client sends this message to the server over a new stream to request the server bind a remote port/hostname on the client's behalf.
type BindResp ¶
The server responds with a BindResp message to notify the client of the success or failure of a bind.
type Envelope ¶
type Envelope struct { Type string Payload json.RawMessage }
type HTTPOptions ¶
type StartProxy ¶
type StartProxy struct { Url string // URL of the tunnel this connection connection is being proxied for ClientAddr string // Network address of the client initiating the connection to the tunnel }
This message is sent first over a new stream from the server to the client to provide it with metadata about the connection it will tunnel over the stream.
type TCPOptions ¶
type TCPOptions struct {
RemotePort uint16
}
type TLSOptions ¶
type Unbind ¶
type Unbind struct { Url string Extra interface{} }
A client sends this message to the server over a new stream to request the server unbind a previously bound tunnel
type UnbindResp ¶
type UnbindResp struct { Error string Extra interface{} }
The server response with an UnbindResp message to notify the client of the success or failure of the unbind.