protocol

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package protocol provides functionalities to create payloads and compose packet that conform to the booster protocol.

Index

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 BandwidthHeader() ([]byte, error)

func ConnectHeader

func ConnectHeader() ([]byte, error)

func CtrlHeader

func CtrlHeader() ([]byte, error)

func DisconnectHeader

func DisconnectHeader() ([]byte, error)

func EncodePayloadBandwidth

func EncodePayloadBandwidth(tot int, bw int, t string) ([]byte, error)

func EncodePayloadConnect

func EncodePayloadConnect(target string) ([]byte, error)

func EncodePayloadCtrl

func EncodePayloadCtrl(op Operation) ([]byte, error)

func EncodePayloadDisconnect

func EncodePayloadDisconnect(id string) ([]byte, error)

func EncodePayloadHeartbeat

func EncodePayloadHeartbeat(h *PayloadHeartbeat) ([]byte, error)

func EncodePayloadHello

func EncodePayloadHello(bport, pport string) ([]byte, error)

func EncodePayloadInspect

func EncodePayloadInspect(f []Message) ([]byte, error)

func EncodePayloadNode

func EncodePayloadNode(node *PayloadNode) ([]byte, error)

func EncodePayloadTunnelEvent

func EncodePayloadTunnelEvent(target string, event int) ([]byte, error)

func HeartbeatHeader

func HeartbeatHeader() ([]byte, error)

func HelloHeader

func HelloHeader() ([]byte, error)

func InspectHeader

func InspectHeader() ([]byte, error)

func IsVersionSupported

func IsVersionSupported(v string) bool

IsVersionSupported returns true if the current protocol version is compatible with the requested version.

func NodeHeader

func NodeHeader() ([]byte, error)

func TunnelEventHeader

func TunnelEventHeader() ([]byte, error)

func TunnelNotifyHeader

func TunnelNotifyHeader() ([]byte, error)

Types

type Header struct {
	ID              Message
	ProtocolVersion string
	SentAt          time.Time
	Modules         []string
}

func DecodeHeader

func DecodeHeader(h []byte) (*Header, error)

DecodeHeader decodes the given header and returns it.

func (*Header) HasModule

func (h *Header) HasModule(m string) bool

type Message

type Message int32

type Operation

type Operation int32
const (
	CtrlStop    Operation = 1
	CtrlRestart           = 2
)

Ctrl operations

func OperationFromString

func OperationFromString(raw string) (Operation, error)

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

type PayloadHeartbeat struct {
	ID   string
	Hops int
	TTL  time.Time
}

func DecodePayloadHeartbeat

func DecodePayloadHeartbeat(p []byte) (*PayloadHeartbeat, error)

type PayloadHello

type PayloadHello struct {
	BPort string
	PPort string
}

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

type PayloadTunnelEvent struct {
	Target string
	Event  int
}

func DecodePayloadTunnelEvent

func DecodePayloadTunnelEvent(p []byte) (*PayloadTunnelEvent, error)

type Tunnel

type Tunnel struct {
	ID     string `json:"id"`
	Target string `json:"target"`
	Acks   int    `json:"acks"`
	Copies int    `json:"copies"`
}

func (*Tunnel) String

func (t *Tunnel) String() string

Directories

Path Synopsis
Package internal is a generated protocol buffer package.
Package internal is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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