object

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 41 Imported by: 0

Documentation

Overview

Package object implements the STUNner dataplane objects (Admin, Auth, Filter, Cluster, Server, Listener, Health, Metrics, Offload) and the declarative object hierarchy (the catalog).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdmin

func NewAdmin(conf stnrv2.Config, rt *runtime.Runtime) (runtime.Object, error)

NewAdmin creates an Admin object.

func NewAuth

func NewAuth(conf stnrv2.Config) (runtime.Object, error)

NewAuth creates an authentication policy object.

func NewCluster

func NewCluster(conf stnrv2.Config, rt *runtime.Runtime) (runtime.Object, error)

NewCluster creates a cluster object.

func NewFilter

func NewFilter(conf stnrv2.Config) (runtime.Object, error)

NewFilter creates a filter object.

func NewHealth

func NewHealth(conf stnrv2.Config, rt *runtime.Runtime) (runtime.Object, error)

NewHealth creates a Health object.

func NewMetrics

func NewMetrics(conf stnrv2.Config, rt *runtime.Runtime) (runtime.Object, error)

NewMetrics creates a Metrics object.

func NewOffload

func NewOffload(conf stnrv2.Config, rt *runtime.Runtime) (runtime.Object, error)

NewOffload creates an Offload object.

func NewServer

func NewServer(conf stnrv2.Config, rt *runtime.Runtime) (runtime.Object, error)

NewServer creates the server object of the type a config names.

func NewStunner

func NewStunner(_ stnrv2.Config, rt *runtime.Runtime) (runtime.Object, error)

NewStunner creates the singleton root object.

Types

type Admin

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

Admin holds the bits of STUNner administration that aren't carved out into Health/Metrics/Offload: Name/LogLevel/UserQuota/License.

func (*Admin) Close

func (a *Admin) Close(_ bool) error

func (*Admin) GetConfig

func (a *Admin) GetConfig() stnrv2.Config

GetConfig returns the full AdminConfig, combining the admin's own snapshot with the Health/Metrics/Offload pieces pulled from the live children. Safe for concurrent use.

func (*Admin) Inspect

func (a *Admin) Inspect(old, new stnrv2.Config, _ *stnrv2.StunnerConfig) (runtime.Action, error)

func (*Admin) LogLevel

func (a *Admin) LogLevel() string

LogLevel returns the configured log level. Safe for concurrent use.

func (*Admin) Name

func (a *Admin) Name() string

func (*Admin) Reconcile

func (a *Admin) Reconcile(conf stnrv2.Config) error

func (*Admin) Start

func (a *Admin) Start() error

func (*Admin) Status

func (a *Admin) Status() stnrv2.Status

func (*Admin) Type

func (a *Admin) Type() runtime.ObjectType

type Auth

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

Auth is an authentication policy. The servers referring to it read its live config per request through rt.AuthConfig, which loads the snapshot Reconcile publishes.

func (*Auth) Close

func (a *Auth) Close(_ bool) error

func (*Auth) GetConfig

func (a *Auth) GetConfig() stnrv2.Config

GetConfig returns a copy of the live config. Safe for concurrent use.

func (*Auth) Inspect

func (a *Auth) Inspect(old, new stnrv2.Config, _ *stnrv2.StunnerConfig) (runtime.Action, error)

Inspect reconciles every change in place.

func (*Auth) Name

func (a *Auth) Name() string

func (*Auth) Reconcile

func (a *Auth) Reconcile(conf stnrv2.Config) error

func (*Auth) Start

func (a *Auth) Start() error

func (*Auth) Status

func (a *Auth) Status() stnrv2.Status

func (*Auth) Type

func (a *Auth) Type() runtime.ObjectType

type Catalog

type Catalog = reconciler.Catalog

func NewCatalog

func NewCatalog() *Catalog

NewCatalog builds the default object catalog:

Stunner (root, singleton)
+-- Admin -- Health / Metrics / Offload    (singletons)
+-- Auth [N from config]
+-- Filter [N from config]
+-- Cluster [N from config]
+-- Server [N from config]
+-- Listener [N from config]

The dataplane objects reference each other by name only, resolved through the runtime when a conn needs them, so each reconciles on its own: no object holds another, and none is restarted because another one is. Siblings start in this order, so the listeners, which hand conns to servers, come up last.

type Cluster

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

Cluster is a cluster object: the router over its endpoints and the dialer that reaches them. Reconcile writes the fields under mu, the data path reads them.

func (*Cluster) Close

func (c *Cluster) Close(shutdown bool) error

Close unregisters the domains and stops the dialer. Dialed conns stay up.

func (*Cluster) Dial

func (c *Cluster) Dial(ctx context.Context, local net.Addr, addr string) (api.Conn, error)

func (*Cluster) GetConfig

func (c *Cluster) GetConfig() stnrv2.Config

func (*Cluster) Inspect

func (c *Cluster) Inspect(old, new stnrv2.Config, full *stnrv2.StunnerConfig) (runtime.Action, error)

Inspect reconciles every change in place: a dialer change swaps the dialer, live conns keep theirs.

func (*Cluster) Listen

func (c *Cluster) Listen(network string, port int) (net.Listener, net.Addr, error)

func (*Cluster) ListenPacket

func (c *Cluster) ListenPacket(network string, port int) (net.PacketConn, net.Addr, error)

func (*Cluster) Name

func (c *Cluster) Name() string

func (*Cluster) Protocol

func (c *Cluster) Protocol() stnrv2.Protocol

func (*Cluster) Reconcile

func (c *Cluster) Reconcile(conf stnrv2.Config) error

Reconcile rebuilds the router, swaps the dialer on a change of its protocol, tunnel, TLS or addresses, and moves the resolver registrations of a running cluster to the new domains.

func (*Cluster) Start

func (c *Cluster) Start() error

Start runs the dialer and registers the domains with the resolver.

func (*Cluster) Status

func (c *Cluster) Status() stnrv2.Status

func (*Cluster) Tag

func (c *Cluster) Tag() api.Tag

Tag returns the tag of the conns the cluster's dialer makes, only the name before it has one.

func (*Cluster) Targets

func (c *Cluster) Targets() []netip.AddrPort

func (*Cluster) Type

func (c *Cluster) Type() runtime.ObjectType

type Filter

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

Filter is a filter config and its compiled rules, which every change replaces in place.

func (*Filter) Close

func (f *Filter) Close(bool) error

func (*Filter) GetConfig

func (f *Filter) GetConfig() stnrv2.Config

func (*Filter) Inspect

func (f *Filter) Inspect(old, new stnrv2.Config, _ *stnrv2.StunnerConfig) (runtime.Action, error)

Inspect reconciles every change in place.

func (*Filter) Match

func (f *Filter) Match(a netip.AddrPort) (allow, matched bool)

func (*Filter) Name

func (f *Filter) Name() string

func (*Filter) Reconcile

func (f *Filter) Reconcile(conf stnrv2.Config) error

Reconcile compiles the rules; the next check uses them.

func (*Filter) Start

func (f *Filter) Start() error

func (*Filter) Status

func (f *Filter) Status() stnrv2.Status

func (*Filter) Type

func (f *Filter) Type() runtime.ObjectType

type Health

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

Health is the Object that owns the /live, /ready, /status HTTP server.

func (*Health) Close

func (h *Health) Close(_ bool) error

func (*Health) GetConfig

func (h *Health) GetConfig() stnrv2.Config

GetConfig returns a copy of the live health config. Safe for concurrent use.

func (*Health) Inspect

func (h *Health) Inspect(old, new stnrv2.Config, _ *stnrv2.StunnerConfig) (runtime.Action, error)

func (*Health) Name

func (h *Health) Name() string

func (*Health) Reconcile

func (h *Health) Reconcile(conf stnrv2.Config) error

func (*Health) Start

func (h *Health) Start() error

func (*Health) Status

func (h *Health) Status() stnrv2.Status

func (*Health) Type

func (h *Health) Type() runtime.ObjectType

type HealthConfig

type HealthConfig struct {
	// Endpoint is the URI of the form `http://address:port` exposed for external HTTP
	// health-checking. Empty endpoint == use defaults; nil pointer in AdminConfig is mapped to
	// the default endpoint at extract time.
	Endpoint string `json:"endpoint,omitempty"`
}

HealthConfig is the typed subconfig consumed by the Health object.

func (*HealthConfig) ConfigName

func (c *HealthConfig) ConfigName() string

func (*HealthConfig) DeepCopyInto

func (c *HealthConfig) DeepCopyInto(dst stnrv2.Config)

func (*HealthConfig) DeepEqual

func (c *HealthConfig) DeepEqual(other stnrv2.Config) bool

func (*HealthConfig) String

func (c *HealthConfig) String() string

func (*HealthConfig) Validate

func (c *HealthConfig) Validate() error

type KindSpec

type KindSpec = reconciler.KindSpec

type Listener

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

Listener is a listener object: it accepts client conns, or dials its peer, applies the listener filters, and processes the conns via a chain of servers.

func NewListener

func NewListener(conf stnrv2.Config, rt *runtime.Runtime) (*Listener, error)

NewListener creates the listener object of a config.

func (*Listener) Close

func (l *Listener) Close(_ bool) error

Close closes the socket. Emitted conns stay up, except the conn of a dialing listener.

func (*Listener) GetConfig

func (l *Listener) GetConfig() stnrv2.Config

func (*Listener) Inspect

func (l *Listener) Inspect(old, new stnrv2.Config, full *stnrv2.StunnerConfig) (runtime.Action, error)

Inspect restarts on a socket change (protocol, address, port, connect); the rest reconciles in place.

func (*Listener) Name

func (l *Listener) Name() string

func (*Listener) Reconcile

func (l *Listener) Reconcile(conf stnrv2.Config) error

Reconcile applies everything but the socket to the next conns. The certificate of a running listener loads here: one that does not load fails the reconcile and keeps the previous one; a stopped listener loads it on Start.

func (*Listener) Start

func (l *Listener) Start() error

Start loads the certificate and binds the socket.

func (*Listener) Status

func (l *Listener) Status() stnrv2.Status

func (*Listener) Type

func (l *Listener) Type() runtime.ObjectType

type Metrics

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

Metrics is the Object that owns the Prometheus metrics HTTP server. Carving it out of Admin makes it independently restartable.

func (*Metrics) Close

func (m *Metrics) Close(_ bool) error

func (*Metrics) GetConfig

func (m *Metrics) GetConfig() stnrv2.Config

GetConfig returns a copy of the live metrics config. Safe for concurrent use.

func (*Metrics) Inspect

func (m *Metrics) Inspect(old, new stnrv2.Config, _ *stnrv2.StunnerConfig) (runtime.Action, error)

func (*Metrics) Name

func (m *Metrics) Name() string

func (*Metrics) Reconcile

func (m *Metrics) Reconcile(conf stnrv2.Config) error

func (*Metrics) Start

func (m *Metrics) Start() error

func (*Metrics) Status

func (m *Metrics) Status() stnrv2.Status

func (*Metrics) Type

func (m *Metrics) Type() runtime.ObjectType

type MetricsConfig

type MetricsConfig struct {
	Endpoint string `json:"endpoint,omitempty"`
}

MetricsConfig is the typed subconfig consumed by Metrics. An empty endpoint disables the server.

func (*MetricsConfig) ConfigName

func (c *MetricsConfig) ConfigName() string

func (*MetricsConfig) DeepCopyInto

func (c *MetricsConfig) DeepCopyInto(dst stnrv2.Config)

func (*MetricsConfig) DeepEqual

func (c *MetricsConfig) DeepEqual(other stnrv2.Config) bool

func (*MetricsConfig) String

func (c *MetricsConfig) String() string

func (*MetricsConfig) Validate

func (c *MetricsConfig) Validate() error

type Offload

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

Offload is the reconciliation representative of the process-wide offload engine (rt.OffloadEngine), created once at startup: an offload-config change restarts the object, whose Close closes the engine and whose Start re-pins it with the new config, while Stunner.Close closes the engine on shutdown. The object surfaces the engine statistics as status.

func (*Offload) Close

func (o *Offload) Close(shutdown bool) error

Close tears the engine down. On a reconcile-driven restart (shutdown=false) the engine is closed so the following Start re-pins it; on process shutdown the engine is closed by Stunner.Close, so this is a no-op.

func (*Offload) GetConfig

func (o *Offload) GetConfig() stnrv2.Config

GetConfig returns a copy of the live offload config. Safe for concurrent use.

func (*Offload) Inspect

func (o *Offload) Inspect(old, new stnrv2.Config, _ *stnrv2.StunnerConfig) (runtime.Action, error)

func (*Offload) Name

func (o *Offload) Name() string

func (*Offload) Reconcile

func (o *Offload) Reconcile(conf stnrv2.Config) error

func (*Offload) Start

func (o *Offload) Start() error

Start (re-)pins the process-wide offload engine with the current config. The reconciler calls it only on object create/restart, i.e. on an actual offload-config change.

func (*Offload) Status

func (o *Offload) Status() stnrv2.Status

func (*Offload) Type

func (o *Offload) Type() runtime.ObjectType

type OffloadConfig

type OffloadConfig struct {
	Engine     string   `json:"engine,omitempty"`
	Interfaces []string `json:"interfaces,omitempty"`
}

OffloadConfig is the typed subconfig consumed by Offload.

func (*OffloadConfig) ConfigName

func (c *OffloadConfig) ConfigName() string

func (*OffloadConfig) DeepCopyInto

func (c *OffloadConfig) DeepCopyInto(dst stnrv2.Config)

func (*OffloadConfig) DeepEqual

func (c *OffloadConfig) DeepEqual(other stnrv2.Config) bool

func (*OffloadConfig) String

func (c *OffloadConfig) String() string

func (*OffloadConfig) Validate

func (c *OffloadConfig) Validate() error

type Stunner

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

Stunner is the root Object of the dataplane tree. It holds no own runtime state; its job is to surface the full StunnerConfig, report live state from descendants, and provide a single node the reconciler can root its walk at.

func (*Stunner) Close

func (s *Stunner) Close(_ bool) error

func (*Stunner) GetConfig

func (s *Stunner) GetConfig() stnrv2.Config

GetConfig pulls each top-level child's config from the registry, surfacing the running dataplane state. Children missing before the first reconcile are reported as zero values.

func (*Stunner) Inspect

func (s *Stunner) Inspect(_, _ stnrv2.Config, _ *stnrv2.StunnerConfig) (runtime.Action, error)

Inspect/Reconcile/Start/Close are no-ops at the root: it has no own state and the tree-walk handles descendants.

func (*Stunner) Name

func (s *Stunner) Name() string

func (*Stunner) Reconcile

func (s *Stunner) Reconcile(_ stnrv2.Config) error

func (*Stunner) Start

func (s *Stunner) Start() error

func (*Stunner) Status

func (s *Stunner) Status() stnrv2.Status

Status aggregates the children's statuses into a StunnerStatus, with the number of live sessions summed over the servers and the readiness of the runtime.

func (*Stunner) Type

func (s *Stunner) Type() runtime.ObjectType

Jump to

Keyboard shortcuts

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