Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertLoader ¶
type CertLoader interface {
GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
}
CertLoader is an interface for loading TLS certificates.
type CertManager ¶
type CertManager struct {
// contains filtered or unexported fields
}
CertManager manages TLS certificates for the proxy. It loads certificates from disk and reloads when explicitly told to via ReloadCertificates().
func NewCertManager ¶
func NewCertManager(certDir string, logger *slog.Logger) (*CertManager, error)
NewCertManager creates a new certificate manager.
func (*CertManager) CertCount ¶
func (cm *CertManager) CertCount() int
CertCount returns the number of certificates currently cached.
func (*CertManager) GetCertificate ¶
func (cm *CertManager) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificate implements the tls.Config.GetCertificate callback. It returns the certificate for the given SNI hostname.
func (*CertManager) ReloadCertificates ¶
func (cm *CertManager) ReloadCertificates() error
ReloadCertificates reloads all certificates from disk.
func (*CertManager) SetRouteTable ¶
func (cm *CertManager) SetRouteTable(config *Config)
SetRouteTable updates the routing snapshot used for alias resolution and known-host checks. Proxy.UpdateConfig calls this automatically.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is an immutable, validated routing snapshot. Build one with RouteBuilder; the zero value routes nothing.
func ConfigFromSnapshot ¶
ConfigFromSnapshot validates and converts a wire snapshot into an immutable routing Config, applying the same duplicate-domain validation as RouteBuilder. The round-robin state of each route starts fresh.
func (*Config) APIBackend ¶
APIBackend returns the control plane's API listener address and whether one is configured.
func (*Config) FindRoute ¶
FindRoute returns the route for the given host (canonical or alias), or nil.
func (*Config) IsKnownHost ¶
IsKnownHost reports whether the host is a routed domain (canonical or alias) or the API domain.
func (*Config) ResolveCanonical ¶
ResolveCanonical resolves a domain (canonical or alias) to its canonical domain.
func (*Config) RouteCount ¶
RouteCount returns the number of routes (canonical domains).
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is an HTTP reverse proxy with TLS termination and host-based routing.
func New ¶
func New(logger *slog.Logger, certLoader CertLoader) *Proxy
New creates a new Proxy instance.
func (*Proxy) Err ¶
Err returns a channel that receives fatal listener errors occurring after Start returned. A value on this channel means the proxy is no longer serving traffic and the process should exit.
func (*Proxy) Shutdown ¶
Shutdown gracefully shuts down both HTTP and HTTPS servers, then waits for active WebSocket tunnels to drain. Tunnels still open when ctx expires are force-closed.
func (*Proxy) Start ¶
Start binds the HTTP and HTTPS listeners and starts serving. A bind failure is returned immediately; errors after that are delivered on Err().
func (*Proxy) UpdateConfig ¶
UpdateConfig atomically updates the proxy configuration. If the cert loader uses routing information (alias resolution, known-host checks), the new snapshot is forwarded to it as well.
type Route ¶
type Route struct {
Canonical string
Aliases []string
Backends []Backend
// contains filtered or unexported fields
}
Route represents a domain route configuration.
type RouteBuilder ¶
type RouteBuilder struct {
// contains filtered or unexported fields
}
RouteBuilder helps build proxy routes from deployment information.
func NewRouteBuilder ¶
func NewRouteBuilder() *RouteBuilder
NewRouteBuilder creates a new route builder.
func (*RouteBuilder) AddRoute ¶
func (rb *RouteBuilder) AddRoute(canonical string, aliases []string, backends []Backend)
AddRoute adds a route for an application.
func (*RouteBuilder) Build ¶
func (rb *RouteBuilder) Build() (*Config, error)
Build validates the routes and creates the final proxy configuration with a flat host lookup index. It returns an error if a domain is used as both a canonical domain and an alias, or as an alias of multiple routes.
func (*RouteBuilder) SetAPIBackend ¶
func (rb *RouteBuilder) SetAPIBackend(ip, port string)
SetAPIBackend sets the control plane's API listener address, which the proxy forwards API-domain and localhost API traffic to.
func (*RouteBuilder) SetAPIDomain ¶
func (rb *RouteBuilder) SetAPIDomain(domain string)
SetAPIDomain sets the API domain for the configuration.