Documentation ¶
Index ¶
- Constants
- Variables
- func GenToken(state quic.ConnectionState, uuid [16]byte, password string) (token [32]byte, err error)
- func NewServerHandler(option *ServerOption, quicConn quic.EarlyConnection, uuid uuid.UUID) common.ServerHandler
- type Address
- type Authenticate
- type BufferedReader
- type BufferedWriter
- type Client
- func (t Client) Close()
- func (t *Client) DialContextWithDialer(ctx context.Context, metadata *C.Metadata, dialer C.Dialer, ...) (net.Conn, error)
- func (t Client) DialerRef() C.Dialer
- func (t Client) LastVisited() time.Time
- func (t *Client) ListenPacketWithDialer(ctx context.Context, metadata *C.Metadata, dialer C.Dialer, ...) (net.PacketConn, error)
- func (t Client) OpenStreams() int64
- func (t Client) SetLastVisited(last time.Time)
- type ClientOption
- type CommandHead
- type CommandType
- type Connect
- type Dissociate
- type Heartbeat
- type Packet
- type ServerOption
Constants ¶
View Source
const ( AuthenticateType = CommandType(0x00) ConnectType = CommandType(0x01) PacketType = CommandType(0x02) DissociateType = CommandType(0x03) HeartbeatType = CommandType(0x04) )
View Source
const ( AtypDomainName byte = 0 AtypIPv4 byte = 1 AtypIPv6 byte = 2 AtypNone byte = 255 // Address type None is used in Packet commands that is not the first fragment of a UDP packet. )
Addr types
View Source
const ( ProtocolError = quic.ApplicationErrorCode(0xfffffff0) AuthenticationFailed = quic.ApplicationErrorCode(0xfffffff1) AuthenticationTimeout = quic.ApplicationErrorCode(0xfffffff2) BadCommand = quic.ApplicationErrorCode(0xfffffff3) )
View Source
const VER byte = 0x05
Variables ¶
View Source
var MaxFragSize = 1200 - PacketOverHead - 3
MaxFragSize is a safe udp relay packet size because tuicv5 support udp fragment so we unneeded to do a magic modify for quic-go to increase MaxDatagramFrameSize it may not work fine in some platform "1200" from quic-go's MaxDatagramSize "-3" from quic-go's DatagramFrame.MaxDataLen
View Source
var PacketOverHead = NewPacket(0, 0, 0, 0, 0, NewAddressAddrPort(netip.AddrPortFrom(netip.IPv6Unspecified(), 0)), nil).BytesLen()
Functions ¶
func NewServerHandler ¶
func NewServerHandler(option *ServerOption, quicConn quic.EarlyConnection, uuid uuid.UUID) common.ServerHandler
Types ¶
type Address ¶
func NewAddress ¶
func NewAddressAddrPort ¶
func ReadAddress ¶
func ReadAddress(reader BufferedReader) (c Address, err error)
func (Address) WriteTo ¶
func (c Address) WriteTo(writer BufferedWriter) (err error)
type Authenticate ¶
type Authenticate struct { CommandHead UUID [16]byte TOKEN [32]byte }
func NewAuthenticate ¶
func NewAuthenticate(UUID [16]byte, TOKEN [32]byte) Authenticate
func ReadAuthenticate ¶
func ReadAuthenticate(reader BufferedReader) (c Authenticate, err error)
func ReadAuthenticateWithHead ¶
func ReadAuthenticateWithHead(head CommandHead, reader BufferedReader) (c Authenticate, err error)
func (Authenticate) BytesLen ¶
func (c Authenticate) BytesLen() int
func (Authenticate) WriteTo ¶
func (c Authenticate) WriteTo(writer BufferedWriter) (err error)
type BufferedReader ¶
type BufferedReader interface { io.Reader io.ByteReader }
type BufferedWriter ¶
type BufferedWriter interface { io.Writer io.ByteWriter }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DialContextWithDialer ¶
func (Client) LastVisited ¶
func (*Client) ListenPacketWithDialer ¶
func (Client) OpenStreams ¶
func (t Client) OpenStreams() int64
func (Client) SetLastVisited ¶
type ClientOption ¶
type CommandHead ¶
type CommandHead struct { VER byte TYPE CommandType }
func NewCommandHead ¶
func NewCommandHead(TYPE CommandType) CommandHead
func ReadCommandHead ¶
func ReadCommandHead(reader BufferedReader) (c CommandHead, err error)
func (CommandHead) BytesLen ¶
func (c CommandHead) BytesLen() int
func (CommandHead) WriteTo ¶
func (c CommandHead) WriteTo(writer BufferedWriter) (err error)
type CommandType ¶
type CommandType byte
func (CommandType) BytesLen ¶
func (c CommandType) BytesLen() int
func (CommandType) String ¶
func (c CommandType) String() string
type Connect ¶
type Connect struct { CommandHead ADDR Address }
func NewConnect ¶
func ReadConnect ¶
func ReadConnect(reader BufferedReader) (c Connect, err error)
func ReadConnectWithHead ¶
func ReadConnectWithHead(head CommandHead, reader BufferedReader) (c Connect, err error)
func (Connect) WriteTo ¶
func (c Connect) WriteTo(writer BufferedWriter) (err error)
type Dissociate ¶
type Dissociate struct { CommandHead ASSOC_ID uint16 }
func NewDissociate ¶
func NewDissociate(ASSOC_ID uint16) Dissociate
func ReadDissociate ¶
func ReadDissociate(reader BufferedReader) (c Dissociate, err error)
func ReadDissociateWithHead ¶
func ReadDissociateWithHead(head CommandHead, reader BufferedReader) (c Dissociate, err error)
func (Dissociate) BytesLen ¶
func (c Dissociate) BytesLen() int
func (Dissociate) WriteTo ¶
func (c Dissociate) WriteTo(writer BufferedWriter) (err error)
type Heartbeat ¶
type Heartbeat struct {
CommandHead
}
func NewHeartbeat ¶
func NewHeartbeat() Heartbeat
func ReadHeartbeat ¶
func ReadHeartbeat(reader BufferedReader) (c Heartbeat, err error)
func ReadHeartbeatWithHead ¶
func ReadHeartbeatWithHead(head CommandHead, reader BufferedReader) (c Heartbeat, err error)
type Packet ¶
type Packet struct { CommandHead ASSOC_ID uint16 PKT_ID uint16 FRAG_TOTAL uint8 FRAG_ID uint8 SIZE uint16 ADDR Address DATA []byte }
func ReadPacket ¶
func ReadPacket(reader BufferedReader) (c Packet, err error)
func ReadPacketWithHead ¶
func ReadPacketWithHead(head CommandHead, reader BufferedReader) (c Packet, err error)
func (Packet) WriteTo ¶
func (c Packet) WriteTo(writer BufferedWriter) (err error)
Click to show internal directories.
Click to hide internal directories.