parsing

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 18 Imported by: ? 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 parsing converts user-facing configuration structs into registered runtime components. Each sub-package (service, hop, chain, auth, …) owns the parsing logic for its corresponding core interface.

Metadata keys defined below bridge the gap between named config fields and generic key-value metadata. When a value is not represented by an explicit field on a config struct it flows through the metadata system instead and these keys are used to look it up at component Init time.

Index

Constants

View Source
const (
	// MDKeyProxyProtocol sets the HAProxy proxy-protocol version on a listener.
	MDKeyProxyProtocol = "proxyProtocol"

	// MDKeyInterface binds the outbound connection to a specific network interface.
	MDKeyInterface = "interface"

	// MDKeySoMark sets the SO_MARK socket option on outbound connections.
	MDKeySoMark = "so_mark"

	// MDKeyHash selects the hash source used by hash-based selectors.
	MDKeyHash = "hash"

	// MDKeyPreUp is a shell command executed when a service starts listening.
	MDKeyPreUp = "preUp"

	// MDKeyPreDown is a shell command executed immediately before a service
	// stops listening.
	MDKeyPreDown = "preDown"

	// MDKeyPostUp is a shell command executed after a service has successfully
	// started listening.
	MDKeyPostUp = "postUp"

	// MDKeyPostDown is a shell command executed after a service has stopped
	// listening.
	MDKeyPostDown = "postDown"

	// MDKeyIgnoreChain disables chain routing for a service. When set the
	// listener/handler will not prepend a chain, which is useful for services
	// that handle routing themselves (e.g. DNS, TUN).
	MDKeyIgnoreChain = "ignoreChain"

	// MDKeyEnableStats enables per-service connection statistics collection.
	MDKeyEnableStats = "enableStats"

	// MDKeyRecorderDirection toggles whether traffic direction (client→server or
	// server→client) is recorded alongside the payload.
	MDKeyRecorderDirection = "direction"

	// MDKeyRecorderTimestampFormat sets the timestamp layout used in recorder
	// output (Go time.Format layout).
	MDKeyRecorderTimestampFormat = "timeStampFormat"

	// MDKeyRecorderHexdump enables hexadecimal dump output in recorders.
	MDKeyRecorderHexdump = "hexdump"

	// MDKeyRecorderHTTPBody enables capturing the HTTP request/response body in
	// HTTP-based recorders.
	MDKeyRecorderHTTPBody = "http.body"

	// MDKeyRecorderHTTPMaxBodySize limits the maximum body size (in bytes) that
	// an HTTP recorder will capture.
	MDKeyRecorderHTTPMaxBodySize = "http.maxBodySize"

	// MDKeyLimiterRefreshInterval sets how often a limiter reloads its
	// configuration from an external source.
	MDKeyLimiterRefreshInterval = "limiter.refreshInterval"

	// MDKeyLimiterCleanupInterval sets how often a limiter purges expired
	// entries from its internal state.
	MDKeyLimiterCleanupInterval = "limiter.cleanupInterval"

	// MDKeyLimiterScope controls whether a cached traffic limiter's scope is
	// per-service ("service") or per-client ("client").
	MDKeyLimiterScope = "limiter.scope"

	// MDKeyObserverResetTraffic requests a traffic counter reset each time the
	// observer reports.
	MDKeyObserverResetTraffic = "observer.resetTraffic"

	// MDKeyObserverPeriod sets the interval between observer reports.
	MDKeyObserverPeriod = "observer.period"

	// MDKeyNetns is the network namespace name or path used for the listener
	// side (inbound).
	MDKeyNetns = "netns"

	// MDKeyNetnsOut is the network namespace name or path used for the handler
	// (outbound) side.
	MDKeyNetnsOut = "netns.out"

	// MDKeyDialTimeout sets the dial timeout for outbound connections.
	MDKeyDialTimeout = "dialTimeout"

	// MDKeyLabels holds static key/value labels attached to a service's
	// records and logs.
	MDKeyLabels = "labels"

	// MDKeyP2P selects the p2p tunnel provider for a chain node's base
	// transport. The value is the name of a registered p2ps: component.
	MDKeyP2P = "p2p"

	// MDKeyP2PNetwork overrides the tunnel network a p2p-wrapped node asks the
	// provider for (see xp2p.WithTunnelNetwork). Empty derives it from the inner
	// dialer. A tun link sets it to "ip": datagram-shaped like udp, but
	// session-scoped on the host, so the link ends on a lost peer session.
	MDKeyP2PNetwork = "p2p.network"
)

Variables

This section is empty.

Functions

func BuildDefaultTLSConfig

func BuildDefaultTLSConfig(cfg *config.TLSConfig) (*tls.Config, error)

BuildDefaultTLSConfig loads or generates the default TLS certificate and key from the given config.

When explicit certificate files are configured (CertFile, KeyFile, or CAFile is non-empty) it loads them via tls_util.LoadDefaultConfig — the original behaviour preserved for backward compatibility.

When no certificate files are configured (all three empty), it tries sources in this order:

  1. cert.pem / key.pem in the current working directory (backward compatible)
  2. auto-ca-cert.pem / auto-ca-key.pem under $HOME/.tnet/ (persisted)
  3. If none found, generates a new ECDSA P-256 CA certificate, persists it to $HOME/.tnet/, and uses it.

If cfg is nil an empty TLSConfig is used (equivalent to no explicit files), so the CWD → persisted → generate path is taken.

func DefaultTLSConfig

func DefaultTLSConfig() *tls.Config

DefaultTLSConfig returns the global default TLS configuration used as a fallback when a listener or handler does not specify its own TLS settings. The returned config is a shared instance; callers that need to mutate it should clone it first.

func SetDefaultTLSConfig added in v0.0.3

func SetDefaultTLSConfig(cfg *tls.Config)

SetDefaultTLSConfig replaces the global default TLS configuration. It is safe to call from multiple goroutines.

Types

This section is empty.

Directories

Path Synopsis
Package p2p converts a config.P2PConfig into a p2p.Tunnel.
Package p2p converts a config.P2PConfig into a p2p.Tunnel.

Jump to

Keyboard shortcuts

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