Documentation ¶
Index ¶
Constants ¶
const ( Version = 5 UserPassVer = 1 )
Version = 5
const ( MethodNoAuth uint8 = iota MethodGSSAPI MethodUserPass MethodNoAcceptable uint8 = 0xFF )
Methods
const ( CmdConnect uint8 = iota + 1 CmdBind CmdUDP CmdUDPOverTCP )
Commands
const ( AddrIPv4 uint8 = 1 AddrDomain = 3 AddrIPv6 = 4 )
Address types
const ( Succeeded uint8 = iota Failure Allowed NetUnreachable HostUnreachable ConnRefused TTLExpired CmdUnsupported AddrUnsupported )
Response codes
Variables ¶
var ( ErrBadVersion = errors.New("Bad version") ErrBadFormat = errors.New("Bad format") ErrBadAddrType = errors.New("Bad address type") ErrShortBuffer = errors.New("Short buffer") ErrBadMethod = errors.New("Bad method") ErrAuthFailure = errors.New("Auth failure") )
Errors
Functions ¶
func ReadMethods ¶
ReadMethods returns methods Method selection
+----+----------+----------+ |VER | NMETHODS | METHODS | +----+----------+----------+ | 1 | 1 | 1 to 255 | +----+----------+----------+
func WriteMethod ¶
WriteMethod send the selected method to the client
Types ¶
type Addr ¶
Addr has following struct
+------+----------+----------+ | ATYP | ADDR | PORT | +------+----------+----------+ | 1 | Variable | 2 | +------+----------+----------+
func NewAddrFromAddr ¶
NewAddrFromAddr creates an address object
func NewAddrFromPair ¶
NewAddrFromPair creates an address object from host and port pair
type Reply ¶
Reply is a SOCKSv5 reply
+----+-----+-------+------+----------+----------+ |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT | +----+-----+-------+------+----------+----------+ | 1 | 1 | X'00' | 1 | Variable | 2 | +----+-----+-------+------+----------+----------+
type Request ¶
Request represent a socks5 request The SOCKSv5 request
+----+-----+-------+------+----------+----------+ |VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT | +----+-----+-------+------+----------+----------+ | 1 | 1 | X'00' | 1 | Variable | 2 | +----+-----+-------+------+----------+----------+
func NewRequest ¶
NewRequest creates an request object
func ReadRequest ¶
ReadRequest reads request from the stream
type UDPDatagram ¶
UDPDatagram represent an UDP request
func NewUDPDatagram ¶
func NewUDPDatagram(header *UDPHeader, data []byte) *UDPDatagram
NewUDPDatagram creates an UDPDatagram
func ReadUDPDatagram ¶
func ReadUDPDatagram(r io.Reader) (*UDPDatagram, error)
ReadUDPDatagram reads an UDPDatagram from the stream
type UDPHeader ¶
UDPHeader is the header of an UDP request
+----+------+------+----------+----------+----------+ |RSV | FRAG | ATYP | DST.ADDR | DST.PORT | DATA | +----+------+------+----------+----------+----------+ | 2 | 1 | 1 | Variable | 2 | Variable | +----+------+------+----------+----------+----------+
func NewUDPHeader ¶
NewUDPHeader creates an UDPHeader
type UserPassRequest ¶ added in v0.5.0
Username/Password authentication request
+----+------+----------+------+----------+ |VER | ULEN | UNAME | PLEN | PASSWD | +----+------+----------+------+----------+ | 1 | 1 | 1 to 255 | 1 | 1 to 255 | +----+------+----------+------+----------+
func NewUserPassRequest ¶ added in v0.5.0
func NewUserPassRequest(ver byte, u, p string) *UserPassRequest
func ReadUserPassRequest ¶ added in v0.5.0
func ReadUserPassRequest(r io.Reader) (*UserPassRequest, error)
func (*UserPassRequest) String ¶ added in v0.5.0
func (req *UserPassRequest) String() string
type UserPassResponse ¶ added in v0.5.0
Username/Password authentication response
+----+--------+ |VER | STATUS | +----+--------+ | 1 | 1 | +----+--------+
func NewUserPassResponse ¶ added in v0.5.0
func NewUserPassResponse(ver, status byte) *UserPassResponse
func ReadUserPassResponse ¶ added in v0.5.0
func ReadUserPassResponse(r io.Reader) (*UserPassResponse, error)
func (*UserPassResponse) String ¶ added in v0.5.0
func (res *UserPassResponse) String() string