tuic

package
v0.0.0-...-45a9176 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultStreamReceiveWindow     = 15728640 // 15 MB/s
	DefaultConnectionReceiveWindow = 67108864 // 64 MB/s
)
View Source
const (
	AuthenticateType = CommandType(0x00)
	ConnectType      = CommandType(0x01)
	PacketType       = CommandType(0x02)
	DissociateType   = CommandType(0x03)
	HeartbeatType    = CommandType(0x04)
	ResponseType     = CommandType(0xff)
)
View Source
const (
	AtypDomainName byte = 0
	AtypIPv4       byte = 1
	AtypIPv6       byte = 2
)

Addr types

View Source
const (
	ProtocolError         = quic.ApplicationErrorCode(0xfffffff0)
	AuthenticationFailed  = quic.ApplicationErrorCode(0xfffffff1)
	AuthenticationTimeout = quic.ApplicationErrorCode(0xfffffff2)
	BadCommand            = quic.ApplicationErrorCode(0xfffffff3)
)

Variables

View Source
var (
	ClientClosed       = errors.New("tuic: client closed")
	TooManyOpenStreams = errors.New("tuic: too many open streams")
)

Functions

func GenTKN

func GenTKN(token string) [32]byte

func SetCongestionController

func SetCongestionController(quicConn quic.Connection, cc string)

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 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
	TKN [32]byte
}

func NewAuthenticate

func NewAuthenticate(TKN [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) *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 DialFunc) (net.Conn, error)

func (*Client) ListenPacketWithDialer

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

type ClientOption

type ClientOption struct {
	TlsConfig             *tls.Config
	QuicConfig            *quic.Config
	Host                  string
	Token                 [32]byte
	UdpRelayMode          string
	CongestionController  string
	ReduceRtt             bool
	RequestTimeout        time.Duration
	MaxUdpRelayPacketSize int
	FastOpen              bool
	MaxOpenStreams        int64
}

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 DialFunc

type DialFunc func(ctx context.Context, dialer C.Dialer) (pc net.PacketConn, addr net.Addr, err error)

type Dissociate

type Dissociate struct {
	CommandHead
	ASSOC_ID uint32
}

func NewDissociate

func NewDissociate(ASSOC_ID uint32) 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 uint32
	LEN      uint16
	ADDR     Address
	DATA     []byte
}

func NewPacket

func NewPacket(ASSOC_ID uint32, LEN 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 PoolClient

type PoolClient struct {
	*ClientOption
	// contains filtered or unexported fields
}

func NewPoolClient

func NewPoolClient(clientOption *ClientOption) *PoolClient

func (*PoolClient) DialContextWithDialer

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

func (*PoolClient) ListenPacketWithDialer

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

type Response

type Response struct {
	CommandHead
	REP byte
}

func NewResponse

func NewResponse(REP byte) Response

func NewResponseFailed

func NewResponseFailed() Response

func NewResponseSucceed

func NewResponseSucceed() Response

func ReadResponse

func ReadResponse(reader BufferedReader) (c Response, err error)

func ReadResponseWithHead

func ReadResponseWithHead(head CommandHead, reader BufferedReader) (c Response, err error)

func (Response) BytesLen

func (c Response) BytesLen() int

func (Response) IsFailed

func (c Response) IsFailed() bool

func (Response) IsSucceed

func (c Response) IsSucceed() bool

func (Response) WriteTo

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

type Server

type Server struct {
	*ServerOption
	// contains filtered or unexported fields
}

func NewServer

func NewServer(option *ServerOption, pc net.PacketConn) (*Server, error)

func (*Server) Close

func (s *Server) Close() error

func (*Server) Serve

func (s *Server) Serve() error

type ServerAssocIdAddr

type ServerAssocIdAddr struct {
	// contains filtered or unexported fields
}

func (ServerAssocIdAddr) Network

func (a ServerAssocIdAddr) Network() string

func (ServerAssocIdAddr) RawAddr

func (a ServerAssocIdAddr) RawAddr() net.Addr

func (ServerAssocIdAddr) String

func (a ServerAssocIdAddr) String() string

type ServerOption

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

	TlsConfig             *tls.Config
	QuicConfig            *quic.Config
	Tokens                [][32]byte
	CongestionController  string
	AuthenticationTimeout time.Duration
	MaxUdpRelayPacketSize int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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