v4

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

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)
)
View Source
const VER byte = 0x04

Variables

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

Functions

func GenTKN

func GenTKN(token string) [32]byte

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
	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, 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
	Token                 [32]byte
	UdpRelayMode          common.UdpRelayMode
	CongestionController  string
	ReduceRtt             bool
	RequestTimeout        time.Duration
	MaxUdpRelayPacketSize int
	FastOpen              bool
	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 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 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 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

	Tokens                [][32]byte
	MaxUdpRelayPacketSize int
}

Jump to

Keyboard shortcuts

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