Documentation
¶
Overview ¶
Package protocol provides functionalities to create payloads and compose packet that conform to the booster protocol.
Index ¶
- Constants
- func BandwidthHeader() ([]byte, error)
- func ConnectHeader() ([]byte, error)
- func CtrlHeader() ([]byte, error)
- func DisconnectHeader() ([]byte, error)
- func EncodePayloadBandwidth(tot int, bw int, t string) ([]byte, error)
- func EncodePayloadConnect(target string) ([]byte, error)
- func EncodePayloadCtrl(op Operation) ([]byte, error)
- func EncodePayloadDisconnect(id string) ([]byte, error)
- func EncodePayloadHeartbeat(h *PayloadHeartbeat) ([]byte, error)
- func EncodePayloadHello(bport, pport string) ([]byte, error)
- func EncodePayloadInspect(f []Message) ([]byte, error)
- func EncodePayloadNode(node *PayloadNode) ([]byte, error)
- func EncodePayloadTunnelEvent(target string, event int) ([]byte, error)
- func HeartbeatHeader() ([]byte, error)
- func HelloHeader() ([]byte, error)
- func InspectHeader() ([]byte, error)
- func IsVersionSupported(v string) bool
- func NodeHeader() ([]byte, error)
- func TunnelEventHeader() ([]byte, error)
- func TunnelNotifyHeader() ([]byte, error)
- type Header
- type Message
- type Operation
- type PayloadBandwidth
- type PayloadConnect
- type PayloadCtrl
- type PayloadDisconnect
- type PayloadHeartbeat
- type PayloadHello
- type PayloadInspect
- type PayloadNode
- type PayloadTunnelEvent
- type Tunnel
Constants ¶
View Source
const ( ModuleHeader string = "HE" ModulePayload = "PA" )
Module Identifiers
View Source
const ( PacketOpeningTag = ">" PacketClosingTag = "<" PayloadOpeningTag = "[" PayloadClosingTag = "]" Separator = ":" )
Tags used in the encoding and decoding of packets.
View Source
const ( MessageHello Message = 1 MessageConnect = 2 MessageDisconnect = 3 MessageNode = 4 MessageHeartbeat = 5 MessageTunnel = 6 MessageNotify = 7 MessageInspect = 8 MessageBandwidth = 9 MessageCtrl = 10 )
Booster possible packet messages
View Source
const ( TunnelAck int32 = 1 TunnelRemove = 2 )
Tunnel operations
View Source
const (
EncodingProtobuf uint8 = 1
)
Possible encodings
View Source
const Version = "v0.1.0"
Booster protocol version
Variables ¶
This section is empty.
Functions ¶
func BandwidthHeader ¶
func ConnectHeader ¶
func CtrlHeader ¶
func DisconnectHeader ¶
func EncodePayloadBandwidth ¶
func EncodePayloadConnect ¶
func EncodePayloadCtrl ¶
func EncodePayloadDisconnect ¶
func EncodePayloadHeartbeat ¶
func EncodePayloadHeartbeat(h *PayloadHeartbeat) ([]byte, error)
func EncodePayloadHello ¶
func EncodePayloadInspect ¶
func EncodePayloadNode ¶
func EncodePayloadNode(node *PayloadNode) ([]byte, error)
func HeartbeatHeader ¶
func HelloHeader ¶
func InspectHeader ¶
func IsVersionSupported ¶
IsVersionSupported returns true if the current protocol version is compatible with the requested version.
func NodeHeader ¶
func TunnelEventHeader ¶
func TunnelNotifyHeader ¶
Types ¶
type Header ¶
func DecodeHeader ¶
DecodeHeader decodes the given header and returns it.
type Operation ¶
type Operation int32
const ( CtrlStop Operation = 1 CtrlRestart = 2 )
Ctrl operations
func OperationFromString ¶
OperationFromString converts raw, if possible, into a protocol known operation. Returns an error if no match is found.
type PayloadBandwidth ¶
type PayloadBandwidth struct { Tot int `json:"tot"` Bandwidth int `json:"bandwidth"` Type string `json:"type"` }
func DecodePayloadBandwidth ¶
func DecodePayloadBandwidth(p []byte) (*PayloadBandwidth, error)
func (*PayloadBandwidth) String ¶
func (n *PayloadBandwidth) String() string
type PayloadConnect ¶
type PayloadConnect struct {
Target string
}
func DecodePayloadConnect ¶
func DecodePayloadConnect(p []byte) (*PayloadConnect, error)
type PayloadCtrl ¶
type PayloadCtrl struct {
Operation Operation
}
func DecodePayloadCtrl ¶
func DecodePayloadCtrl(p []byte) (*PayloadCtrl, error)
type PayloadDisconnect ¶
type PayloadDisconnect struct {
ID string
}
func DecodePayloadDisconnect ¶
func DecodePayloadDisconnect(p []byte) (*PayloadDisconnect, error)
type PayloadHeartbeat ¶
func DecodePayloadHeartbeat ¶
func DecodePayloadHeartbeat(p []byte) (*PayloadHeartbeat, error)
type PayloadHello ¶
func DecodePayloadHello ¶
func DecodePayloadHello(p []byte) (*PayloadHello, error)
type PayloadInspect ¶
type PayloadInspect struct {
Features []Message
}
func DecodePayloadInspect ¶
func DecodePayloadInspect(p []byte) (*PayloadInspect, error)
type PayloadNode ¶
type PayloadNode struct { ID string `json:"id"` BAddr string `json:"baddr"` PAddr string `json:"paddr"` Active bool `json:"active"` Tunnels []*Tunnel `json:"tunnels"` }
func DecodePayloadNode ¶
func DecodePayloadNode(p []byte) (*PayloadNode, error)
func (*PayloadNode) String ¶
func (n *PayloadNode) String() string
type PayloadTunnelEvent ¶
func DecodePayloadTunnelEvent ¶
func DecodePayloadTunnelEvent(p []byte) (*PayloadTunnelEvent, error)
Click to show internal directories.
Click to hide internal directories.