Documentation ¶
Index ¶
- Constants
- Variables
- type AddrFeature
- type AddrType
- type CmdType
- type ConnectorFlag
- type ConnectorID
- func (cid ConnectorID) Equal(x ConnectorID) bool
- func (cid ConnectorID) ID() (id [connectorIDLen]byte)
- func (cid ConnectorID) IsUDP() bool
- func (cid ConnectorID) IsZero() bool
- func (cid ConnectorID) SetUDP(udp bool) ConnectorID
- func (cid ConnectorID) SetWeight(weight uint8) ConnectorID
- func (cid ConnectorID) String() string
- func (cid ConnectorID) Weight() uint8
- type Feature
- type FeatureType
- type NetworkFeature
- type NetworkID
- type Request
- type Response
- type TunnelFeature
- type TunnelFlag
- type TunnelID
- func (tid TunnelID) Equal(x TunnelID) bool
- func (tid TunnelID) ID() (id [connectorIDLen]byte)
- func (tid TunnelID) IsPrivate() bool
- func (tid TunnelID) IsZero() bool
- func (tid TunnelID) SetPrivate(private bool) TunnelID
- func (tid TunnelID) SetWeight(weight uint8) TunnelID
- func (tid TunnelID) String() string
- func (tid TunnelID) Weight() uint8
- type UserAuthFeature
Constants ¶
View Source
const ( StatusOK = 0x00 StatusBadRequest = 0x01 StatusForbidden = 0x03 StatusTimeout = 0x04 StatusHostUnreachable = 0x06 StatusNetworkUnreachable = 0x07 StatusInternalServerError = 0x08 )
response status list
View Source
const (
Version1 = 0x01
)
Variables ¶
View Source
var ( ErrShortBuffer = errors.New("short buffer") ErrBadAddrType = errors.New("bad address type") )
View Source
var (
ErrBadVersion = errors.New("bad version")
)
Functions ¶
This section is empty.
Types ¶
type AddrFeature ¶
AddrFeature is a relay feature,
Protocol spec:
+------+----------+----------+ | ATYP | ADDR | PORT | +------+----------+----------+ | 1 | Variable | 2 | +------+----------+----------+ ATYP - address type, 0x01 - IPv4, 0x03 - domain name, 0x04 - IPv6. 1 byte. ADDR - host address, IPv4 (4 bytes), IPV6 (16 bytes) or doman name based on ATYP. For domain name, the first byte is the length of the domain name. PORT - port number, 2 bytes.
func (*AddrFeature) Decode ¶
func (f *AddrFeature) Decode(b []byte) error
func (*AddrFeature) Encode ¶
func (f *AddrFeature) Encode() ([]byte, error)
func (*AddrFeature) ParseFrom ¶
func (f *AddrFeature) ParseFrom(address string) error
func (*AddrFeature) Type ¶
func (f *AddrFeature) Type() FeatureType
type ConnectorFlag ¶ added in v0.4.0
type ConnectorFlag uint8
const (
ConnectorUDP ConnectorFlag = 0x01
)
type ConnectorID ¶
type ConnectorID [20]byte
ConnectorID is an identification for tunnel connection.
+------------------+-------+--------+ | ID | FLAG | RSV | WEIGHT | +------------------+-------+--------+ | 16 | 1 | 2 | 1 | +------------------+-------+--------+ ID: 16-byte connector ID value, should be a valid UUID. FLAG: 1-byte flag, 0x1 for UDP connector. RSV: 2-byte reserved field. WEIGHT: connector weight
func NewConnectorID ¶ added in v0.4.0
func NewConnectorID(v []byte) (cid ConnectorID)
func NewUDPConnectorID ¶ added in v0.4.0
func NewUDPConnectorID(v []byte) (cid ConnectorID)
func (ConnectorID) Equal ¶ added in v0.4.0
func (cid ConnectorID) Equal(x ConnectorID) bool
func (ConnectorID) ID ¶ added in v0.4.0
func (cid ConnectorID) ID() (id [connectorIDLen]byte)
func (ConnectorID) IsUDP ¶ added in v0.4.0
func (cid ConnectorID) IsUDP() bool
func (ConnectorID) IsZero ¶ added in v0.4.0
func (cid ConnectorID) IsZero() bool
func (ConnectorID) SetUDP ¶ added in v0.5.0
func (cid ConnectorID) SetUDP(udp bool) ConnectorID
func (ConnectorID) SetWeight ¶ added in v0.5.0
func (cid ConnectorID) SetWeight(weight uint8) ConnectorID
func (ConnectorID) String ¶ added in v0.4.0
func (cid ConnectorID) String() string
func (ConnectorID) Weight ¶ added in v0.5.0
func (cid ConnectorID) Weight() uint8
type Feature ¶
type Feature interface { Type() FeatureType Encode() ([]byte, error) Decode([]byte) error }
Feature represents a feature the client or server owned.
Protocol spec:
+------+----------+------+ | TYPE | LEN | FEATURE | +------+-------+---------+ | 1 | 2 | VAR | +------+-------+---------+ TYPE - feature type, 1 byte. LEN - length of feature data, 2 bytes. FEATURE - feature data.
func NewFeature ¶
func NewFeature(t FeatureType, data []byte) (f Feature, err error)
type FeatureType ¶
type FeatureType uint8
const ( FeatureUserAuth FeatureType = 0x01 FeatureAddr FeatureType = 0x02 FeatureTunnel FeatureType = 0x03 FeatureNetwork FeatureType = 0x04 )
type NetworkFeature ¶ added in v0.5.0
type NetworkFeature struct {
Network NetworkID
}
NetworkFeature is a relay feature,
Protocol spec:
+---------------------+ | NETWORK | +---------------------+ | 2 | +---------------------+ NETWORK - 2-byte network ID.
func (*NetworkFeature) Decode ¶ added in v0.5.0
func (f *NetworkFeature) Decode(b []byte) error
func (*NetworkFeature) Encode ¶ added in v0.5.0
func (f *NetworkFeature) Encode() ([]byte, error)
func (*NetworkFeature) Type ¶ added in v0.5.0
func (f *NetworkFeature) Type() FeatureType
type Request ¶
Request is a relay client request.
Protocol spec:
+-----+-------------+----+---+-----+----+ | VER | CMD/FLAGS | FEALEN | FEATURES | +-----+-------------+----+---+-----+----+ | 1 | 1 | 2 | VAR | +-----+-------------+--------+----------+ VER - protocol version, 1 byte. CMD/FLAGS - command (low 4-bit) and flags (high 4-bit), 1 byte. FEALEN - length of features, 2 bytes. FEATURES - feature list.
type Response ¶
Response is a relay server response.
Protocol spec:
+-----+--------+----+---+-----+----+ | VER | STATUS | FEALEN | FEATURES | +-----+--------+----+---+-----+----+ | 1 | 1 | 2 | VAR | +-----+--------+--------+----------+ VER - protocol version, 1 byte. STATUS - server status, 1 byte. FEALEN - length of features, 2 bytes. FEATURES - feature list.
type TunnelFeature ¶
type TunnelFeature struct {
ID [20]byte
}
TunnelFeature is a relay feature,
Protocol spec:
+---------------------+ | TUNNEL/CONNECTOR ID | +---------------------+ | 20 | +---------------------+ ID - 20-byte tunnel ID for request or connector ID for response.
func (*TunnelFeature) Decode ¶
func (f *TunnelFeature) Decode(b []byte) error
func (*TunnelFeature) Encode ¶
func (f *TunnelFeature) Encode() ([]byte, error)
func (*TunnelFeature) Type ¶
func (f *TunnelFeature) Type() FeatureType
type TunnelID ¶
type TunnelID [20]byte
TunnelID is an identification for tunnel.
+------------------+-------+--------+ | ID | FLAG | RSV | WEIGHT | +------------------+-------+--------+ | 16 | 1 | 2 | 1 | +------------------+-------+--------+ ID: 16-byte tunnel ID value, should be a valid UUID. FLAG: 1-byte flag, 0x80 for private tunnel. RSV: 2-byte reserved field. WEIGHT: tunnel weight
func NewPrivateTunnelID ¶ added in v0.3.0
func NewTunnelID ¶ added in v0.3.0
func (TunnelID) SetPrivate ¶ added in v0.5.0
type UserAuthFeature ¶
UserAuthFeature is a relay feature, it contains the username and password for user authentication on server side.
Protocol spec:
+------+----------+------+----------+ | ULEN | UNAME | PLEN | PASSWD | +------+----------+------+----------+ | 1 | 0 to 255 | 1 | 1 to 255 | +------+----------+------+----------+ ULEN - length of username field, 1 byte. UNAME - username, variable length, 0 to 255 bytes, 0 means no username. PLEN - length of password field, 1 byte. PASSWD - password, variable length, 0 to 255 bytes, 0 means no password.
func (*UserAuthFeature) Decode ¶
func (f *UserAuthFeature) Decode(b []byte) error
func (*UserAuthFeature) Encode ¶
func (f *UserAuthFeature) Encode() ([]byte, error)
func (*UserAuthFeature) Type ¶
func (f *UserAuthFeature) Type() FeatureType
Click to show internal directories.
Click to hide internal directories.