Documentation ¶
Index ¶
Constants ¶
const ( CommandConnect = byte(0x01) CommandBind = byte(0x02) CommandAssociate = byte(0x03) )
request command defined
const ( MethodNoAuth = byte(0x00) MethodGSSAPI = byte(0x01) // TODO: not support now MethodUserPassAuth = byte(0x02) MethodNoAcceptable = byte(0xff) )
method defined
const ( ATYPIPv4 = byte(0x01) ATYPDomain = byte(0x03) ATYPIPv6 = byte(0x04) )
address type defined
const ( RepSuccess uint8 = iota RepServerFailure RepRuleFailure RepNetworkUnreachable RepHostUnreachable RepConnectionRefused RepTTLExpired RepCommandNotSupported RepAddrTypeNotSupported )
reply status
const ( // user password version UserPassAuthVersion = byte(0x01) // auth status AuthSuccess = byte(0x00) AuthFailure = byte(0x01) )
auth defined
const VersionSocks5 = byte(0x05)
VersionSocks5 socks protocol version
Variables ¶
var ( ErrUserAuthFailed = fmt.Errorf("user authentication failed") ErrNoSupportedAuth = fmt.Errorf("no supported authentication mechanism") )
auth error defined
var ( ErrUnrecognizedAddrType = errors.New("unrecognized address type") ErrNotSupportVersion = errors.New("not support version") ErrNotSupportMethod = errors.New("not support method") )
error defined
Functions ¶
This section is empty.
Types ¶
type AddrSpec ¶
type AddrSpec struct { FQDN string IP net.IP Port int // private stuff set when Request parsed AddrType byte }
AddrSpec is used to return the target AddrSpec which may be specified as IPv4, IPv6, or a FQDN
func ParseAddrSpec ¶
ParseAddrSpec parse addr(host:port) to the AddrSpec address
type Datagram ¶
Datagram udp packet The SOCKS UDP request/response is formed as follows: +-----+------+-------+----------+----------+----------+ | RSV | FRAG | ATYP | DST.ADDR | DST.PORT | DATA | +-----+------+-------+----------+----------+----------+ | 2 | 1 | X'00' | Variable | 2 | Variable | +-----+------+-------+----------+----------+----------+
func NewDatagram ¶
NewDatagram new packet with dest addr and data
func ParseDatagram ¶
ParseDatagram parse to datagram from bytes
type MethodReply ¶
MethodReply is the negotiation method reply packet The SOCKS handshake method response is formed as follows:
+-----+--------+ | VER | METHOD | +-----+--------+ | 1 | 1 | +-----+--------+
func ParseMethodReply ¶
func ParseMethodReply(r io.Reader) (n MethodReply, err error)
ParseMethodReply parse method reply.
type MethodRequest ¶
MethodRequest is the negotiation method request packet The SOCKS handshake method request is formed as follows:
+-----+----------+---------------+ | VER | NMETHODS | METHODS | +-----+----------+---------------+ | 1 | 1 | X'00' - X'FF' | +-----+----------+---------------+
func NewMethodRequest ¶
func NewMethodRequest(ver byte, medthods []byte) MethodRequest
NewMethodRequest new negotiation method request
func ParseMethodRequest ¶
func ParseMethodRequest(r io.Reader) (mr MethodRequest, err error)
ParseMethodRequest parse method request.
type Reply ¶
type Reply struct { // Version of socks protocol for message Version byte // Socks Response status" Response byte // Reserved byte Reserved byte // Bind Address in socks message BndAddr AddrSpec }
Reply represents the SOCKS5 reply, it contains everything that is not payload The SOCKS5 reply is formed as follows:
+-----+-----+-------+------+----------+-----------+ | VER | REP | RSV | ATYP | BND.ADDR | BND].PORT | +-----+-----+-------+------+----------+-----------+ | 1 | 1 | X'00' | 1 | Variable | 2 | +-----+-----+-------+------+----------+-----------+
func ParseReply ¶
ParseReply parse to reply from io.Reader
type Request ¶
type Request struct { // Version of socks protocol for message Version byte // Socks Command "connect","bind","associate" Command byte // Reserved byte Reserved byte // DstAddr in socks message DstAddr AddrSpec }
Request represents the SOCKS5 request, it contains everything that is not payload The SOCKS5 request is formed as follows:
+-----+-----+-------+------+----------+----------+ | VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT | +-----+-----+-------+------+----------+----------+ | 1 | 1 | X'00' | 1 | Variable | 2 | +-----+-----+-------+------+----------+----------+
func ParseRequest ¶
ParseRequest to request from io.Reader
type UserPassReply ¶
UserPassReply is the negotiation user's password reply packet The SOCKS handshake user's password response is formed as follows:
+-----+--------+ | VER | status | +-----+--------+ | 1 | 1 | +-----+--------+
func ParseUserPassReply ¶
func ParseUserPassReply(r io.Reader) (upr UserPassReply, err error)
ParseUserPassReply parse user's password reply packet.
type UserPassRequest ¶
type UserPassRequest struct { Ver byte Ulen byte Plen byte User []byte // 1-255 bytes Pass []byte // 1-255 bytes }
UserPassRequest is the negotiation user's password request packet The SOCKS handshake user's password request is formed as follows:
+--------------+------+----------+------+----------+ | USERPASS_VER | ULEN | USER | PLEN | PASS | +--------------+------+----------+------+----------+ | 1 | 1 | Variable | 1 | Variable | +--------------+------+----------+------+----------+
func NewUserPassRequest ¶
func NewUserPassRequest(ver byte, user, pass []byte) UserPassRequest
NewUserPassRequest new user's password request packet with ver,user, pass
func ParseUserPassRequest ¶
func ParseUserPassRequest(r io.Reader) (nup UserPassRequest, err error)
ParseUserPassRequest parse user's password request.