socks

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdConnect      = 1
	CmdBind         = 2
	CmdUDPAssociate = 3
)

SOCKS request commands as defined in RFC 1928 section 4.

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

SOCKS address types as defined in RFC 1928 section 5.

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

SOCKS errors as defined in RFC 1928 section 6.

View Source
const (
	SocksAddressIPv4Length = 1 + net.IPv4len + 2
	SocksAddressIPv6Length = 1 + net.IPv6len + 2

	// MaxAddrLen is the maximum size of SOCKS address in bytes.
	MaxAddrLen = 1 + 1 + 255 + 2
)

Variables

This section is empty.

Functions

func ReadAddr

func ReadAddr(dst []byte, r io.Reader) (n int, err error)

ReadAddr reads just enough bytes from r to get a valid Addr.

The destination slice must be big enough to hold the socks address. Otherwise, this function might panic.

func WriteAddr

func WriteAddr(dst []byte, s string) (n int, host string, port int, err error)

WriteAddr parses an address string into a socks address and writes to the destination slice.

The destination slice must be big enough to hold the socks address. Otherwise, this function might panic.

func WriteUDPAddrAsSocksAddr

func WriteUDPAddrAsSocksAddr(b []byte, addr *net.UDPAddr) (n int)

WriteUDPAddrAsSocksAddr converts a UDP address into socks address and writes to the buffer.

No buffer length checks are performed. Make sure the buffer can hold the socks address.

Types

type Addr

type Addr []byte

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

func AddrFromReader

func AddrFromReader(r io.Reader) (Addr, error)

AddrFromReader allocates and reads a socks address from an io.Reader.

To avoid allocation, use ReadAddr instead.

func ParseAddr

func ParseAddr(s string) (Addr, error)

ParseAddr parses an address string into a socks address.

To avoid allocation, use WriteAddr instead.

func SplitAddr

func SplitAddr(b []byte) (Addr, error)

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

func (Addr) Addr

func (a Addr) Addr(network string) (net.Addr, error)

func (Addr) String

func (a Addr) String() string

String serializes SOCKS address a to string form.

func (Addr) UDPAddr

func (a Addr) UDPAddr(preferIPv6 bool) (*net.UDPAddr, error)

Jump to

Keyboard shortcuts

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