v1

package
v0.17.5 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 7 Imported by: 3

Documentation

Overview

Package v1 is the v1 version of the STUNner API.

Index

Constants

View Source
const (
	AuthTypePlainText = AuthTypeStatic
	AuthTypeLongTerm  = AuthTypeEphemeral
)
View Source
const ApiVersion string = "v1"
View Source
const DefaultAdminName = "default-admin-config"
View Source
const DefaultAuthName = "default-auth-config"
View Source
const DefaultAuthType = "static"
View Source
const DefaultClusterProtocol = "udp"
View Source
const DefaultClusterType = "STATIC"
View Source
const DefaultConfigDiscoveryAddress = ":13478"
View Source
const DefaultEnvVarConfigOrigin = "STUNNER_CONFIG_ORIGIN"
View Source
const DefaultEnvVarName = "STUNNER_NAME"
View Source
const DefaultEnvVarNamespace = "STUNNER_NAMESPACE"
View Source
const DefaultEnvVarNodeName = "STUNNER_NODENAME"
View Source
const DefaultHealthCheckPort int = 8086
View Source
const DefaultLogLevel = "all:INFO"
View Source
const DefaultMaxRelayPort int = 1<<16 - 1
View Source
const DefaultMetricsPort int = 8080
View Source
const DefaultMinRelayPort int = 1
View Source
const DefaultPort int = 3478
View Source
const DefaultProtocol = "turn-udp"
View Source
const DefaultRealm = "stunner.l7mp.io"
View Source
const DefaultStunnerName = "default-stunnerd"

Variables

View Source
var (
	ErrInvalidConf    = errors.New("invalid configuration")
	ErrNoSuchListener = errors.New("no such listener")
	ErrNoSuchCluster  = errors.New("no such cluster")
)

Functions

This section is empty.

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://0.0.0.0:8086`. Set to a pointer to an empty string to disable
	// health-checking.
	HealthCheckEndpoint *string `json:"healthcheck_endpoint,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 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 AuthType

type AuthType int

AuthType species the type of the STUN/TURN authentication mechanism used by STUNner.

const (
	AuthTypeStatic AuthType = iota + 1
	AuthTypeEphemeral
	AuthTypeUnknown
)

func NewAuthType

func NewAuthType(raw string) (AuthType, error)

NewAuthType parses the authentication mechanism specification.

func (AuthType) String

func (a AuthType) String() string

String returns a string representation for the authentication mechanism.

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 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 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 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) DeepCopyInto

func (req *StunnerConfig) DeepCopyInto(dst Config)

DeepCopyInto copies a configuration.

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) Validate

func (req *StunnerConfig) Validate() error

Validate checks if a listener configuration is correct.

Jump to

Keyboard shortcuts

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