m_socks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATUS_VERIFY  uint = 0
	STATUS_CONNECT uint = 1
)

进度

View Source
const (
	V5  uint = 0
	V4  uint = 1
	V4A uint = 2
)

版本

View Source
const (
	CONNECT      uint = 0
	BIND         uint = 1
	UDPASSOCIATE uint = 2
)

命令类型

View Source
const (
	IPV4     uint = 0
	IPV6     uint = 1
	HOSTNAME uint = 2
)

地址类型

View Source
const (
	// Ver is socks protocol version
	Ver byte = 0x05

	// MethodNone is none method
	MethodNone byte = 0x00

	// MethodGSSAPI is gssapi method // MUST Support // todo
	MethodGSSAPI byte = 0x01

	// MethodUserPassword is username / password auth method
	MethodUsernamePassword byte = 0x02

	// MethodUnsupportAll means unsupport all given methods
	MethodUnsupportAll byte = 0xFF

	// UserPassVer is username/password auth protocol version
	UserPassVer byte = 0x01

	// UserPassStatusSuccess is success status of username/password auth
	UserPassStatusSuccess byte = 0x00

	// UserPassStatusFailure is failure status of username/password auth
	UserPassStatusFailure byte = 0x01

	// CmdConnect is connect connect
	CmdConnect byte = 0x01
	// CmdBind is bind command
	CmdBind byte = 0x02
	// CmdUDP is UDP command
	CmdUDP byte = 0x03

	// ATYPIPv4 is ipv4 address type
	ATYPIPv4 byte = 0x01 // 4 octets
	// ATYPDomain is domain address type
	// The first octet of the address field contains the number of octets of name that follow, there is no terminating NUL octet.
	ATYPDomain byte = 0x03
	// ATYPIPv6 is ipv6 address type
	ATYPIPv6 byte = 0x04 // 16 octets

	// RepSuccess means that success for repling
	RepSuccess byte = 0x00
	// RepServerFailure means the server failure
	RepServerFailure byte = 0x01
	// RepNotAllowed means the request not allowed
	RepNotAllowed byte = 0x02
	// RepNetworkUnreachable means the network unreachable
	RepNetworkUnreachable byte = 0x03
	// RepHostUnreachable means the host unreachable
	RepHostUnreachable byte = 0x04
	// RepConnectionRefused means the connection refused
	RepConnectionRefused byte = 0x05
	// RepTTLExpired means the TTL expired
	RepTTLExpired byte = 0x06
	// RepCommandNotSupported means the request command not supported
	RepCommandNotSupported byte = 0x07
	// RepAddressNotSupported means the request address not supported
	ReqAddressNotSupported byte = 0x08
)
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)
	InfoUDPAssociate        = Error(9)
)

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

View Source
var UDPEnabled = false

UDPEnabled is the toggle for UDP support

Functions

func NewRequest

func NewRequest(conn *net.Conn) *request

Types

type Addr

type Addr []byte

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

func HandShake

func HandShake(rw io.ReadWriter) (Addr, error)

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, 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) String

func (a Addr) String() string

String serializes SOCKS address a to string form.

type Datagram

type Datagram struct {
	Rsv     []byte // 0x00 0x00
	Frag    byte
	Atyp    byte
	DstAddr []byte
	DstPort []byte // 2 bytes
	Data    []byte
}

Datagram is the UDP packet

type Error

type Error byte

Error represents a SOCKS error

func (Error) Error

func (err Error) Error() string

type NegotiationReply

type NegotiationReply struct {
	Ver    byte
	Method byte
}

NegotiationReply is the negotiation reply packet

type NegotiationRequest

type NegotiationRequest struct {
	Ver      byte
	NMethods byte
	Methods  []byte // 1-255 bytes
}

NegotiationRequest is the negotiation request packet

type Reply

type Reply struct {
	Ver  byte
	Rep  byte
	Rsv  byte // 0x00
	Atyp byte
	// CONNECT socks server's address which used to connecct to dst addr
	// BIND ...
	// UDP socks server's address which used to connect to dst addr
	BndAddr []byte
	// CONNECT socks server's port which used to connect to dst addr
	// BIND ...
	// UDP socks server's port which used to connecct to dst addr
	BndPort []byte // 2bytes
}

Reply is the reply packet

type UserPassNegotiationReply

type UserPassNegotiationReply struct {
	Ver    byte
	Status byte
}

UserPassNegotiationReply is the negotiation username/password reply packet

type UserPassNegotiationRequest

type UserPassNegotiationRequest struct {
	Ver    byte
	Ulen   byte
	Uname  []byte // 1-255 bytes
	Plen   byte
	Passwd []byte // 1-255 bytes
}

UserPassNegotiationRequest is the negotiation username/password request packet

Jump to

Keyboard shortcuts

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