socks5

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AtypIPv4       = 1
	AtypDomainName = 3
	AtypIPv6       = 4
)

SOCKS address types as defined in RFC 1928 section 5.

View Source
const (
	ErrGeneralFailure       = Error(1)
	ErrConnectionNotAllowed = Error(2)
	ErrNetworkUnreachable   = Error(3)
	ErrHostUnreachable      = Error(4)
	ErrConnectionRefused    = Error(5)
	ErrTTLExpired           = Error(6)
	ErrCommandNotSupported  = Error(7)
	ErrAddressNotSupported  = Error(8)
)

SOCKS errors as defined in RFC 1928 section 6.

View Source
const MaxAddrLen = 1 + 1 + 255 + 2

MaxAddrLen is the maximum size of SOCKS address in bytes.

Variables

This section is empty.

Functions

func EncodeUDPPacket

func EncodeUDPPacket(addr Addr, payload []byte) (packet []byte, err error)

func ServerHandshake

func ServerHandshake(rw net.Conn) (addr Addr, command Command, err error)

ServerHandshake fast-tracks SOCKS initialization to get target address to connect on server side.

Types

type Addr

type Addr []byte

Addr represents a SOCKS address as defined in RFC 1928 section 5.

func ClientHandshake

func ClientHandshake(rw io.ReadWriter, addr Addr, command Command) (Addr, error)

ClientHandshake fast-tracks SOCKS initialization to get target address to connect on client side.

func DecodeUDPPacket

func DecodeUDPPacket(packet []byte) (addr Addr, payload []byte, err error)

DecodeUDPPacket split `packet` to addr payload, and this function is mutable with `packet`

func ParseAddr

func ParseAddr(s string) Addr

ParseAddr parses the address in string s. Returns nil if failed.

func ParseAddrToSocksAddr

func ParseAddrToSocksAddr(addr net.Addr) Addr

ParseAddrToSocksAddr parse a socks addr from net.addr This is a fast path of ParseAddr(addr.String())

func ReadAddr

func ReadAddr(r io.Reader, b []byte) (Addr, error)

func SplitAddr

func SplitAddr(b []byte) Addr

SplitAddr slices a SOCKS address from beginning of b. Returns nil if failed.

func (Addr) String

func (a Addr) String() string

func (Addr) UDPAddr

func (a Addr) UDPAddr() *net.UDPAddr

UDPAddr converts a socks5.Addr to *net.UDPAddr

type Command

type Command = uint8

Command is request commands as defined in RFC 1928 section 4.

const (
	CmdConnect      Command = 1
	CmdBind         Command = 2
	CmdUDPAssociate Command = 3
)

SOCKS request commands as defined in RFC 1928 section 4.

type Error

type Error byte

Error represents a SOCKS error

func (Error) Error

func (err Error) Error() string

type SockListener

type SockListener struct {
	net.Listener
	// contains filtered or unexported fields
}

func NewSocksProxy

func NewSocksProxy(addr string, cb SocksCallback) (*SockListener, error)

func NewSocksProxyV2

func NewSocksProxyV2(addr string, cb SocksCallback, meter snellapi.TrafficMeter) (*SockListener, error)

func (*SockListener) Address

func (l *SockListener) Address() string

func (*SockListener) Close

func (l *SockListener) Close()

type SocksCallback

type SocksCallback func(net.Conn, Addr)

Jump to

Keyboard shortcuts

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