mysocks5

package
v1.11.32 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version5     byte = 0x05 //SOCKS5 的版本号,固定为 0x05。
	Version4     byte = 0x04 //SOCKS5 的版本号,固定为 0x05。
	Reserved     byte = 0x00 //保留字段,固定为 0x00。
	ReplySuccess byte = 0x00 //成功应答
)
View Source
const (
	CmdConnect      = 0x01 //客户端通过代理服务器与目标服务器建立一个 TCP 连接
	CmdBind         = 0x02 //用于服务器模式下的连接。这个命令允许客户端告诉代理服务器监听特定端口
	CmdUDPAssociate = 0x03 //此命令用于通过 SOCKS5 代理发送和接收 UDP 数据报
)

socks5 request commands

View Source
const (
	ATypeIPv4   = 0x01 //IPv4 地址(4 字节)
	ATypeDomain = 0x03 //域名(第一个字节是域名长度,后跟域名字符串)
	ATypeIPV6   = 0x04 //IPv6 地址(16 字节)
)
View Source
const (
	MaxAddrLen = 1 + 1 + 255 + 2
	MaxReqLen  = 1 + 1 + 1 + MaxAddrLen
)
View Source
const (
	ErrGeneralFailure       = Error(1) //General SOCKS server failure
	ErrConnectionNotAllowed = Error(2) //Connection not allowed by ruleset
	ErrNetworkUnreachable   = Error(3) //Network unreachable
	ErrHostUnreachable      = Error(4) //Host unreachable
	ErrConnectionRefused    = Error(5) //Connection refused
	ErrTTLExpired           = Error(6) //TTL expired
	ErrCommandNotSupported  = Error(7) //Command not supported
	ErrAddressNotSupported  = Error(8) //Address type not supported
	ErrUdpAssociate         = Error(9) //udp associate
)

SOCKS errors as defined in RFC 1928 section 6.

View Source
const (
	MethodNoAuth = 0x00 //表示无需认证
	MethodAuth   = 0x02 //表示用户名/密码认证
)

Variables

This section is empty.

Functions

func ConnToSocks5 added in v1.11.13

func ConnToSocks5(addr Addr, remoteAddr string, authfn func() (userName, password string)) (net.Conn, error)

Types

type Addr

type Addr []byte

func Handshake

func Handshake(rw io.ReadWriter, authFn func(username, password string) bool) (Addr, error)

Handshake fast-tracks SOCKS initialization to get target address to connect.

func ParseAddr

func ParseAddr(s string) Addr

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

func ReadAddr

func ReadAddr(r io.Reader) (Addr, int, error)

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

func SplitAddr

func SplitAddr(b []byte) Addr

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

func (Addr) AddType

func (a Addr) AddType() (string, int)

func (Addr) String

func (a Addr) String() string

type Error

type Error byte

func (Error) Error

func (self Error) Error() string

Jump to

Keyboard shortcuts

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