tls

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: CC0-1.0 Imports: 20 Imported by: 0

Documentation

Overview

Package tls provides Network middlewares for outgoing TLS interception.

The middleware is intended for code that accepts a gonnect.Network but does not let its caller provide a tls.Config. It detects client-first TLS traffic on TCP Dial and DialTCP connections, terminates the client TLS session with a leaf certificate signed by a configured CA, and opens a new upstream TLS session through the wrapped Network with the configured client tls.Config. This lets the owner of the Network enforce root CAs, TLS versions, client certificates, and other client TLS settings while preserving the visible SNI host and ALPN offer from the original ClientHello.

The client that uses the returned connection must trust the CA supplied to this package. The CA private key must be kept private.

Only TLS ClientHello messages with a visible SNI host and no encrypted client hello signal can be intercepted. TLS traffic without visible SNI, with ECH, malformed TLS, or over the configured sniff limit is rejected. Non-TLS TCP traffic that sends client bytes first is passed through unchanged. UDP, listen operations, resolver calls, and interface calls are delegated to the wrapped Network.

Use Config.InterceptionFilter to limit which TLS connections are intercepted. Inclusive filtering intercepts only matching rules. Exclusive filtering intercepts all TLS connections except matching rules. Connections filtered out by this policy are copied unchanged through the wrapped Network, including TLS connections that have no visible SNI or that carry the ECH signal.

Server-first TCP protocols are out of scope. The bridge waits for the first client bytes before it can decide whether to intercept TLS or pass bytes through. If a caller can dial a server-first protocol through this Network, it should use connection deadlines or another timeout policy and close the connection when the timeout expires.

Deadlines set on a returned connection apply to reads and writes on that returned connection. They are not copied to the hidden upstream socket after Dial or DialTCP returns. Close the returned connection to abort hidden upstream work.

Terminator is a narrower middleware. It also terminates client TLS with a generated certificate, but it does not create a new upstream TLS connection. Instead it dials plaintext TCP through the wrapped Network. It rejects non-TLS TCP, TLS it cannot intercept, and all operations except TCP Dial and DialTCP. Use other gonnect.Network middlewares before or after Terminator for filtering, routing, and DNS policy.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoVisibleSNI is used when a TLS ClientHello does not contain a
	// visible server name. The middleware needs that name to create a leaf
	// certificate and to set the upstream tls.Config ServerName.
	ErrNoVisibleSNI = errors.New(
		"gonnect/tls: TLS connection has no visible SNI",
	)

	// ErrEncryptedClientHello is used when a ClientHello signals encrypted
	// client hello. The middleware rejects the connection because it cannot
	// see the inner SNI name.
	ErrEncryptedClientHello = errors.New(
		"gonnect/tls: TLS connection uses encrypted client hello",
	)
)
View Source
var (
	// ErrNonTLSConnection is used when Terminator receives client-first
	// bytes that are not a TLS ClientHello.
	ErrNonTLSConnection = errors.New(
		"gonnect/tls: connection is not TLS",
	)

	// ErrTerminatorUnsupported is used when a caller uses an operation that a
	// TLS terminator cannot handle. Terminator only allows outgoing TLS over
	// TCP Dial and DialTCP.
	ErrTerminatorUnsupported = errors.New(
		"gonnect/tls: terminator supports only outgoing TLS over TCP",
	)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// CA is the certificate authority used to sign generated leaf
	// certificates. It must include at least one certificate and a private key.
	CA stdtls.Certificate

	// ClientConfig configures the upstream TLS client connection. The
	// middleware clones this config for each intercepted connection and sets
	// ServerName and NextProtos from the client's ClientHello. Nil uses the Go
	// TLS defaults with ServerName and NextProtos set from the ClientHello.
	ClientConfig *stdtls.Config

	// SniffBufferSize is the maximum number of bytes inspected from the first
	// client write. Zero uses sniffer.DefaultTLSClientHelloMaxBytes. A smaller
	// value can cause large TLS ClientHello messages to be rejected.
	SniffBufferSize int

	// LeafTTL is the validity period for generated leaf certificates. Zero uses
	// a conservative default. The CA expiration still bounds the leaf
	// certificate expiration.
	LeafTTL time.Duration

	// InterceptionFilter optionally selects which TLS connections are
	// intercepted. The zero value keeps the default behavior and intercepts
	// every interceptable TLS ClientHello. Filtered-out TLS connections are
	// passed through unchanged to the wrapped Network.
	InterceptionFilter InterceptionFilter

	// Spawner optionally starts background copy workers. Nil uses normal
	// goroutines.
	Spawner gonnect.Spawner
}

Config configures a TLS MITM Network.

type InterceptionFilter

type InterceptionFilter struct {
	// Mode selects inclusive or exclusive filtering. The zero value disables
	// filtering and requires Rules to be empty.
	Mode InterceptionFilterMode

	// Rules is the list of match rules.
	Rules []InterceptionRule
}

InterceptionFilter controls which TLS connections Network intercepts.

Rules are ORed. In inclusive mode, a connection is selected for interception when any rule matches. In exclusive mode, a connection is passed through unchanged when any rule matches. A selected TLS ClientHello still must have a visible SNI host and no ECH signal before Network can intercept it.

Empty Rules are valid. They make inclusive mode pass all TLS connections through and make exclusive mode use the default interception behavior.

type InterceptionFilterMode

type InterceptionFilterMode uint8

InterceptionFilterMode selects how InterceptionFilter rules are used.

const (
	// InterceptionFilterOff disables interception filtering. This is the
	// default and keeps the historical behavior: every interceptable TLS
	// ClientHello is intercepted.
	InterceptionFilterOff InterceptionFilterMode = iota

	// InterceptionFilterInclusive intercepts only connections that match at
	// least one rule. Valid TLS connections that do not match are passed
	// through unchanged.
	InterceptionFilterInclusive

	// InterceptionFilterExclusive filters out connections that match at least
	// one rule. Other TLS connections use the default interception behavior.
	InterceptionFilterExclusive
)

type InterceptionFlag

type InterceptionFlag uint8

InterceptionFlag is a tri-state boolean matcher used by InterceptionRule.

The zero value is a wildcard. Required matches when the observed value is true. Forbidden matches when the observed value is false.

const (
	// InterceptionFlagAny accepts both true and false.
	InterceptionFlagAny InterceptionFlag = iota

	// InterceptionFlagRequired requires the observed value to be true.
	InterceptionFlagRequired

	// InterceptionFlagForbidden requires the observed value to be false.
	InterceptionFlagForbidden
)

type InterceptionRule

type InterceptionRule struct {
	Networks []string

	ConnSrcs []string
	ConnDsts []string

	SNIHosts []string
	ALPNs    []string

	SNIAvailable InterceptionFlag
	SNIEncrypted InterceptionFlag

	TLSVersions []uint16
}

InterceptionRule matches one TLS connection.

Empty field groups are wildcards. Non-empty values in one field group are ORed, and all configured field groups must match.

Networks are exact or glob patterns over the dial network string, such as "tcp", "tcp4", or "tcp*".

ConnSrcs match the requested DialTCP local address and the actual local socket address after dialing. Dial has no requested local address. ConnDsts match the requested remote address and the actual remote socket address after dialing. Source and destination patterns use the same syntax as gonnect.FilterFromString: host, host:port, IP, IP:port, CIDR, and host wildcards are supported.

SNIHosts match the visible SNI host_name. Matching is case-insensitive. ALPNs match any ALPN protocol name. Matching is case-sensitive. Both fields use whole-value glob patterns where * matches any byte sequence, ? matches one byte, and character classes use path.Match syntax.

SNIAvailable and SNIEncrypted match the visible ClientHello flags. SNIEncrypted only reports that the encrypted_client_hello extension is present. Network cannot decrypt ECH or intercept a connection that has ECH.

TLSVersions match protocol versions offered by the ClientHello. If the supported_versions extension is present, it is used. Otherwise the ClientHello legacy_version field is used.

type Network

type Network struct {
	// contains filtered or unexported fields
}

Network is a gonnect.Network middleware that MITMs outgoing TLS TCP dials.

Dial and DialTCP establish the real upstream TCP connection immediately, so dial errors are still returned by those calls. The returned connection is a local TCP-like pipe. A background worker sniffs the first client bytes. If they are interceptable TLS, the worker terminates client TLS with a generated certificate and then opens upstream TLS through the already-dialed connection. If they are non-TLS, the worker relays bytes without modification. Server-first TCP protocols are out of scope; callers should use connection deadlines or another timeout policy and close the connection on timeout.

Lifecycle calls are delegated when the wrapped Network implements the matching optional interface. If it does not, Close, Up, Down, SubscribeCloser, and SubscribeUpDown are no-ops, and IsUp reports true. IsNative always reports false because this middleware changes TCP behavior.

func NewNetwork

func NewNetwork(
	network gonnect.Network,
	ca stdtls.Certificate,
	clientConfig *stdtls.Config,
) (*Network, error)

NewNetwork wraps network with TLS MITM behavior.

func NewNetworkWithConfig

func NewNetworkWithConfig(
	network gonnect.Network,
	config Config,
) (*Network, error)

NewNetworkWithConfig wraps network with TLS MITM behavior.

func (*Network) Close

func (n *Network) Close() error

Close closes the wrapped Network when it implements io.Closer.

func (*Network) Dial

func (n *Network) Dial(
	ctx context.Context,
	network, address string,
) (net.Conn, error)

Dial intercepts TCP dials and delegates all other networks unchanged.

func (*Network) DialTCP

func (n *Network) DialTCP(
	ctx context.Context,
	network, laddr, raddr string,
) (gonnect.TCPConn, error)

DialTCP intercepts TCP dials and delegates unknown or non-TCP networks unchanged.

func (*Network) DialUDP

func (n *Network) DialUDP(
	ctx context.Context,
	network, laddr, raddr string,
) (gonnect.UDPConn, error)

DialUDP delegates to the wrapped Network.

func (*Network) Down

func (n *Network) Down() error

Down brings the wrapped Network down when it implements gonnect.UpDown.

func (*Network) GetNetwork

func (n *Network) GetNetwork() gonnect.Network

GetNetwork returns the wrapped Network.

func (*Network) GetWrapped

func (n *Network) GetWrapped() any

GetWrapped returns the wrapped Network.

func (*Network) InterfaceAddrs

func (n *Network) InterfaceAddrs() ([]net.Addr, error)

InterfaceAddrs delegates to the wrapped Network.

func (*Network) InterfaceMulticastAddrs

func (n *Network) InterfaceMulticastAddrs() ([]net.Addr, error)

InterfaceMulticastAddrs delegates to the wrapped Network.

func (*Network) Interfaces

func (n *Network) Interfaces() ([]gonnect.NetworkInterface, error)

Interfaces delegates to the wrapped Network.

func (*Network) InterfacesByIndex

func (n *Network) InterfacesByIndex(
	index int,
) ([]gonnect.NetworkInterface, error)

InterfacesByIndex delegates to the wrapped Network.

func (*Network) InterfacesByName

func (n *Network) InterfacesByName(
	name string,
) ([]gonnect.NetworkInterface, error)

InterfacesByName delegates to the wrapped Network.

func (*Network) IsNative

func (n *Network) IsNative() bool

IsNative always reports false because the middleware changes TCP behavior.

func (*Network) IsUp

func (n *Network) IsUp() (bool, error)

IsUp reports the wrapped Network state when it implements gonnect.UpDown.

func (*Network) Listen

func (n *Network) Listen(
	ctx context.Context,
	network, address string,
) (net.Listener, error)

Listen delegates to the wrapped Network.

func (*Network) ListenMulticastUDP

func (n *Network) ListenMulticastUDP(
	ctx context.Context,
	network, address string,
	opts gonnect.MulticastOptions,
) (gonnect.MulticastPacketConn, error)

ListenMulticastUDP delegates to the wrapped Network.

func (*Network) ListenPacket

func (n *Network) ListenPacket(
	ctx context.Context,
	network, address string,
) (gonnect.PacketConn, error)

ListenPacket delegates to the wrapped Network.

func (*Network) ListenPacketConfig

func (n *Network) ListenPacketConfig(
	ctx context.Context,
	lc *gonnect.ListenConfig,
	network, address string,
) (gonnect.PacketConn, error)

ListenPacketConfig delegates to the wrapped Network.

func (*Network) ListenTCP

func (n *Network) ListenTCP(
	ctx context.Context,
	network, laddr string,
) (gonnect.TCPListener, error)

ListenTCP delegates to the wrapped Network.

func (*Network) ListenUDP

func (n *Network) ListenUDP(
	ctx context.Context,
	network, laddr string,
) (gonnect.UDPConn, error)

ListenUDP delegates to the wrapped Network.

func (*Network) ListenUDPConfig

func (n *Network) ListenUDPConfig(
	ctx context.Context,
	lc *gonnect.ListenConfig,
	network, laddr string,
) (gonnect.UDPConn, error)

ListenUDPConfig delegates to the wrapped Network.

func (*Network) LookupAddr

func (n *Network) LookupAddr(
	ctx context.Context,
	addr string,
) ([]string, error)

LookupAddr delegates to the wrapped Network.

func (*Network) LookupCNAME

func (n *Network) LookupCNAME(
	ctx context.Context,
	host string,
) (string, error)

LookupCNAME delegates to the wrapped Network.

func (*Network) LookupHost

func (n *Network) LookupHost(
	ctx context.Context,
	host string,
) ([]string, error)

LookupHost delegates to the wrapped Network.

func (*Network) LookupIP

func (n *Network) LookupIP(
	ctx context.Context,
	network, address string,
) ([]net.IP, error)

LookupIP delegates to the wrapped Network.

func (*Network) LookupIPAddr

func (n *Network) LookupIPAddr(
	ctx context.Context,
	host string,
) ([]net.IPAddr, error)

LookupIPAddr delegates to the wrapped Network.

func (*Network) LookupMX

func (n *Network) LookupMX(
	ctx context.Context,
	name string,
) ([]*net.MX, error)

LookupMX delegates to the wrapped Network.

func (*Network) LookupNS

func (n *Network) LookupNS(
	ctx context.Context,
	name string,
) ([]*net.NS, error)

LookupNS delegates to the wrapped Network.

func (*Network) LookupNetIP

func (n *Network) LookupNetIP(
	ctx context.Context,
	network, host string,
) ([]netip.Addr, error)

LookupNetIP delegates to the wrapped Network.

func (*Network) LookupPort

func (n *Network) LookupPort(
	ctx context.Context,
	network, service string,
) (int, error)

LookupPort delegates to the wrapped Network.

func (*Network) LookupSRV

func (n *Network) LookupSRV(
	ctx context.Context,
	service, proto, name string,
) (string, []*net.SRV, error)

LookupSRV delegates to the wrapped Network.

func (*Network) LookupTXT

func (n *Network) LookupTXT(
	ctx context.Context,
	name string,
) ([]string, error)

LookupTXT delegates to the wrapped Network.

func (*Network) PacketDial

func (n *Network) PacketDial(
	ctx context.Context,
	network, address string,
) (gonnect.PacketConn, error)

PacketDial delegates to the wrapped Network.

func (*Network) SubscribeCloser

func (n *Network) SubscribeCloser(c io.Closer) (func(), error)

SubscribeCloser delegates to the wrapped Network when supported.

func (*Network) SubscribeUpDown

func (n *Network) SubscribeUpDown(u gonnect.UpDown) (func(), error)

SubscribeUpDown delegates to the wrapped Network when supported.

func (*Network) Up

func (n *Network) Up() error

Up brings the wrapped Network up when it implements gonnect.UpDown.

type Terminator

type Terminator struct {
	// contains filtered or unexported fields
}

Terminator is a gonnect.Network middleware that terminates outgoing TLS over TCP and sends plaintext TCP to the wrapped Network.

Dial and DialTCP return a local TCP-like pipe immediately. A background worker waits for the first client bytes, requires a valid TLS ClientHello with visible SNI and no ECH signal, selects the upstream plaintext destination, dials it through the wrapped Network, completes client-facing TLS with a generated certificate, and then copies decrypted bytes to the upstream TCP connection.

Non-TLS TCP is rejected. TLS without visible SNI, TLS with ECH, malformed TLS, and TLS over the sniff limit are rejected. No rejected stream is passed through or dialed upstream. Operations other than TCP Dial and DialTCP return ErrTerminatorUnsupported and do not call the wrapped Network.

The Dial or DialTCP context is checked before the local pipe is returned. After Dial or DialTCP returns, canceling that context does not stop the background worker. Close the returned connection to abort sniffing, hidden upstream dials, and bridge work.

Lifecycle calls are delegated when the wrapped Network implements the matching optional interface. If it does not, Close, Up, Down, SubscribeCloser, and SubscribeUpDown are no-ops, and IsUp reports true. IsNative always reports false because this middleware changes TCP behavior.

func NewTerminator

func NewTerminator(
	network gonnect.Network,
	ca stdtls.Certificate,
) (*Terminator, error)

NewTerminator wraps network with TLS termination behavior.

func NewTerminatorWithConfig

func NewTerminatorWithConfig(
	network gonnect.Network,
	config TerminatorConfig,
) (*Terminator, error)

NewTerminatorWithConfig wraps network with TLS termination behavior.

func (*Terminator) Close

func (n *Terminator) Close() error

Close closes the wrapped Network when it implements io.Closer.

func (*Terminator) Dial

func (n *Terminator) Dial(
	ctx context.Context,
	network, address string,
) (net.Conn, error)

Dial accepts only TCP networks and terminates client TLS before upstream.

func (*Terminator) DialTCP

func (n *Terminator) DialTCP(
	ctx context.Context,
	network, laddr, raddr string,
) (gonnect.TCPConn, error)

DialTCP accepts only TCP networks and terminates client TLS before upstream.

func (*Terminator) DialUDP

func (n *Terminator) DialUDP(
	ctx context.Context,
	network, laddr, raddr string,
) (gonnect.UDPConn, error)

DialUDP is not supported by Terminator.

func (*Terminator) Down

func (n *Terminator) Down() error

Down brings the wrapped Network down when it implements gonnect.UpDown.

func (*Terminator) GetNetwork

func (n *Terminator) GetNetwork() gonnect.Network

GetNetwork returns the wrapped Network.

func (*Terminator) GetWrapped

func (n *Terminator) GetWrapped() any

GetWrapped returns the wrapped Network.

func (*Terminator) InterfaceAddrs

func (n *Terminator) InterfaceAddrs() ([]net.Addr, error)

InterfaceAddrs is not supported by Terminator.

func (*Terminator) InterfaceMulticastAddrs

func (n *Terminator) InterfaceMulticastAddrs() ([]net.Addr, error)

InterfaceMulticastAddrs is not supported by Terminator.

func (*Terminator) Interfaces

func (n *Terminator) Interfaces() ([]gonnect.NetworkInterface, error)

Interfaces is not supported by Terminator.

func (*Terminator) InterfacesByIndex

func (n *Terminator) InterfacesByIndex(
	index int,
) ([]gonnect.NetworkInterface, error)

InterfacesByIndex is not supported by Terminator.

func (*Terminator) InterfacesByName

func (n *Terminator) InterfacesByName(
	name string,
) ([]gonnect.NetworkInterface, error)

InterfacesByName is not supported by Terminator.

func (*Terminator) IsNative

func (n *Terminator) IsNative() bool

IsNative always reports false because the middleware changes TCP behavior.

func (*Terminator) IsUp

func (n *Terminator) IsUp() (bool, error)

IsUp reports the wrapped Network state when it implements gonnect.UpDown.

func (*Terminator) Listen

func (n *Terminator) Listen(
	ctx context.Context,
	network, address string,
) (net.Listener, error)

Listen is not supported by Terminator.

func (*Terminator) ListenMulticastUDP

func (n *Terminator) ListenMulticastUDP(
	ctx context.Context,
	network, address string,
	opts gonnect.MulticastOptions,
) (gonnect.MulticastPacketConn, error)

ListenMulticastUDP is not supported by Terminator.

func (*Terminator) ListenPacket

func (n *Terminator) ListenPacket(
	ctx context.Context,
	network, address string,
) (gonnect.PacketConn, error)

ListenPacket is not supported by Terminator.

func (*Terminator) ListenPacketConfig

func (n *Terminator) ListenPacketConfig(
	ctx context.Context,
	lc *gonnect.ListenConfig,
	network, address string,
) (gonnect.PacketConn, error)

ListenPacketConfig is not supported by Terminator.

func (*Terminator) ListenTCP

func (n *Terminator) ListenTCP(
	ctx context.Context,
	network, laddr string,
) (gonnect.TCPListener, error)

ListenTCP is not supported by Terminator.

func (*Terminator) ListenUDP

func (n *Terminator) ListenUDP(
	ctx context.Context,
	network, laddr string,
) (gonnect.UDPConn, error)

ListenUDP is not supported by Terminator.

func (*Terminator) ListenUDPConfig

func (n *Terminator) ListenUDPConfig(
	ctx context.Context,
	lc *gonnect.ListenConfig,
	network, laddr string,
) (gonnect.UDPConn, error)

ListenUDPConfig is not supported by Terminator.

func (*Terminator) LookupAddr

func (n *Terminator) LookupAddr(
	ctx context.Context,
	addr string,
) ([]string, error)

LookupAddr is not supported by Terminator.

func (*Terminator) LookupCNAME

func (n *Terminator) LookupCNAME(
	ctx context.Context,
	host string,
) (string, error)

LookupCNAME is not supported by Terminator.

func (*Terminator) LookupHost

func (n *Terminator) LookupHost(
	ctx context.Context,
	host string,
) ([]string, error)

LookupHost is not supported by Terminator.

func (*Terminator) LookupIP

func (n *Terminator) LookupIP(
	ctx context.Context,
	network, address string,
) ([]net.IP, error)

LookupIP is not supported by Terminator.

func (*Terminator) LookupIPAddr

func (n *Terminator) LookupIPAddr(
	ctx context.Context,
	host string,
) ([]net.IPAddr, error)

LookupIPAddr is not supported by Terminator.

func (*Terminator) LookupMX

func (n *Terminator) LookupMX(
	ctx context.Context,
	name string,
) ([]*net.MX, error)

LookupMX is not supported by Terminator.

func (*Terminator) LookupNS

func (n *Terminator) LookupNS(
	ctx context.Context,
	name string,
) ([]*net.NS, error)

LookupNS is not supported by Terminator.

func (*Terminator) LookupNetIP

func (n *Terminator) LookupNetIP(
	ctx context.Context,
	network, host string,
) ([]netip.Addr, error)

LookupNetIP is not supported by Terminator.

func (*Terminator) LookupPort

func (n *Terminator) LookupPort(
	ctx context.Context,
	network, service string,
) (int, error)

LookupPort is not supported by Terminator.

func (*Terminator) LookupSRV

func (n *Terminator) LookupSRV(
	ctx context.Context,
	service, proto, name string,
) (string, []*net.SRV, error)

LookupSRV is not supported by Terminator.

func (*Terminator) LookupTXT

func (n *Terminator) LookupTXT(
	ctx context.Context,
	name string,
) ([]string, error)

LookupTXT is not supported by Terminator.

func (*Terminator) PacketDial

func (n *Terminator) PacketDial(
	ctx context.Context,
	network, address string,
) (gonnect.PacketConn, error)

PacketDial is not supported by Terminator.

func (*Terminator) SubscribeCloser

func (n *Terminator) SubscribeCloser(c io.Closer) (func(), error)

SubscribeCloser delegates to the wrapped Network when supported.

func (*Terminator) SubscribeUpDown

func (n *Terminator) SubscribeUpDown(u gonnect.UpDown) (func(), error)

SubscribeUpDown delegates to the wrapped Network when supported.

func (*Terminator) Up

func (n *Terminator) Up() error

Up brings the wrapped Network up when it implements gonnect.UpDown.

type TerminatorConfig

type TerminatorConfig struct {
	// CA is the certificate authority used to sign generated leaf
	// certificates. It must include at least one certificate and a private key.
	CA stdtls.Certificate

	// SniffBufferSize is the maximum number of bytes inspected from the first
	// client write. Zero uses sniffer.DefaultTLSClientHelloMaxBytes. A smaller
	// value can cause large TLS ClientHello messages to be rejected.
	SniffBufferSize int

	// LeafTTL is the validity period for generated leaf certificates. Zero uses
	// a conservative default. The CA expiration still bounds the leaf
	// certificate expiration.
	LeafTTL time.Duration

	// DestinationRemaps optionally replace the upstream plaintext TCP
	// destination. Rules are checked in order, and the first match wins. When
	// no rule matches, Terminator uses the original dial destination unless
	// UseSNIHostname is true.
	DestinationRemaps []TerminatorDestinationRemap

	// UseSNIHostname makes the default upstream destination use the SNI host
	// with the original destination port. It is ignored when a destination
	// remap matches. The zero value keeps the original destination.
	UseSNIHostname bool

	// NextProtos is the list of ALPN protocols the client-facing TLS server
	// can select. Empty disables ALPN selection. Remap rules still match the
	// ALPN protocols offered by the client.
	NextProtos []string

	// Spawner optionally starts background copy workers. Nil uses normal
	// goroutines.
	Spawner gonnect.Spawner
}

TerminatorConfig configures a TLS terminating Network.

type TerminatorDestinationRemap

type TerminatorDestinationRemap struct {
	// OriginalDsts match the original Dial or DialTCP remote address.
	OriginalDsts []string

	// SNIHosts match the visible SNI host_name.
	SNIHosts []string

	// ALPNs match any ALPN protocol offered by the client.
	ALPNs []string

	// Dst is the plaintext TCP destination used when this rule matches. It
	// must use host:port syntax.
	Dst string
}

TerminatorDestinationRemap maps intercepted TLS connections to another plaintext TCP destination.

Empty match fields are wildcards. Values in one field are ORed. Different fields are ANDed. OriginalDsts use the address syntax accepted by gonnect.FilterFromString. SNIHosts and ALPNs use whole-value glob patterns, where * matches any byte sequence and ? matches one byte. SNIHosts match case-insensitively. ALPNs match the client offer, not the selected ALPN.

Jump to

Keyboard shortcuts

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