control

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(pdu PDU) ([]byte, error)

Encode encodes PDU to binary data.

func EncodeTo

func EncodeTo(w io.Writer, pdu PDU) error

EncodeTo encodes PDU to binary data in w.

Types

type BindCS

type BindCS struct {
	*Header    `cbor:"-"`
	Identifier string `cbor:"identifier"`
	Address    string `cbor:"address"`
}

BindCS is used by the client to open a tunnel. This tunnel will accept a bidirectional connection from client to server (the client start the listener).

func NewBindCS

func NewBindCS() *BindCS

NewBindCS returns a new BindCS.

type BindCSResp

type BindCSResp struct {
	*Header `cbor:"-"`
}

BindCSResp is the response to BindCS.

func NewBindCSResp

func NewBindCSResp(id string) *BindCSResp

NewBindCSResp returns a new BindCSResp.

type BindSC

type BindSC struct {
	*Header    `cbor:"-"`
	Identifier string `cbor:"identifier"`
	Address    string `cbor:"address"`
}

BindSC is used by the client to open a tunnel. This tunnel will accept a bidirectional connection from server to client (the server start the listener).

func NewBindSC

func NewBindSC() *BindSC

NewBindSC returns a new BindSC.

type BindSCResp

type BindSCResp struct {
	*Header `cbor:"-"`
}

BindSCResp is the response to BindSC.

func NewBindSCResp

func NewBindSCResp(id string) *BindSCResp

NewBindSCResp returns a new BindSCResp.

type Error

type Error struct {
	*Header `cbor:"-"`
	Status  int    `cbor:"status"`
	Message string `cbor:"message"`
}

Error is the payload in case of error.

func NewError

func NewError(id string) *Error

NewError returns a new Error.

func (*Error) Error

func (e *Error) Error() string
type Header struct {
	// contains filtered or unexported fields
}

Header is a PDU header.

func DecodeHeader

func DecodeHeader(r io.Reader) (*Header, error)

DecodeHeader decodes binary PDU header data.

func (*Header) ControlID

func (h *Header) ControlID() ID

ControlID returns the PDU control ID.

func (*Header) HeaderSize

func (h *Header) HeaderSize() int

HeaderSize returns the size of the header.

func (*Header) PID

func (h *Header) PID() string

PID returns the PDU ID.

func (*Header) RawHeader

func (h *Header) RawHeader() *Header

RawHeader returns the Header.

func (*Header) Size

func (h *Header) Size() int

Size returns the PDU size.

func (*Header) Version

func (h *Header) Version() int

Version returns the PDU version.

type ID

type ID uint8

ID is the identifier of the control PDU.

const (
	ErrorID        ID = 0x01
	InboundsID     ID = 0x02
	InboundsRespID ID = 0x03
	BindCSID       ID = 0x04
	BindCSRespID   ID = 0x05
	BindSCID       ID = 0x06
	BindSCRespID   ID = 0x07
)

Control identifier list.

func (ID) String

func (id ID) String() string

type Inbounds

type Inbounds struct {
	*Header    `cbor:"-"`
	Identifier string `cbor:"identifier"`
}

Inbounds is asked by the client to the server to get the server -> client tunnels.

func NewInbounds

func NewInbounds() *Inbounds

NewInbounds returns a new Inbounds.

type InboundsResp

type InboundsResp struct {
	*Header  `cbor:"-"`
	Inbounds []string `cbor:"inbounds"`
}

InboundsResp is the response to Inbounds.

func NewInboundsResp

func NewInboundsResp(id string) *InboundsResp

NewInboundsResp returns a new InboundsResp.

type PDU

type PDU interface {
	RawHeader() *Header
	Size() int
	Version() int
	ControlID() ID
	PID() string
}

A PDU is the data sent and received through a net connection for control purposes.

func Decode

func Decode(r io.Reader) (PDU, error)

Decode decodes binary PDU data.

func Do

func Do(c net.Conn, pdu PDU) (PDU, error)

Do sends the given pdu and returns the pdu response.

Jump to

Keyboard shortcuts

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