tuic

package
v0.0.0-...-5f1f6bc Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: AGPL-3.0 Imports: 24 Imported by: 0

README

tuic

This part of code is modified from clash.meta with many thanks.

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 (
	DefaultTCPTimeout = 5 * time.Second
	DefaultUDPTimeout = DefaultTCPTimeout
)
View Source
const Ver5 = 0x5

Variables

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

Functions

func GenToken

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

func NewDialer

func NewDialer(nextDialer netproxy.Dialer, header protocol.Header) (netproxy.Dialer, error)

Types

type Address

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

func NewAddress

func NewAddress(metadata *protocol.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) 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)

func (Address) WriteToBytes

func (c Address) WriteToBytes(b []byte) (n int)

type Authenticate

type Authenticate struct {
	*CommandHead
	UUID  uuid.UUID
	TOKEN [32]byte
	VER   byte
}

func NewAuthenticate

func NewAuthenticate(UUID [16]byte, TOKEN [32]byte, VER 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 ClientOption

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

type CommandHead

type CommandHead struct {
	VER  byte
	TYPE CommandType
}

func NewCommandHead

func NewCommandHead(TYPE CommandType, VER byte) *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)

func (CommandHead) WriteToBytes

func (c CommandHead) WriteToBytes(buf []byte) (n int)

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, VER byte) *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)

func (Connect) WriteToBytes

func (c Connect) WriteToBytes(b []byte) (n int)

type Dialer

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

func (*Dialer) Dial

func (d *Dialer) Dial(network string, addr string) (c netproxy.Conn, err error)

func (*Dialer) DialTcp

func (d *Dialer) DialTcp(addr string) (c netproxy.Conn, err error)

func (*Dialer) DialUdp

func (d *Dialer) DialUdp(addr string) (c netproxy.PacketConn, err error)

type Dissociate

type Dissociate struct {
	*CommandHead
	ASSOC_ID uint16
}

func NewDissociate

func NewDissociate(ASSOC_ID uint16, VER byte) *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(VER byte) *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, VER 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 Packets

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

func NewPackets

func NewPackets() *Packets

func (*Packets) Close

func (p *Packets) Close() error

func (*Packets) PopFrontBlock

func (p *Packets) PopFrontBlock() (packet *Packet, closed bool)

func (*Packets) PushBack

func (p *Packets) PushBack(packet *Packet)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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