socks5

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Overview

Package socks5 provides SOCKS5 client functionalities.

Index

Constants

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 SOCKS auth.

View Source
const Version = 0x05

Version is the protocol version as defined in RFC 1928 section 4.

Variables

This section is empty.

Functions

func EncodeUDPPacket

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

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, 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(addr net.Addr) Addr

ParseAddr parses a socks addr from net.Addr. This is a fast path of ParseAddrString(addr.String())

func ParseAddrString

func ParseAddrString(s string) Addr

ParseAddrString parses the address in string s to Addr. Returns nil if failed.

func ReadAddr

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

func SerializeAddr

func SerializeAddr(domainName string, dstIP net.IP, dstPort uint16) Addr

SerializeAddr serializes destination address and port to Addr. If a domain name is provided, AtypDomainName would be used first.

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

String returns string of socks5.Addr.

func (Addr) UDPAddr

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

UDPAddr converts a socks5.Addr to *net.UDPAddr.

func (Addr) Valid

func (a Addr) Valid() bool

type Atyp

type Atyp = uint8
const (
	AtypIPv4       Atyp = 0x01
	AtypDomainName Atyp = 0x03
	AtypIPv6       Atyp = 0x04
)

SOCKS address types as defined in RFC 1928 section 5.

type Command

type Command uint8

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

const (
	CmdConnect      Command = 0x01
	CmdBind         Command = 0x02
	CmdUDPAssociate Command = 0x03
)

SOCKS request commands as defined in RFC 1928 section 4.

func (Command) String

func (c Command) String() string

type Reply

type Reply uint8

Reply field as defined in RFC 1928 section 6.

func (Reply) String

func (r Reply) String() string

type User

type User struct {
	Username string
	Password string
}

User provides basic socks5 auth functionality.

Jump to

Keyboard shortcuts

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