Documentation
¶
Overview ¶
Package netproxy is SSHYard's proxies, both ways: dialing out through an HTTP CONNECT or SOCKS5 proxy (the first hop to a host), and serving HTTP (CONNECT and plain absolute-URI requests), SOCKS4, SOCKS4a and SOCKS5 on a local port (a dynamic -D forward). It has no UI and no secrets of its own: a password is passed in by the caller.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAuth = errors.New("proxy: authentication failed")
ErrAuth reports a proxy that refused the user name and password, or that wants them and was given none.
var ErrClientLimit = errors.New("proxy: active client limit reached")
ErrClientLimit reports a rejected connection when all slots are occupied.
var ErrHandshakeTooLarge = errors.New("proxy: handshake too large")
ErrHandshakeTooLarge reports a rejected handshake exceeding its wire limit.
var ErrProtocol = errors.New("proxy: protocol not accepted")
ErrProtocol is a client speaking a protocol the server does not take.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
ID uint64
Source string
Target string
Protocol string // "socks5", "socks4", "socks4a", "http", "connect"; "" for a fixed target
Start time.Time
// contains filtered or unexported fields
}
Conn is one connection relayed by a forward or a proxy: from Source, to Target, since Start. It lives in memory only.
type Dialer ¶
type Dialer struct {
Kind Kind
Addr string // the proxy's host:port
User string
// Password is read when dialing; nil or "" is none.
Password func(ctx context.Context) (string, error)
// Forward dials the proxy itself; nil is net.Dialer.
Forward func(ctx context.Context, network, addr string) (net.Conn, error)
}
Dialer dials TCP connections through a proxy.
type Error ¶
Error is a failure of the proxy itself (reaching it, or what it said), not of what was dialed through it.
type Protocol ¶
type Protocol string
Protocol limits what a Server accepts; Auto takes them all, told apart by the first byte.
type RefusedError ¶
type RefusedError struct{ Reason string }
RefusedError is a proxy that reached itself but would not connect to the target.
func (*RefusedError) Error ¶
func (e *RefusedError) Error() string
type Registry ¶
type Registry struct {
// OnChange, when set, is called when a connection comes or goes.
OnChange func()
// contains filtered or unexported fields
}
Registry is the connections a forward relays now.
type Server ¶
type Server struct {
Protocol Protocol
// User and Password, when User is set, are required of HTTP (Basic)
// and SOCKS5 (username/password) clients; SOCKS4, which cannot carry
// a password, is then refused.
User, Password string
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
Conns *Registry
// OnError, when set, hears why a client was turned away.
OnError func(err error)
// contains filtered or unexported fields
}
Server serves a local proxy (a dynamic forward): HTTP CONNECT and plain HTTP requests with an absolute URI, SOCKS4, SOCKS4a and SOCKS5 CONNECT. Every target is dialed with Dial, so names are resolved on the far side.