Documentation ¶
Overview ¶
Package socks implements essential parts of SOCKS protocol.
Index ¶
- Constants
- Variables
- func Copy(ctx context.Context, dst io.Writer, src io.Reader) (written int64, err error)
- func Copy1(dst io.Writer, src io.Reader) (written int64, err error)
- func Relay(ctx context.Context, left, right net.Conn) (int64, int64, error)
- func TCPLocalOnly(ctx context.Context, socksAddr string)
- type Addr
- type Error
Constants ¶
View Source
const ( CmdConnect = 1 CmdBind = 2 CmdUDPAssociate = 3 )
SOCKS request commands as defined in RFC 1928 section 4.
View Source
const ( AtypIPv4 = 1 AtypDomainName = 3 AtypIPv6 = 4 AtypProxy = 5 // 作为代理 AtypProxyNewIPv4 = 6 // 建立代理 AtypProxyNewIPv6 = 7 // 建立代理 AtypProxyNewDomainName = 8 // 建立代理 )
SOCKS address types as defined in RFC 1928 section 5.
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 ErrCMDConn = errors.New("ErrCMDConn")
View Source
var ErrCMDConnNew = errors.New("ErrCMDConnNew")
View Source
var UDPEnabled = false
UDPEnabled is the toggle for UDP support
Functions ¶
func Relay ¶
Relay copies between left and right bidirectionally. Returns number of bytes copied from right to left, from left to right, and any error occurred.
func TCPLocalOnly ¶
Listen on addr and proxy to server to reach target from getAddr.
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)
Handshake fast-tracks SOCKS initialization to get target address to connect.
Click to show internal directories.
Click to hide internal directories.