Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeAddr(addr *SocksAddr, b []byte) error
- func EncodeAddr(addr *SocksAddr, b []byte) (int, error)
- type SocksAddr
- type SocksAuthMethod
- type SocksCommand
- type SocksDialer
- type SocksUsernamePassword
- type UDPDatagram
- type UDPHeader
- type UdpSocksConn
- func (c *UdpSocksConn) Close() error
- func (c *UdpSocksConn) LocalAddr() net.Addr
- func (c *UdpSocksConn) Read(b []byte) (n int, err error)
- func (c *UdpSocksConn) RemoteAddr() net.Addr
- func (c *UdpSocksConn) SetDeadline(t time.Time) error
- func (c *UdpSocksConn) SetReadDeadline(t time.Time) error
- func (c *UdpSocksConn) SetRealUDP(udp net.Conn)
- func (c *UdpSocksConn) SetWriteDeadline(t time.Time) error
- func (c *UdpSocksConn) Write(b []byte) (n int, err error)
Constants ¶
View Source
const ( SocksCmdConnect SocksCommand = 0x01 // establishes an active-open forward proxy connection SockscmdBind SocksCommand = 0x02 // establishes a passive-open forward proxy connection SockscmdUDP SocksCommand = 0x03 // establishes a udp associate connection SocksAuthMethodNotRequired SocksAuthMethod = 0x00 // no authentication required SocksAuthMethodUsernamePassword SocksAuthMethod = 0x02 // use username/password )
Wire protocol constants.
View Source
const ( AddrIPv4 uint8 = 1 AddrDomain = 3 AddrIPv6 = 4 )
Address
+------+----------+----------+ | ATYP | ADDR | PORT | +------+----------+----------+ | 1 | Variable | 2 | +------+----------+----------+
Variables ¶
View Source
var (
ErrBadAddrType = errors.New("Bad address type")
)
Functions ¶
func DecodeAddr ¶
Types ¶
type SocksAuthMethod ¶
type SocksAuthMethod socksAuthMethod
type SocksCommand ¶
type SocksCommand int
A Command represents a SOCKS command.
func (SocksCommand) String ¶
func (cmd SocksCommand) String() string
type SocksDialer ¶
type SocksDialer struct { // ProxyDial specifies the optional dial function for // establishing the transport connection. ProxyDial func(context.Context, string, string) (net.Conn, error) // AuthMethods specifies the list of request authentication // methods. // If empty, SOCKS client requests only AuthMethodNotRequired. AuthMethods []SocksAuthMethod // Authenticate specifies the optional authentication // function. It must be non-nil when AuthMethods is not empty. // It must return an error when the authentication is failed. Authenticate func(context.Context, io.ReadWriter, socksAuthMethod) error // contains filtered or unexported fields }
A Dialer holds SOCKS-specific options.
func (*SocksDialer) SetCMD ¶
func (d *SocksDialer) SetCMD(cmd SocksCommand)
type SocksUsernamePassword ¶
func (*SocksUsernamePassword) Authenticate ¶
func (up *SocksUsernamePassword) Authenticate(ctx context.Context, rw io.ReadWriter, auth socksAuthMethod) error
type UDPDatagram ¶
func NewUDPDatagram ¶
func NewUDPDatagram(header *UDPHeader, data []byte) *UDPDatagram
func ReadUDPDatagram ¶
func ReadUDPDatagram(r io.Reader) (*UDPDatagram, error)
type UDPHeader ¶
UDP request
+----+------+------+----------+----------+----------+ |RSV | FRAG | ATYP | DST.ADDR | DST.PORT | DATA | +----+------+------+----------+----------+----------+ | 2 | 1 | 1 | Variable | 2 | Variable | +----+------+------+----------+----------+----------+
type UdpSocksConn ¶
type UdpSocksConn struct {
// contains filtered or unexported fields
}
func NewUdpSocksConn ¶
func NewUdpSocksConn(addr *SocksAddr, tcpconn, udpconn net.Conn) *UdpSocksConn
func (*UdpSocksConn) Close ¶
func (c *UdpSocksConn) Close() error
func (*UdpSocksConn) LocalAddr ¶
func (c *UdpSocksConn) LocalAddr() net.Addr
func (*UdpSocksConn) RemoteAddr ¶
func (c *UdpSocksConn) RemoteAddr() net.Addr
func (*UdpSocksConn) SetDeadline ¶
func (c *UdpSocksConn) SetDeadline(t time.Time) error
func (*UdpSocksConn) SetReadDeadline ¶
func (c *UdpSocksConn) SetReadDeadline(t time.Time) error
func (*UdpSocksConn) SetRealUDP ¶
func (c *UdpSocksConn) SetRealUDP(udp net.Conn)
func (*UdpSocksConn) SetWriteDeadline ¶
func (c *UdpSocksConn) SetWriteDeadline(t time.Time) error
Click to show internal directories.
Click to hide internal directories.