Documentation ¶
Overview ¶
Package socks5 provides a SOCKS5 server implementation. See RFC1928 for protocol specification.
Index ¶
- Constants
- func EncodeAddressBinary(addr string) ([]byte, error)
- func EncodeHostBinary(host string) ([]byte, error)
- func EncodePortBinary(port string) ([]byte, error)
- func ReadAddress(r io.Reader) (addr string, err error)
- func ReadHost(r io.Reader) (string, error)
- func ReadPort(r io.Reader) (string, error)
- type BandwidthMessage
- type Dialer
- type Event
- type PubSub
- type Socks5
- func (s *Socks5) Associate(ctx context.Context, conn net.Conn, target string) (net.Conn, error)
- func (s *Socks5) Bind(ctx context.Context, conn net.Conn, target string) (net.Conn, error)
- func (s *Socks5) Close() error
- func (s *Socks5) Connect(ctx context.Context, conn net.Conn, target string) (net.Conn, error)
- func (s *Socks5) Handle(ctx context.Context, conn net.Conn) error
- func (s *Socks5) ListenAndServe(ctx context.Context, port int) error
- func (s *Socks5) Negotiate(conn net.Conn) error
- func (s *Socks5) Port() int
- func (s *Socks5) Proto() string
- func (s *Socks5) ProxyData(src net.Conn, dst net.Conn)
- func (s *Socks5) Run(port int) error
Constants ¶
const ( // TopicTunnelEvents is the topic where the tunnels updates are published TopicTunnelEvents = "topic_tunnel_events" // TopicNetUsage is the topic where bandwidth usage updates are published TopicNetUsage = "topic_network_usage" )
Variables ¶
This section is empty.
Functions ¶
func EncodeAddressBinary ¶
EncodeAddressBinary expects as input a canonical host:port address and returns the binary representation as speccified in the socks5 protocol (RFC1928). Booster uses the same encoding.
func EncodeHostBinary ¶
EncodeHostBinary encodes a canonical host (IPv4, IPv6, FQDN) into a byte slice. Format follows RFC1928.
func EncodePortBinary ¶
EncodePortBinary encodes a canonical port into 2 bytes. Format follows RFC1928.
func ReadAddress ¶
ReadAddress reads hostname and port and converts them into its string format, properly formatted.
r expects to read one byte that specifies the address format (1/3/4), followed by the address itself and a 16 bit port number.
addr == "" only when err != nil.
Types ¶
type BandwidthMessage ¶ added in v0.3.0
type Dialer ¶
type Dialer interface { // DialContext opens a connection to addr, which should // be a canonical address with host and port. DialContext(ctx context.Context, network, addr string) (net.Conn, error) }
Dialer is the interface that wraps the DialContext function.
type PubSub ¶
type PubSub interface { Sub(cmd *pubsub.Command) (pubsub.CancelFunc, error) Pub(message interface{}, topic string) }
PubSub describes the required functionalities of a publication/subscription object.
type Socks5 ¶
type Socks5 struct { PubSub ReadWriteTimeout time.Duration ChunkSize int64 BandwidthCheck time.Duration NextCopyDelay time.Duration DownloadIO *network.NetworkIO UploadIO *network.NetworkIO sync.Mutex Dialer // contains filtered or unexported fields }
Socks5 represents a SOCKS5 proxy server implementation.
func (*Socks5) Connect ¶
connect dials a new connection with target, which must be a canonical address with host and port.
func (*Socks5) Handle ¶
Handle performs the steps required to be SOCKS5 compliant. See RFC 1928 for details.
Should run in its own go routine, closes the connection when returning.
func (*Socks5) ListenAndServe ¶
ListenAndServe accepts and handles TCP connections using the SOCKS5 protocol.
func (*Socks5) Negotiate ¶
negotiate performs the very first method subnegotiation when handling a new connection.
func (*Socks5) Proto ¶ added in v0.3.0
Proto returns the protocol used by the proxy in string format.