{"modulePath":"github.com/dolfly/core","version":"v0.6.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package handler\n\nPackage handler defines the Handler interface for processing inbound connections — authenticating, routing, and forwarding traffic.\n\n## Types\n\n```go\ntype Forwarder interface {\n\tForward(hop.Hop)\n}\n```\nForwarder 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.\n\n```go\ntype HandleOption func(opts *HandleOptions)\n```\nHandleOption is a functional option for configuring HandleOptions.\n\n```go\nfunc MetadataHandleOption(md metadata.Metadata) HandleOption\n```\nMetadataHandleOption sets the per-connection metadata.\n\n```go\ntype HandleOptions struct {\n\t// Metadata is per-connection metadata.\n\tMetadata metadata.Metadata\n}\n```\nHandleOptions holds runtime parameters for a Handle call.\n\n```go\ntype Handler interface {\n\t// Init initializes the handler with metadata.\n\tInit(metadata.Metadata) error\n\t// Handle processes an inbound connection. The connection is closed when\n\t// Handle returns.\n\tHandle(context.Context, net.Conn, ...HandleOption) error\n}\n```\nHandler 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.\n\n```go\ntype Option func(opts *Options)\n```\nOption is a functional option for configuring Options.\n\n```go\nfunc AuthOption(auth *url.Userinfo) Option\n```\nAuthOption sets the authentication credentials.\n\n```go\nfunc AutherOption(auther auth.Authenticator) Option\n```\nAutherOption sets the Authenticator.\n\n```go\nfunc BypassOption(bypass bypass.Bypass) Option\n```\nBypassOption sets the Bypass rule.\n\n```go\nfunc CacheOption(c cache.Cache) Option\n```\nCacheOption sets the response cache.\n\n```go\nfunc LoggerOption(logger logger.Logger) Option\n```\nLoggerOption sets the logger.\n\n```go\nfunc NetnsOption(netns string) Option\n```\nNetnsOption sets the network namespace.\n\n```go\nfunc ObserverOption(observer observer.Observer) Option\n```\nObserverOption sets the Observer.\n\n```go\nfunc RateLimiterOption(limiter rate.RateLimiter) Option\n```\nRateLimiterOption sets the rate limiter.\n\n```go\nfunc RecordersOption(recorders ...recorder.RecorderObject) Option\n```\nRecordersOption sets the traffic Recorders.\n\n```go\nfunc RewriterOption(rewriter rewriter.Rewriter) Option\n```\nRewriterOption sets the Rewriter.\n\n```go\nfunc RouterOption(router chain.Router) Option\n```\nRouterOption sets the chain Router.\n\n```go\nfunc ServiceOption(service string) Option\n```\nServiceOption sets the service name.\n\n```go\nfunc TLSConfigOption(tlsConfig *tls.Config) Option\n```\nTLSConfigOption sets the TLS configuration.\n\n```go\nfunc TrafficLimiterOption(limiter traffic.TrafficLimiter) Option\n```\nTrafficLimiterOption sets the traffic limiter.\n\n```go\ntype Options struct {\n\t// Bypass determines which addresses skip the proxy chain.\n\tBypass bypass.Bypass\n\t// Router is the chain router used for upstream forwarding.\n\tRouter chain.Router\n\t// Auth is the authentication credentials.\n\tAuth *url.Userinfo\n\t// Auther is the authenticator for verifying client credentials.\n\tAuther auth.Authenticator\n\t// RateLimiter limits the rate of new connections.\n\tRateLimiter rate.RateLimiter\n\t// Limiter is the traffic (bandwidth) limiter.\n\tLimiter traffic.TrafficLimiter\n\t// TLSConfig is the TLS configuration for handler connections.\n\tTLSConfig *tls.Config\n\t// Logger is the logger for handler operations.\n\tLogger logger.Logger\n\t// Observer receives observability events.\n\tObserver observer.Observer\n\t// Recorders records traffic data.\n\tRecorders []recorder.RecorderObject\n\t// Cache is the response cache (e.g. HTTP response caching).\n\tCache cache.Cache\n\t// Rewriter rewrites traffic data.\n\tRewriter rewriter.Rewriter\n\t// Service is the service name this handler belongs to.\n\tService string\n\t// Netns is the network namespace name.\n\tNetns string\n}\n```\nOptions holds the initialization parameters for a Handler.\n\n","path":"github.com/dolfly/core/handler","name":"handler","synopsis":"Package handler defines the Handler interface for processing inbound connections — authenticating, routing, and forwarding traffic.","isRedistributable":true}
