socks5

package
v0.0.0-...-ea687ca Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: GPL-3.0 Imports: 8 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.

View Source
const MaxAuthLen = 255

MaxAuthLen is the maximum size of user/password field in SOCKS5 Auth

View Source
const Version = 5

Variables

View Source
var ErrAuth = errors.New("auth failed")

Auth errors used to return a specific "Auth failed" error

Functions

func EncodeUDPPacket

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

func ReadByte

func ReadByte(reader io.Reader) (byte, error)

func ServerHandshake

func ServerHandshake(rw net.Conn, authenticator auth.Authenticator) (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 AddrFromStdAddrPort

func AddrFromStdAddrPort(addrPort netip.AddrPort) Addr

func ClientHandshake

func ClientHandshake(rw io.ReadWriter, addr Addr, command Command, user *User) (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 ReadAddr0

func ReadAddr0(r io.Reader) (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 User

type User struct {
	Username string
	Password string
}

Jump to

Keyboard shortcuts

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