handler

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 16 Imported by: 1 module, 29 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package handler defines the Handler interface for processing inbound connections — authenticating, routing, and forwarding traffic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Forwarder

type Forwarder interface {
	Forward(hop.Hop)
}

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

type HandleOptions struct {
	// Metadata is per-connection metadata.
	Metadata metadata.Metadata
}

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

func AuthOption(auth *url.Userinfo) Option

AuthOption sets the authentication credentials.

func AutherOption

func AutherOption(auther auth.Authenticator) Option

AutherOption sets the Authenticator.

func BypassOption

func BypassOption(bypass bypass.Bypass) Option

BypassOption sets the Bypass rule.

func CacheOption added in v0.6.1

func CacheOption(c cache.Cache) Option

CacheOption sets the response cache.

func LoggerOption

func LoggerOption(logger logger.Logger) Option

LoggerOption sets the logger.

func NetnsOption added in v0.3.2

func NetnsOption(netns string) Option

NetnsOption sets the network namespace.

func ObserverOption

func ObserverOption(observer observer.Observer) Option

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

func RewriterOption(rewriter rewriter.Rewriter) Option

RewriterOption sets the Rewriter.

func RouterOption

func RouterOption(router chain.Router) Option

RouterOption sets the chain Router.

func ServiceOption

func ServiceOption(service string) Option

ServiceOption sets the service name.

func TLSConfigOption

func TLSConfigOption(tlsConfig *tls.Config) Option

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.

Jump to

Keyboard shortcuts

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