Documentation
¶
Overview ¶
Package v1 is the v1 version of the STUNner API.
Index ¶
- Constants
- Variables
- func LicensingStatus(req *LicenseConfig) string
- type AdminConfig
- type AdminStatus
- type AuthConfig
- type AuthStatus
- type AuthType
- type ClusterConfig
- type ClusterProtocol
- type ClusterStatus
- type ClusterType
- type Config
- type ErrRestarted
- type LicenseConfig
- type LicenseStatus
- type ListenerConfig
- func (req *ListenerConfig) ConfigName() string
- func (req *ListenerConfig) DeepCopyInto(dst Config)
- func (req *ListenerConfig) DeepEqual(other Config) bool
- func (req *ListenerConfig) GetListenerURI(rfc7065 bool) (string, error)
- func (req *ListenerConfig) String() string
- func (req *ListenerConfig) Validate() error
- type ListenerProtocol
- type ListenerStatus
- type OffloadDirStat
- type OffloadMode
- type OffloadStatInfo
- type StatType
- type Status
- type StunnerConfig
- func (req *StunnerConfig) ConfigName() string
- func (req *StunnerConfig) DeepCopy() *StunnerConfig
- func (req *StunnerConfig) DeepCopyInto(dst Config)
- func (a *StunnerConfig) DeepEqual(conf Config) bool
- func (req *StunnerConfig) GetClusterConfig(name string) (ClusterConfig, error)
- func (req *StunnerConfig) GetListenerConfig(name string) (ListenerConfig, error)
- func (req *StunnerConfig) String() string
- func (req *StunnerConfig) Summary() string
- func (req *StunnerConfig) Validate() error
- type StunnerStatus
Constants ¶
const ( ApiVersion string = "v1" DefaultStunnerName = "default-stunnerd" DefaultProtocol = "turn-udp" DefaultClusterProtocol = "udp" DefaultPort int = 3478 DefaultLogLevel = "all:INFO" DefaultRealm = "stunner.l7mp.io" DefaultAuthType = "static" DefaultMinRelayPort int = 1 DefaultMaxRelayPort int = 1<<16 - 1 DefaultClusterType = "STATIC" DefaultAdminName = "default-admin-config" DefaultAuthName = "default-auth-config" DefaultNodeAddressPlaceholder = "__node_address_placeholder" // guaranteed to not parse as a valid IP )
stunnerd defaults
const ( DefaultMetricsPort int = 8080 DefaultHealthCheckPort int = 8086 DefaultAuthServicePort int = 8088 DefaultICETesterPort int = 8089 )
default ports
const ( DefaultCDSServiceLabelKey = "stunner.l7mp.io/config-discovery-service" DefaultCDSServiceLabelValue = "enabled" DefaultAppLabelKey = "app" DefaultAppLabelValue = "stunner" DefaultAuthAppLabelValue = "stunner-auth" DefaultRelatedGatewayKey = "stunner.l7mp.io/related-gateway-name" DefaultRelatedGatewayNamespace = "stunner.l7mp.io/related-gateway-namespace" DefaultOwnedByLabelKey = "stunner.l7mp.io/owned-by" DefaultOwnedByLabelValue = "stunner" )
Label/annotation defaults
const ( DefaultConfigDiscoveryPort = 13478 DefaultConfigDiscoveryAddress = ":13478" DefaultEnvVarName = "STUNNER_NAME" DefaultEnvVarNamespace = "STUNNER_NAMESPACE" DefaultEnvVarAddr = "STUNNER_ADDR" DefaultEnvVarNodeName = "STUNNER_NODENAME" DefaultEnvVarConfigOrigin = "STUNNER_CONFIG_ORIGIN" DefaultCDSServerAddrEnv = "CDS_SERVER_ADDR" DefaultCDSServerNamespaceEnv = "CDS_SERVER_NAMESPACE" DefaultCDSServerPortEnv = "CDS_SERVER_PORT" )
CDS defaults
const ( AuthTypePlainText = AuthTypeStatic AuthTypeLongTerm = AuthTypeEphemeral )
Variables ¶
Functions ¶
func LicensingStatus ¶ added in v1.1.0
func LicensingStatus(req *LicenseConfig) string
Types ¶
type AdminConfig ¶
type AdminConfig struct {
// Name of the server. Default is "default-stunnerd".
Name string `json:"name,omitempty"`
// LogLevel is the desired log verbosity, e.g.: "stunner:TRACE,all:INFO". Default is
// "all:INFO".
LogLevel string `json:"loglevel,omitempty"`
// MetricsEndpoint is the URI in the form `http://address:port/path` at which HTTP metric
// requests are served. The scheme (`http://`") is mandatory. Default is to expose no
// metric endpoints.
MetricsEndpoint string `json:"metrics_endpoint,omitempty"`
// HealthCheckEndpoint is the URI of the form `http://address:port` exposed for external
// HTTP health-checking. A liveness probe responder will be exposed on path `/live` and
// readiness probe on path `/ready`. The scheme (`http://`) is mandatory, and if no port is
// specified then the default port is 8086. If ignored, then the default is to enable
// health-checking at `http://:8086`. Set to a pointer to an empty string to disable
// health-checking.
HealthCheckEndpoint *string `json:"healthcheck_endpoint,omitempty"`
// UserQuota defines the number of permitted TURN allocatoins per username. Affects
// allocation created on any listener. Default is 0, meaning no quota is enforced.
UserQuota int `json:"user_quota,omitempty"`
// OffloadEngine defines the dataplane offload mode, either "None", "XDP", "TC", or
// "Auto". Set to "Auto" to let STUNner find the optimal offload mode. Default is "None".
OffloadEngine string `json:"offload_engine,omitempty"`
// OffloadInterfaces explicitly specifies the interfaces on which to enable the offload
// engine. Empty list means to enable offload on all interfaces (this is the default).
OffloadInterfaces []string `json:"offload_interfaces,omitempty"`
// LicenseConfig describes the licensing info to be used to check subscription status with
// the license server.
LicenseConfig *LicenseConfig `json:"license_config,omitempty"`
}
AdminConfig holds the administrative configuration.
func (*AdminConfig) ConfigName ¶
func (req *AdminConfig) ConfigName() string
Name returns the name of the object to be configured.
func (*AdminConfig) DeepCopyInto ¶
func (req *AdminConfig) DeepCopyInto(dst Config)
DeepCopyInto copies a configuration.
func (*AdminConfig) DeepEqual ¶
func (req *AdminConfig) DeepEqual(other Config) bool
DeepEqual compares two configurations.
func (*AdminConfig) String ¶
func (req *AdminConfig) String() string
String stringifies the configuration.
func (*AdminConfig) Validate ¶
func (req *AdminConfig) Validate() error
Validate checks a configuration and injects defaults.
type AdminStatus ¶ added in v0.17.12
type AdminStatus struct {
Name string `json:"name,omitempty"`
LogLevel string `json:"loglevel,omitempty"`
MetricsEndpoint string `json:"metrics_endpoint,omitempty"`
HealthCheckEndpoint string `json:"healthcheck_endpoint,omitempty"`
UserQuota string `json:"quota,omitempty"`
OffloadStatus string `json:"offload,omitempty"`
LicensingInfo string `json:"licensing_info,omitempty"`
}
AdminStatus represents the administrative status.
func (*AdminStatus) String ¶ added in v0.17.12
func (a *AdminStatus) String() string
String returns a string reprsentation of the administrative status.
type AuthConfig ¶
type AuthConfig struct {
// Type of the STUN/TURN authentication mechanism ("static" or "ephemeral"). The deprecated
// type name "plaintext" is accepted for "static" and the deprecated type name "longterm"
// is accepted for "ephemeral" for compatibility with older versions.
Type string `json:"type,omitempty"`
// Realm defines the STUN/TURN authentication realm.
Realm string `json:"realm,omitempty"`
// Credentials specifies the authententication credentials: for "static" at least the keys
// "username" and "password" must be set, for "ephemeral" the key "secret" specifying the
// shared authentication secret must be set.
Credentials map[string]string `json:"credentials"`
}
Auth specifies the STUN/TURN authentication mechanism used by STUNner.
func (*AuthConfig) ConfigName ¶
func (req *AuthConfig) ConfigName() string
Name returns the name of the object to be configured.
func (*AuthConfig) DeepCopyInto ¶
func (req *AuthConfig) DeepCopyInto(dst Config)
DeepCopyInto copies a configuration.
func (*AuthConfig) DeepEqual ¶
func (req *AuthConfig) DeepEqual(other Config) bool
DeepEqual compares two configurations.
func (*AuthConfig) String ¶
func (req *AuthConfig) String() string
String stringifies the configuration.
func (*AuthConfig) Validate ¶
func (req *AuthConfig) Validate() error
Validate checks a configuration and injects defaults.
type AuthStatus ¶ added in v0.17.12
type AuthStatus = AuthConfig
AuthStatus represents the authentication status.
type AuthType ¶
type AuthType int
AuthType species the type of the STUN/TURN authentication mechanism used by STUNner.
func NewAuthType ¶
NewAuthType parses the authentication mechanism specification.
type ClusterConfig ¶
type ClusterConfig struct {
// Name of the cluster. Name is mandatory.
Name string `json:"name"`
// Type specifies the cluster address resolution policy, either STATIC or
// STRICT_DNS. Default is "STATIC".
Type string `json:"type,omitempty"`
// Protocol specifies the protocol to be used with the cluster, either UDP (default) or TCP
// (not implemented yet).
Protocol string `json:"protocol,omitempty"`
// Endpoints specifies the peers that can be reached via this cluster.
Endpoints []string `json:"endpoints,omitempty"`
}
ClusterConfig specifies a set of upstream peers to which STUNner can open transport relay connections. There are two address resolution policies. In STATIC clusters the allowed peer IP addresses are explicitly listed in the endpoint list. In STRICT_DNS clusters the endpoints are assumed to be proper DNS domain names: STUNner will resolve each domain name in the background and admit a new connection only if the peer address matches one of the IP addresses returned by the DNS resolver for one of the endpoints. STRICT_DNS clusters are best used with headless Kubernetes services.
func (*ClusterConfig) ConfigName ¶
func (req *ClusterConfig) ConfigName() string
Name returns the name of the object to be configured.
func (*ClusterConfig) DeepCopyInto ¶
func (req *ClusterConfig) DeepCopyInto(dst Config)
DeepCopyInto copies a configuration.
func (*ClusterConfig) DeepEqual ¶
func (req *ClusterConfig) DeepEqual(other Config) bool
DeepEqual compares two configurations.
func (*ClusterConfig) String ¶
func (req *ClusterConfig) String() string
String stringifies the configuration.
func (*ClusterConfig) Validate ¶
func (req *ClusterConfig) Validate() error
Validate checks a configuration and injects defaults.
type ClusterProtocol ¶
type ClusterProtocol int
ClusterProtocol specifies the network protocol for a cluster.
const ( ClusterProtocolUDP ClusterProtocol = iota + 1 ClusterProtocolTCP ClusterProtocolUnknown )
func NewClusterProtocol ¶
func NewClusterProtocol(raw string) (ClusterProtocol, error)
NewClusterProtocol parses the protocol specification.
func (ClusterProtocol) String ¶
func (p ClusterProtocol) String() string
String returns a string representation of a cluster protocol.
type ClusterStatus ¶ added in v0.17.12
type ClusterStatus struct {
*ClusterConfig
Stats OffloadDirStat `json:"stats"`
}
func (*ClusterStatus) String ¶ added in v1.1.0
func (req *ClusterStatus) String() string
String stringifies the configuration.
type ClusterType ¶
type ClusterType int
ClusterType specifies the cluster address resolution policy.
const ( ClusterTypeStatic ClusterType = iota + 1 ClusterTypeStrictDNS ClusterTypeUnknown )
func NewClusterType ¶
func NewClusterType(raw string) (ClusterType, error)
func (ClusterType) String ¶
func (l ClusterType) String() string
type Config ¶
type Config interface {
// Validate checks a configuration and injects defaults.
Validate() error
// Name returns the name of the object to be configured.
ConfigName() string
// DeepEqual compares two configurations.
DeepEqual(other Config) bool
// DeepCopyInto copies a configuration.
DeepCopyInto(dst Config)
// String stringifies the configuration.
String() string
}
Config is the main interface for STUNner configuration objects.
type ErrRestarted ¶
type ErrRestarted struct {
Objects []string
}
func (ErrRestarted) Error ¶
func (e ErrRestarted) Error() string
type LicenseConfig ¶ added in v1.1.0
type LicenseConfig struct {
// Key is a comma-separated list of unlocked features plus a time-window during which the
// key is considered valid.
Key string `json:"key"`
// HMAC is a hash-based message authentication code for validating the license key.
HMAC string `json:"hmac"`
}
Licensing info to be used to check subscription status with the license server.
type LicenseStatus ¶ added in v1.1.0
type LicenseStatus struct {
EnabledFeatures []string `json:"enabledFeatures"`
SubscriptionType string `json:"subscriptionType"`
LastUpdated string `json:"lastUpdated"`
LastError string `json:"lastError"`
}
LicenseStatus holds the licensing status.
func NewEmptyLicenseStatus ¶ added in v1.1.0
func NewEmptyLicenseStatus() LicenseStatus
func (LicenseStatus) String ¶ added in v1.1.0
func (s LicenseStatus) String() string
func (LicenseStatus) Summary ¶ added in v1.1.0
func (s LicenseStatus) Summary() string
Summary returns a stringified configuration.
type ListenerConfig ¶
type ListenerConfig struct {
// Name of the listener.
Name string `json:"name,omitempty"`
// Protocol is the transport protocol ("UDP", "TCP", "TLS", "DTLS") or the complete L4/L7
// protocol stack ("TURN-UDP", "TURN-TCP", "TURN-TLS", "TURN-DTLS") used by the listener.
// The application-layer protocol on top of the transport protocol is always TURN, so "UDP"
// and "TURN-UDP" are equivalent (and so on for the other protocols). Default is
// "TURN-UDP".
Protocol string `json:"protocol,omitempty"`
// PublicAddr is the Internet-facing public IP address for the listener (ignored by
// STUNner).
PublicAddr string `json:"public_address,omitempty"`
// PublicPort is the Internet-facing public port for the listener (ignored by STUNner).
PublicPort int `json:"public_port,omitempty"`
// Addr is the IP address for the listener. Default is localhost.
Addr string `json:"address,omitempty"`
// Port is the port for the listener. Default is the standard TURN port (3478).
Port int `json:"port,omitempty"`
// Cert is the base64-encoded TLS cert.
Cert string `json:"cert,omitempty"`
// Key is the base64-encoded TLS key.
Key string `json:"key,omitempty"`
// Routes specifies the list of Routes allowed via a listener.
Routes []string `json:"routes,omitempty"`
}
ListenerConfig specifies a server socket on which STUN/TURN connections will be served.
func (*ListenerConfig) ConfigName ¶
func (req *ListenerConfig) ConfigName() string
Name returns the name of the object to be configured.
func (*ListenerConfig) DeepCopyInto ¶
func (req *ListenerConfig) DeepCopyInto(dst Config)
DeepCopyInto copies a configuration.
func (*ListenerConfig) DeepEqual ¶
func (req *ListenerConfig) DeepEqual(other Config) bool
DeepEqual compares two configurations. Routes must be sorted in both configs!
func (*ListenerConfig) GetListenerURI ¶
func (req *ListenerConfig) GetListenerURI(rfc7065 bool) (string, error)
GetListenerURI is a helper that can output two types of Listener URIs: one with "://" after the scheme or one with only ":" (as per RFC7065).
func (*ListenerConfig) String ¶
func (req *ListenerConfig) String() string
String stringifies the configuration.
func (*ListenerConfig) Validate ¶
func (req *ListenerConfig) Validate() error
Validate checks a configuration and injects defaults.
type ListenerProtocol ¶
type ListenerProtocol int
ListenerProtocol specifies the network protocol for a listener.
const ( ListenerProtocolUnknown ListenerProtocol = iota ListenerProtocolUDP ListenerProtocolTCP ListenerProtocolTLS ListenerProtocolDTLS ListenerProtocolTURNUDP ListenerProtocolTURNTCP ListenerProtocolTURNTLS ListenerProtocolTURNDTLS )
func NewListenerProtocol ¶
func NewListenerProtocol(raw string) (ListenerProtocol, error)
NewListenerProtocol parses the protocol specification.
func (ListenerProtocol) String ¶
func (l ListenerProtocol) String() string
String returns a string representation of a listener protocol.
type ListenerStatus ¶ added in v0.17.12
type ListenerStatus struct {
*ListenerConfig
Stats OffloadDirStat `json:"stats"`
}
func (*ListenerStatus) String ¶ added in v1.1.0
func (req *ListenerStatus) String() string
String stringifies the configuration.
type OffloadDirStat ¶ added in v1.1.0
type OffloadDirStat struct {
Rx OffloadStatInfo `json:"rx"`
Tx OffloadStatInfo `json:"tx"`
}
OffloadStatMap defines the TX/RX offload statistics for a particular listener or cluster.
type OffloadMode ¶ added in v1.1.0
type OffloadMode int
OffloadEngine specifies the type of TURN offload mode.
const ( OffloadEngineNone OffloadMode = iota OffloadEngineXDP OffloadEngineTC OffloadEngineAuto )
func NewOffloadEngine ¶ added in v1.1.0
func NewOffloadEngine(raw string) (OffloadMode, error)
NewOffloadEngine parses the offload mode.
func (OffloadMode) String ¶ added in v1.1.0
func (p OffloadMode) String() string
String returns a string representation of a cluster protocol.
type OffloadStatInfo ¶ added in v1.1.0
type OffloadStatInfo struct {
Pkts uint64 `json:"pkts"`
Bytes uint64 `json:"bytes"`
TimestampLast uint64 `json:"timestamp"`
}
OffloadStatInfo holds the statistics for a listener or cluster in RX or TX direction.
type Status ¶ added in v0.17.12
type Status interface {
// String stringifies the status.
String() string
}
Status holds the status of a component.
type StunnerConfig ¶
type StunnerConfig struct {
// ApiVersion is the version of the STUNner API implemented. Must be set to "v1".
ApiVersion string `json:"version"`
// AdminConfig holds administrative configuration.
Admin AdminConfig `json:"admin,omitempty"`
// Auth defines the STUN/TURN authentication mechanism.
Auth AuthConfig `json:"auth"`
// Listeners defines the server sockets exposed to clients.
Listeners []ListenerConfig `json:"listeners,omitempty"`
// Clusters defines the upstream endpoints to which relay transport connections can be made
// by clients.
Clusters []ClusterConfig `json:"clusters,omitempty"`
}
StunnerConfig specifies the configuration for the STUnner daemon.
func (*StunnerConfig) ConfigName ¶
func (req *StunnerConfig) ConfigName() string
Name returns the name of the object to be configured.
func (*StunnerConfig) DeepCopy ¶ added in v1.1.0
func (req *StunnerConfig) DeepCopy() *StunnerConfig
DeepCopy copies a configuration.
func (*StunnerConfig) DeepCopyInto ¶
func (req *StunnerConfig) DeepCopyInto(dst Config)
DeepCopyInto copies a configuration into another config.
func (*StunnerConfig) DeepEqual ¶
func (a *StunnerConfig) DeepEqual(conf Config) bool
DeepEqual compares two configurations.
func (*StunnerConfig) GetClusterConfig ¶
func (req *StunnerConfig) GetClusterConfig(name string) (ClusterConfig, error)
GetClusterConfig finds a Cluster by name in a StunnerConfig or returns an error.
func (*StunnerConfig) GetListenerConfig ¶
func (req *StunnerConfig) GetListenerConfig(name string) (ListenerConfig, error)
GetListenerConfig finds a Listener by name in a StunnerConfig or returns an error.
func (*StunnerConfig) String ¶
func (req *StunnerConfig) String() string
String stringifies the configuration.
func (*StunnerConfig) Summary ¶ added in v0.17.6
func (req *StunnerConfig) Summary() string
Summary returns a stringified configuration.
func (*StunnerConfig) Validate ¶
func (req *StunnerConfig) Validate() error
Validate checks if a listener configuration is correct.
type StunnerStatus ¶ added in v0.17.12
type StunnerStatus struct {
ApiVersion string `json:"version"`
Admin *AdminStatus `json:"admin"`
Auth *AuthStatus `json:"auth"`
Listeners []*ListenerStatus `json:"listeners"`
Clusters []*ClusterStatus `json:"clusters"`
AllocationCount int `json:"allocationCount"`
Status string `json:"status"`
}
StunnerStatus represents the status of the STUnner daemon.
func (*StunnerStatus) String ¶ added in v0.17.12
func (s *StunnerStatus) String() string
String stringifies the status.
func (*StunnerStatus) Summary ¶ added in v0.17.12
func (s *StunnerStatus) Summary() string
String summarizes the status.