socks5

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRulePermitAll

func NewRulePermitAll() socks5.RuleSet

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(listenAddr string, username, password string) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) ConnsChan

func (c *Client) ConnsChan() <-chan net.Conn

func (*Client) HandleLocalAuth added in v0.17.0

func (c *Client) HandleLocalAuth(conn net.Conn) error

HandleLocalAuth performs the SOCKS5 auth negotiation locally. It reads the version byte and offered methods, then delegates to the configured authenticator.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger() *Logger

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...interface{})

type ReadWriterConnWrapper

type ReadWriterConnWrapper struct {
	io.ReadWriteCloser
}

ReadWriterConnWrapper is used for socks5

func (ReadWriterConnWrapper) LocalAddr

func (c ReadWriterConnWrapper) LocalAddr() net.Addr

func (ReadWriterConnWrapper) RemoteAddr

func (c ReadWriterConnWrapper) RemoteAddr() net.Addr

func (ReadWriterConnWrapper) SetDeadline

func (c ReadWriterConnWrapper) SetDeadline(time.Time) error

func (ReadWriterConnWrapper) SetReadDeadline

func (c ReadWriterConnWrapper) SetReadDeadline(time.Time) error

func (ReadWriterConnWrapper) SetWriteDeadline

func (c ReadWriterConnWrapper) SetWriteDeadline(time.Time) error

type RuleDenyLocalhost

type RuleDenyLocalhost struct {
	// contains filtered or unexported fields
}

func NewRuleDenyLocalhost

func NewRuleDenyLocalhost() *RuleDenyLocalhost

func (*RuleDenyLocalhost) Allow

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(dialControl func(network, address string, c syscall.RawConn) error) *Server

NewServer constructs the SOCKS5 exit-node server. dialControl, when non-nil, is applied to every outbound connection the server opens to the real destination — it is the same socket-marking callback used for libp2p sockets (sockmark). This keeps SOCKS5 exit-node traffic going out the host's physical NIC, independent of whether this node is itself a VPN gateway client (whose 0.0.0.0/0-via-TUN default route would otherwise capture these sockets). Marking unconditionally is safe: when gateway mode is off there is no matching fwmark ip-rule, so the kernel ignores the mark — mirroring how libp2p sockets are marked at all times (see application.go). A nil dialControl yields a plain context-aware dialer.

TODO(socks5-udp): UDP ASSOCIATE is effectively unsupported today (we serve only libp2p streams via ServeConn; haxii's UDP relay starts only inside Serve(), and BindIP is a fake 127.0.0.1). If it is ever enabled, note that haxii creates its UDP sockets directly (net.ListenUDP / net.DialUDP in udp.go) — bypassing config.Dial and therefore this marking, on every platform. Those sockets would need their own dialControl-style hook, otherwise UDP relay traffic loops into the VPN gateway tunnel.

func (*Server) SendServerFailureReply

func (s *Server) SendServerFailureReply(conn io.ReadWriter) error

func (*Server) ServeConn

func (s *Server) ServeConn(ioConn io.ReadWriteCloser) error

ServeConn is only used in tests. TODO: refactor tests

func (*Server) ServeStreamConn

func (s *Server) ServeStreamConn(stream network.Stream) error

func (*Server) ServeStreamConnNoAuth added in v0.17.0

func (s *Server) ServeStreamConnNoAuth(stream network.Stream) error

func (*Server) SetRules

func (s *Server) SetRules(rule socks5.RuleSet)

SetRules is created for tests and not intended for real usage.

type StreamConnWrapper

type StreamConnWrapper struct {
	network.Stream
}

StreamConnWrapper is used for socks5

func (StreamConnWrapper) Close

func (c StreamConnWrapper) Close() error

func (StreamConnWrapper) LocalAddr

func (c StreamConnWrapper) LocalAddr() net.Addr

func (StreamConnWrapper) RemoteAddr

func (c StreamConnWrapper) RemoteAddr() net.Addr

type UpdatableRule

type UpdatableRule struct {
	// contains filtered or unexported fields
}

func NewUpdatableRule

func NewUpdatableRule(rule socks5.RuleSet) *UpdatableRule

func (*UpdatableRule) Allow

func (r *UpdatableRule) Allow(ctx context.Context, req *socks5.Request) (context.Context, bool)

func (*UpdatableRule) SetRule

func (r *UpdatableRule) SetRule(rule socks5.RuleSet)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL