Documentation ¶
Index ¶
- Constants
- func EncodeUDPPacket(addr Addr, payload []byte) (packet []byte, err error)
- func ServerHandshake(rw net.Conn) (addr Addr, command Command, err error)
- type Addr
- func ClientHandshake(rw io.ReadWriter, addr Addr, command Command) (Addr, error)
- func DecodeUDPPacket(packet []byte) (addr Addr, payload []byte, err error)
- func ParseAddr(s string) Addr
- func ParseAddrToSocksAddr(addr net.Addr) Addr
- func ReadAddr(r io.Reader, b []byte) (Addr, error)
- func SplitAddr(b []byte) Addr
- type Command
- type Error
- type SockListener
- type SocksCallback
Constants ¶
View Source
const ( AtypIPv4 = 1 AtypDomainName = 3 AtypIPv6 = 4 )
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) )
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 ¶
This section is empty.
Functions ¶
Types ¶
type Addr ¶
type Addr []byte
Addr represents a SOCKS address as defined in RFC 1928 section 5.
func ClientHandshake ¶
ClientHandshake fast-tracks SOCKS initialization to get target address to connect on client side.
func DecodeUDPPacket ¶
DecodeUDPPacket split `packet` to addr payload, and this function is mutable with `packet`
func ParseAddrToSocksAddr ¶
ParseAddrToSocksAddr parse a socks addr from net.addr This is a fast path of ParseAddr(addr.String())
type Command ¶
type Command = uint8
Command is request commands as defined in RFC 1928 section 4.
SOCKS request commands as defined in RFC 1928 section 4.
type SockListener ¶
func NewSocksProxy ¶
func NewSocksProxy(addr string, cb SocksCallback) (*SockListener, error)
func NewSocksProxyV2 ¶
func NewSocksProxyV2(addr string, cb SocksCallback, meter snellapi.TrafficMeter) (*SockListener, error)
func (*SockListener) Address ¶
func (l *SockListener) Address() string
func (*SockListener) Close ¶
func (l *SockListener) Close()
type SocksCallback ¶
Click to show internal directories.
Click to hide internal directories.