msg

package
v0.0.0-...-e5a7b82 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeMap map[string]reflect.Type

Functions

func Pack

func Pack(payload interface{}) ([]byte, error)

func ReadMsgInto

func ReadMsgInto(c conn.Conn, msg Message) (err error)

func UnpackInto

func UnpackInto(buffer []byte, msg Message) (err error)

func WriteMsg

func WriteMsg(c conn.Conn, msg interface{}) (err error)

Types

type Auth

type Auth struct {
	Version   string // protocol version
	MmVersion string // major/minor software version (informational only)
	User      string
	Password  string
	OS        string
	Arch      string
	ClientId  string // empty for new sessions
}

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
	MmVersion string
	ClientId  string
	Error     string
}

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 Envelope

type Envelope struct {
	Type    string
	Payload json.RawMessage
}

type Message

type Message interface{}

func ReadMsg

func ReadMsg(c conn.Conn) (msg Message, err error)

func Unpack

func Unpack(buffer []byte) (msg Message, err error)

type NewTunnel

type NewTunnel struct {
	ReqId    string
	Url      string
	Protocol string
	Error    string
}

When the server opens a new tunnel on behalf of a client, it sends a NewTunnel message to notify the client. ReqId is the ReqId from the corresponding ReqTunnel message.

A client may receive *multiple* NewTunnel messages from a single ReqTunnel. (ex. A client opens an https tunnel and the server chooses to open an http tunnel of the same name as well)

type Ping

type Ping struct {
}

A client or server may send this message periodically over the control channel to request that the remote side acknowledge its connection is still alive. The remote side must respond with a Pong.

type Pong

type Pong struct {
}

Sent by a client or server over the control channel to indicate it received a Ping.

type RegProxy

type RegProxy struct {
	ClientId string
}

After a client receives a ReqProxy message, it opens a new connection to the server and sends a RegProxy message.

type ReqProxy

type ReqProxy struct {
}

When the server wants to initiate a new tunneled connection, it sends this message over the control channel to the client. When a client receives this message, it must initiate a new proxy connection to the server.

type ReqTunnel

type ReqTunnel struct {
	ReqId    string
	Protocol string

	// http only
	Hostname  string
	Subdomain string
	HttpAuth  string

	// tcp only
	RemotePort uint16
}

A client sends this message to the server over the control channel to request a new tunnel be opened on the client's behalf. ReqId is a random number set by the client that it can pull from future NewTunnel's to correlate then to the requesting ReqTunnel.

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 by the server to the client over a *proxy* connection before it begins to send the bytes of the proxied request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL