proto

package
v0.0.0-...-9678cfa Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMsg   = errors.New("invalid message")
	ErrMsgRead      = errors.New("error reading from connection")
	ErrMsgLength    = errors.New("invalid message length")
	ErrInvalidToken = errors.New("invalid token")
	ErrMsgUnmarshal = errors.New("error unmarshalling message")
)
View Source
var (
	PacketUnknown     = PacketType(0x00)
	PacketLogin       = PacketType(0x01)
	PacketHeartbeat   = PacketType(0x02)
	PacketProxyReq    = PacketType(0x03)
	PacketProxyResp   = PacketType(0x04)
	PacketProxyCancel = PacketType(0x05)
	PacketExchange    = PacketType(0x06)
	PacketUDPDatagram = PacketType(0x07)
)

Functions

func Recv

func Recv(r io.Reader, msg Msg) error

func Send

func Send(w io.Writer, msg Msg) error

Types

type Msg

type Msg interface {
	Type() PacketType
}

type MsgExchange

type MsgExchange struct {
	ConnId    string `json:"conn_id"`
	ProxyType string `json:"proxy_type"`
}

func NewMsgExchange

func NewMsgExchange(connId, typ string) *MsgExchange

func (*MsgExchange) Type

func (m *MsgExchange) Type() PacketType

type MsgHeartbeat

type MsgHeartbeat struct{}

func NewMsgHeartbeat

func NewMsgHeartbeat() *MsgHeartbeat

func (*MsgHeartbeat) Type

func (m *MsgHeartbeat) Type() PacketType

type MsgLogin

type MsgLogin struct {
	Token     string `json:"token"`
	Version   string `json:"version"`
	Timestamp int64  `json:"timestamp"`
}

func NewMsgLogin

func NewMsgLogin(token string) *MsgLogin

func (*MsgLogin) Type

func (m *MsgLogin) Type() PacketType

type MsgProxyReq

type MsgProxyReq struct {
	RemotePort int    `json:"remote_port"`
	ProxyName  string `json:"proxy_name"`
	Subdomain  string `json:"subdomain"`
	ProxyType  string `json:"proxy_type"`
}

func NewMsgProxy

func NewMsgProxy(proxyName, subdomain, proxyType string, remotePort int) *MsgProxyReq

func (*MsgProxyReq) Type

func (m *MsgProxyReq) Type() PacketType

type MsgProxyResp

type MsgProxyResp struct {
	Domain string `json:"domain"`
	Status string `json:"status"`
}

func NewMsgProxyResp

func NewMsgProxyResp(domain, status string) *MsgProxyResp

func (*MsgProxyResp) Type

func (m *MsgProxyResp) Type() PacketType

type MsgUDPDatagram

type MsgUDPDatagram struct {
	Payload []byte       `json:"payload"`
	Addr    *net.UDPAddr `json:"addr"`
}

func NewMsgUDPDatagram

func NewMsgUDPDatagram(addr *net.UDPAddr, payload []byte) *MsgUDPDatagram

func (*MsgUDPDatagram) Type

func (m *MsgUDPDatagram) Type() PacketType

type NewProxyCancel

type NewProxyCancel struct {
	ProxyName  string `json:"proxy_name"`
	RemotePort int    `json:"remote_port"`
}

func NewMsgCancel

func NewMsgCancel(token, proxyName string, remotePort int) *NewProxyCancel

func (*NewProxyCancel) Type

func (m *NewProxyCancel) Type() PacketType

type PacketType

type PacketType byte

func Read

func Read(r io.Reader) (PacketType, []byte, error)

func (PacketType) String

func (p PacketType) String() string

Jump to

Keyboard shortcuts

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