Documentation
¶
Overview ¶
Package handler defines the Handler interface for processing inbound connections — authenticating, routing, and forwarding traffic.
Index ¶
- type Forwarder
- type HandleOption
- type HandleOptions
- type Handler
- type Option
- func AuthOption(auth *url.Userinfo) Option
- func AutherOption(auther auth.Authenticator) Option
- func BypassOption(bypass bypass.Bypass) Option
- func CacheOption(c cache.Cache) Option
- func LoggerOption(logger logger.Logger) Option
- func NetnsOption(netns string) Option
- func ObserverOption(observer observer.Observer) Option
- func RateLimiterOption(limiter rate.RateLimiter) Option
- func RecordersOption(recorders ...recorder.RecorderObject) Option
- func RewriterOption(rewriter rewriter.Rewriter) Option
- func RouterOption(router chain.Router) Option
- func ServiceOption(service string) Option
- func TLSConfigOption(tlsConfig *tls.Config) Option
- func TrafficLimiterOption(limiter traffic.TrafficLimiter) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Forwarder ¶
Forwarder is an optional interface implemented by handlers that support dynamic forwarding. It allows setting or changing the forwarding hop at runtime, which is used in reverse tunnel scenarios where the target is determined after the connection is established.
type HandleOption ¶
type HandleOption func(opts *HandleOptions)
HandleOption is a functional option for configuring HandleOptions.
func MetadataHandleOption ¶
func MetadataHandleOption(md metadata.Metadata) HandleOption
MetadataHandleOption sets the per-connection metadata.
type HandleOptions ¶
HandleOptions holds runtime parameters for a Handle call.
type Handler ¶
type Handler interface {
// Init initializes the handler with metadata.
Init(metadata.Metadata) error
// Handle processes an inbound connection. The connection is closed when
// Handle returns.
Handle(context.Context, net.Conn, ...HandleOption) error
}
Handler processes an inbound connection. It authenticates the client, selects a route through the proxy chain, and forwards traffic between the client and the destination. A Handler is typically paired with a Listener to form a Service.
type Option ¶
type Option func(opts *Options)
Option is a functional option for configuring Options.
func AuthOption ¶
AuthOption sets the authentication credentials.
func AutherOption ¶
func AutherOption(auther auth.Authenticator) Option
AutherOption sets the Authenticator.
func BypassOption ¶
BypassOption sets the Bypass rule.
func CacheOption ¶ added in v0.6.1
CacheOption sets the response cache.
func NetnsOption ¶ added in v0.3.2
NetnsOption sets the network namespace.
func ObserverOption ¶
ObserverOption sets the Observer.
func RateLimiterOption ¶
func RateLimiterOption(limiter rate.RateLimiter) Option
RateLimiterOption sets the rate limiter.
func RecordersOption ¶ added in v0.3.2
func RecordersOption(recorders ...recorder.RecorderObject) Option
RecordersOption sets the traffic Recorders.
func RewriterOption ¶ added in v0.6.1
RewriterOption sets the Rewriter.
func RouterOption ¶
RouterOption sets the chain Router.
func TLSConfigOption ¶
TLSConfigOption sets the TLS configuration.
func TrafficLimiterOption ¶
func TrafficLimiterOption(limiter traffic.TrafficLimiter) Option
TrafficLimiterOption sets the traffic limiter.
type Options ¶
type Options struct {
// Bypass determines which addresses skip the proxy chain.
Bypass bypass.Bypass
// Router is the chain router used for upstream forwarding.
Router chain.Router
// Auth is the authentication credentials.
Auth *url.Userinfo
// Auther is the authenticator for verifying client credentials.
Auther auth.Authenticator
// RateLimiter limits the rate of new connections.
RateLimiter rate.RateLimiter
// Limiter is the traffic (bandwidth) limiter.
Limiter traffic.TrafficLimiter
// TLSConfig is the TLS configuration for handler connections.
TLSConfig *tls.Config
// Logger is the logger for handler operations.
Logger logger.Logger
// Observer receives observability events.
Observer observer.Observer
// Recorders records traffic data.
Recorders []recorder.RecorderObject
// Cache is the response cache (e.g. HTTP response caching).
Cache cache.Cache
// Rewriter rewrites traffic data.
Rewriter rewriter.Rewriter
// Service is the service name this handler belongs to.
Service string
// Netns is the network namespace name.
Netns string
}
Options holds the initialization parameters for a Handler.