snell

package
v1.19.30 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version1            = 1
	Version2            = 2
	Version3            = 3
	Version4            = 4
	Version5            = 5
	DefaultSnellVersion = Version1
)
View Source
const (
	CommandPing       byte = 0
	CommandConnect    byte = 1
	CommandConnectV2  byte = 5
	CommandUDP        byte = 6
	CommondUDPForward byte = 1

	CommandTunnel byte = 0
	CommandPong   byte = 1
	CommandError  byte = 2

	Version byte = 1
)

Variables

This section is empty.

Functions

func HalfClose

func HalfClose(conn net.Conn) error

HalfClose only works after the request negotiated the reuse command.

func NewAES128GCM

func NewAES128GCM(psk []byte) shadowaead.Cipher

func NewChacha20Poly1305

func NewChacha20Poly1305(psk []byte) shadowaead.Cipher

func PacketConn

func PacketConn(conn net.Conn) net.PacketConn

func ReadPacket

func ReadPacket(r io.Reader, payload []byte) (net.Addr, int, error)

func UdpRequestHeaderLength added in v1.19.26

func UdpRequestHeaderLength(socks5Addr []byte) int

func WriteHeader

func WriteHeader(conn net.Conn, host string, port uint, version int) error

func WriteHeaderWithReuse added in v1.19.26

func WriteHeaderWithReuse(conn net.Conn, host string, port uint, version int, reuse bool) error

func WritePacket

func WritePacket(w io.Writer, socks5Addr, payload []byte) (int, error)

func WritePacketResponse added in v1.19.26

func WritePacketResponse(w io.Writer, addr net.Addr, payload []byte) (int, error)

func WriteUDPHeader

func WriteUDPHeader(conn net.Conn, version int) error

Types

type Pool

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

func NewPool

func NewPool(factory func(context.Context) (*Snell, error)) *Pool

func (*Pool) Get

func (p *Pool) Get() (net.Conn, error)

func (*Pool) GetContext

func (p *Pool) GetContext(ctx context.Context) (net.Conn, error)

func (*Pool) Put

func (p *Pool) Put(conn *Snell)

type PoolConn

type PoolConn struct {
	*Snell
	// contains filtered or unexported fields
}

func (*PoolConn) Close

func (pc *PoolConn) Close() error

func (*PoolConn) CloseWrite added in v1.19.26

func (pc *PoolConn) CloseWrite() error

func (*PoolConn) MarkReusable added in v1.19.28

func (pc *PoolConn) MarkReusable()

MarkReusable allows Close to return this request to the pool after the request header is committed.

func (*PoolConn) Read

func (pc *PoolConn) Read(b []byte) (int, error)

func (*PoolConn) Write

func (pc *PoolConn) Write(b []byte) (int, error)

type Snell

type Snell struct {
	net.Conn
	// contains filtered or unexported fields
}

func ServerStreamConn added in v1.19.26

func ServerStreamConn(conn net.Conn, psk []byte, version int) *Snell

func StreamConn

func StreamConn(conn net.Conn, psk []byte, version int) *Snell

func (*Snell) Read

func (s *Snell) Read(b []byte) (int, error)

func (*Snell) ReadReply added in v1.19.26

func (s *Snell) ReadReply() error

func (*Snell) WritePacketFrame added in v1.19.26

func (s *Snell) WritePacketFrame(b []byte) (int, error)

type UDPRequest added in v1.19.26

type UDPRequest struct {
	Host    string
	Ip      netip.Addr
	Port    uint16
	Payload []byte
}

func ParseUDPRequest added in v1.19.26

func ParseUDPRequest(packet []byte) (UDPRequest, error)

Jump to

Keyboard shortcuts

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