v5

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

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

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

View Source
var PacketOverHead = NewPacket(0, 0, 0, 0, 0, NewAddressAddrPort(netip.AddrPortFrom(netip.IPv6Unspecified(), 0)), nil).BytesLen()

Functions

func GenToken

func GenToken(state quic.ConnectionState, uuid [16]byte, password string) (token [32]byte, err error)

func NewServerHandler

func NewServerHandler(option *ServerOption, quicConn quic.EarlyConnection, uuid uuid.UUID) common.ServerHandler

Types

type Address

type Address struct {
	TYPE byte
	ADDR []byte
	PORT uint16
}

func NewAddress

func NewAddress(metadata *C.Metadata) Address

func NewAddressAddrPort

func NewAddressAddrPort(addrPort netip.AddrPort) Address

func NewAddressNetAddr

func NewAddressNetAddr(addr net.Addr) (Address, error)

func ReadAddress

func ReadAddress(reader BufferedReader) (c Address, err error)

func (Address) BytesLen

func (c Address) BytesLen() int

func (Address) SocksAddr

func (c Address) SocksAddr() socks5.Addr

func (Address) String

func (c Address) String() string

func (Address) UDPAddr

func (c Address) UDPAddr() *net.UDPAddr

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 NewClient

func NewClient(clientOption *ClientOption, udp bool, dialerRef C.Dialer) *Client

func (Client) Close

func (t Client) Close()

func (*Client) DialContextWithDialer

func (t *Client) DialContextWithDialer(ctx context.Context, metadata *C.Metadata, dialer C.Dialer, dialFn common.DialFunc) (net.Conn, error)

func (Client) DialerRef

func (t Client) DialerRef() C.Dialer

func (Client) LastVisited

func (t Client) LastVisited() time.Time

func (*Client) ListenPacketWithDialer

func (t *Client) ListenPacketWithDialer(ctx context.Context, metadata *C.Metadata, dialer C.Dialer, dialFn common.DialFunc) (net.PacketConn, error)

func (Client) OpenStreams

func (t Client) OpenStreams() int64

func (Client) SetLastVisited

func (t Client) SetLastVisited(last time.Time)

type ClientOption

type ClientOption struct {
	TlsConfig             *tls.Config
	QuicConfig            *quic.Config
	Uuid                  [16]byte
	Password              string
	UdpRelayMode          common.UdpRelayMode
	CongestionController  string
	ReduceRtt             bool
	MaxUdpRelayPacketSize int
	MaxOpenStreams        int64
	CWND                  int
}

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 NewConnect(ADDR Address) Connect

func ReadConnect

func ReadConnect(reader BufferedReader) (c Connect, err error)

func ReadConnectWithHead

func ReadConnectWithHead(head CommandHead, reader BufferedReader) (c Connect, err error)

func (Connect) BytesLen

func (c Connect) BytesLen() int

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 NewPacket

func NewPacket(ASSOC_ID uint16, PKT_ID uint16, FRGA_TOTAL uint8, FRAG_ID uint8, SIZE uint16, ADDR Address, DATA []byte) Packet

func ReadPacket

func ReadPacket(reader BufferedReader) (c Packet, err error)

func ReadPacketWithHead

func ReadPacketWithHead(head CommandHead, reader BufferedReader) (c Packet, err error)

func (Packet) BytesLen

func (c Packet) BytesLen() int

func (Packet) WriteTo

func (c Packet) WriteTo(writer BufferedWriter) (err error)

type ServerOption

type ServerOption struct {
	HandleTcpFn func(conn net.Conn, addr socks5.Addr, additions ...inbound.Addition) error
	HandleUdpFn func(addr socks5.Addr, packet C.UDPPacket, additions ...inbound.Addition) error

	Users                 map[[16]byte]string
	MaxUdpRelayPacketSize int
}

Jump to

Keyboard shortcuts

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