gateway

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 23 Imported by: 0 modules, 0 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 gateway implements bounded explicit application gateways.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, cfg Config, compiled *policy.Compiled) error

Types

type Config

type Config struct {
	Protocol string
	Listen   string
	Upstream string
	// Empty permits loopback clients only, even on a wildcard listener.
	AllowedClients []netip.Prefix
	MaxConnections int
	IdleTimeout    time.Duration
	IOTimeout      time.Duration
	SessionTimeout time.Duration
	// UDP DNS responses are also limited to three times the query length.
	MaxDNSResponseBytes int
	// TLSCert/TLSKey enable implicit TLS; Postgres/MySQL use SSLRequest negotiation.
	TLSCert, TLSKey string
	// UpstreamTLS verifies the pinned destination against this name and CA pool.
	UpstreamTLS                    bool
	UpstreamServerName, UpstreamCA string
	UpstreamCert, UpstreamKey      string
	// ClientCA requires and verifies listener client certificates when set.
	ClientCA           string
	MaxMessageBytes    int
	MaxSessionMessages int
	MaxStateEntries    int
}

type Evaluator

type Evaluator interface {
	Evaluate(policy.Event) (policy.Decision, error)
}

Evaluator is implemented by policy.Compiled. Implementations must be concurrency safe.

type Gateway

type Gateway struct {
	Operations *runtimeobs.Monitor
	// contains filtered or unexported fields
}

func New

func New(cfg Config, evaluator Evaluator) (*Gateway, error)

func (*Gateway) Run

func (g *Gateway) Run(ctx context.Context) error

func (*Gateway) Serve

func (g *Gateway) Serve(ctx context.Context, l net.Listener) error

Serve owns and closes l. Cancellation closes active connections and waits for all handlers. Each client has at most one upstream connection and outstanding ADU.

func (*Gateway) ServePacket

func (g *Gateway) ServePacket(ctx context.Context, pc net.PacketConn) error

ServePacket owns pc. Single-question IN queries may carry one bounded EDNS0 OPT.

Jump to

Keyboard shortcuts

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