Documentation
¶
Index ¶
- func SendReply(w io.Writer, rep uint8, bindAddr net.Addr) error
- type ConnState
- type GPool
- type Logger
- type Option
- func WithAssociateHandle(h func(ctx context.Context, writer io.Writer, req *handler.Request) error) Option
- func WithAssociateMiddleware(m handler.Middleware) Option
- func WithAuthMethods(authMethods []auth.Authenticator) Option
- func WithBaseContext(fn func(net.Listener) context.Context) Option
- func WithBindAcceptTimeout(d time.Duration) Option
- func WithBindHandle(h func(ctx context.Context, writer io.Writer, req *handler.Request) error) Option
- func WithBindIP(ip net.IP) Option
- func WithBindMiddleware(m handler.Middleware) Option
- func WithBindPeerCheckIPOnly(b bool) Option
- func WithBufferPool(pool buffer.BufPool) Option
- func WithConnContext(fn func(ctx context.Context, conn net.Conn) context.Context) Option
- func WithConnMetadata(fn func(net.Conn) map[string]string) Option
- func WithConnState(fn func(net.Conn, ConnState)) Option
- func WithConnectHandle(h func(ctx context.Context, writer io.Writer, req *handler.Request) error) Option
- func WithConnectMiddleware(m handler.Middleware) Option
- func WithConnectionLogging(enabled bool) Option
- func WithCredential(cs auth.CredentialStore) Option
- func WithDial(dial func(ctx context.Context, network, addr string) (net.Conn, error)) Option
- func WithDialAndRequest(...) Option
- func WithDialer(d net.Dialer) Option
- func WithGPool(pool GPool) Option
- func WithHandshakeTimeout(d time.Duration) Option
- func WithLinkQuality(tr *linkquality.Tracker) Option
- func WithLogger(l Logger) Option
- func WithResolver(res resolver.NameResolver) Option
- func WithRewriter(rew handler.AddressRewriter) Option
- func WithRule(rule rules.RuleSet) Option
- func WithTCPKeepAlive(period time.Duration) Option
- func WithUDPAssociateLimits(maxPeers int, idleTimeout time.Duration) Option
- func WithUseBindIpBaseResolveAsUdpAddr(b bool) Option
- type Server
- func (sf *Server) LinkQualityTracker() *linkquality.Tracker
- func (sf *Server) ListenAndServe(network, addr string) error
- func (sf *Server) ListenAndServeTLS(network, addr string, c *tls.Config) error
- func (sf *Server) Proxy(dst io.Writer, src io.Reader) error
- func (sf *Server) Serve(l net.Listener) error
- func (sf *Server) ServeConn(conn net.Conn) error
- func (sf *Server) ServeConnContext(ctx context.Context, conn net.Conn) error
- func (sf *Server) ServeContext(ctx context.Context, l net.Listener) error
- type Std
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(s *Server)
func WithAssociateHandle ¶
func WithAssociateHandle(h func(ctx context.Context, writer io.Writer, req *handler.Request) error) Option
WithAssociateHandle replaces the default UDP ASSOCIATE handler.
func WithAssociateMiddleware ¶
func WithAssociateMiddleware(m handler.Middleware) Option
WithAssociateMiddleware appends middleware executed before the UDP ASSOCIATE handler.
func WithAuthMethods ¶
func WithAuthMethods(authMethods []auth.Authenticator) Option
WithAuthMethods appends custom authenticators to the method negotiation list.
func WithBaseContext ¶ added in v0.3.2
WithBaseContext installs a base context factory that is invoked once per listener. ServeContext derives each connection context from the returned value.
func WithBindAcceptTimeout ¶
WithBindAcceptTimeout sets how long the server waits for the peer during BIND.
func WithBindHandle ¶
func WithBindHandle(h func(ctx context.Context, writer io.Writer, req *handler.Request) error) Option
WithBindHandle replaces the default BIND handler.
func WithBindIP ¶
WithBindIP sets the bind address used for BIND/UDP sockets.
func WithBindMiddleware ¶
func WithBindMiddleware(m handler.Middleware) Option
WithBindMiddleware appends middleware executed before the BIND handler.
func WithBindPeerCheckIPOnly ¶
WithBindPeerCheckIPOnly switches peer validation to IP-only (ignoring port).
func WithBufferPool ¶
WithBufferPool sets the buffer pool used by the proxy I/O fast-paths.
func WithConnContext ¶ added in v0.3.2
WithConnContext decorates the per-connection context before handlers and dialers run. The provided ctx is derived from ServeContext; return nil to keep the original value.
func WithConnMetadata ¶ added in v0.3.2
WithConnMetadata installs a callback used to attach static metadata to handler.Request.Metadata. The returned map is shallow-copied per connection.
func WithConnState ¶ added in v0.3.2
WithConnState registers a hook that receives connection lifecycle transitions (StateNew, StateActive, StateClosed).
func WithConnectHandle ¶
func WithConnectHandle(h func(ctx context.Context, writer io.Writer, req *handler.Request) error) Option
WithConnectHandle replaces the default CONNECT handler.
func WithConnectMiddleware ¶
func WithConnectMiddleware(m handler.Middleware) Option
WithConnectMiddleware appends middleware executed before the CONNECT handler.
func WithConnectionLogging ¶ added in v0.4.1
WithConnectionLogging enables or disables per-connection accept/close logs.
func WithCredential ¶
func WithCredential(cs auth.CredentialStore) Option
WithCredential provides a credential store used by the default user/pass authenticator.
func WithDialAndRequest ¶
func WithDialAndRequest(dial func(ctx context.Context, network, addr string, req *handler.Request) (net.Conn, error)) Option
WithDialAndRequest is like WithDial but also exposes the parsed request.
func WithDialer ¶
WithDialer sets a custom net.Dialer for outbound connections when a custom dial is not provided.
func WithHandshakeTimeout ¶
WithHandshakeTimeout sets a deadline for initial negotiation and request parsing. Zero disables the handshake deadline.
func WithLinkQuality ¶ added in v0.4.1
func WithLinkQuality(tr *linkquality.Tracker) Option
WithLinkQuality enables link quality tracking for outbound hops.
func WithLogger ¶
WithLogger replaces the server logger implementation.
func WithResolver ¶
func WithResolver(res resolver.NameResolver) Option
WithResolver overrides the DNS resolver used for FQDN targets.
func WithRewriter ¶
func WithRewriter(rew handler.AddressRewriter) Option
WithRewriter installs an address rewriter that can mutate the destination before dialing.
func WithTCPKeepAlive ¶
WithTCPKeepAlive enables TCP keepalives on accepted connections with the given period. Zero disables keepalives.
func WithUDPAssociateLimits ¶
WithUDPAssociateLimits configures UDP ASSOCIATE peer limits and idle cleanup. If maxPeers <= 0, unlimited peers are allowed. If idleTimeout <= 0, peers are not GC'd by idle.
func WithUseBindIpBaseResolveAsUdpAddr ¶
WithUseBindIpBaseResolveAsUdpAddr forces UDP ASSOCIATE replies to advertise the bind IP.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) LinkQualityTracker ¶ added in v0.4.1
func (sf *Server) LinkQualityTracker() *linkquality.Tracker
LinkQualityTracker returns the tracker used for outbound hops, if enabled.
func (*Server) ListenAndServe ¶
func (*Server) ListenAndServeTLS ¶
func (*Server) Proxy ¶
Proxy copies data from src to dst. It prefers optimized io.Copy paths (ReaderFrom/WriterTo) and uses the shared buffer pool for the generic copy case to avoid per-call allocations.
func (*Server) ServeConnContext ¶ added in v0.3.2
ServeConnContext is like ServeConn but binds the provided context to the connection lifecycle.