v1alpha1

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package v1alpha1 is the v1alpha1 version of the STUNner API.

Index

Constants

View Source
const ApiVersion string = "v1alpha1"
View Source
const DefaultAdminName = "default-admin-config"
View Source
const DefaultAuthName = "default-auth-config"
View Source
const DefaultAuthType = "plaintext"
View Source
const DefaultClusterProtocol = "udp"
View Source
const DefaultClusterType = "STATIC"
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 << 15
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 is the name of the server, optional.
	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 pointer value nil then the default is to
	// enable health-checking at `http://0.0.0.0:8086`, set to a pointer to an enpty string if
	// you want 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 added in v0.14.1

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 is the type of the STUN/TURN authentication mechanism ("plaintext" or "longterm").
	Type string `json:"type,omitempty"`
	// Realm defines the STUN/TURN authentication realm.
	Realm string `json:"realm,omitempty"`
	// Credentials specifies the authententication credentials: for "plaintext" at least the
	// keys "username" and "password" must be set, for "longterm" the key "secret" will hold
	// the shared authentication secret.
	Credentials map[string]string `json:"credentials"`
}

Auth defines the specification of 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 added in v0.14.1

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 (
	AuthTypePlainText AuthType = iota + 1
	AuthTypeLongTerm
	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 is the name of the cluster.
	Name string `json:"name"`
	// Type specifies the cluster address resolution policy, either STATIC or STRICT_DNS.
	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 STUNner can open transport relay connections to. 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 admits 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 added in v0.14.1

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 added in v0.11.2

type ClusterProtocol int

ClusterProtocol specifies the network protocol for a cluster

const (
	ClusterProtocolUDP ClusterProtocol = iota + 1
	ClusterProtocolTCP
	ClusterProtocolUnknown
)

func NewClusterProtocol added in v0.11.2

func NewClusterProtocol(raw string) (ClusterProtocol, error)

NewClusterProtocol parses the protocol specification

func (ClusterProtocol) String added in v0.11.2

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 added in v0.11.3

type ErrRestarted struct {
	Objects []string
}

func (ErrRestarted) Error added in v0.11.3

func (e ErrRestarted) Error() string

type ListenerConfig

type ListenerConfig struct {
	// Name is the name of the listener.
	Name string `json:"name,omitempty"`
	// Protocol is the transport protocol used by the listener ("UDP", "TCP", "TLS",
	// "DTLS"). The application-layer protocol on top of the transport protocol is always
	// STUN/TURN.
	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.
	Addr string `json:"address,omitempty"`
	// Port is the port for the listener.
	Port int `json:"port,omitempty"`
	// MinRelayPort is the smallest relay port assigned for the relay connections spawned by
	// the listener.
	MinRelayPort int `json:"min_relay_port,omitempty"`
	// MaxRelayPort is the highest relay port assigned for the relay connections spawned by the
	// listener.
	MaxRelayPort int `json:"max_relay_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 added in v0.14.1

func (req *ListenerConfig) DeepCopyInto(dst Config)

DeepCopyInto copies a configuration.

func (*ListenerConfig) DeepEqual

func (req *ListenerConfig) DeepEqual(other Config) bool

DeepEqual compares two configurations.

func (*ListenerConfig) GetListenerURI added in v0.15.3

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.
	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 of the the STUnner daemon.

func (*StunnerConfig) ConfigName

func (req *StunnerConfig) ConfigName() string

Name returns the name of the object to be configured.

func (*StunnerConfig) DeepCopyInto added in v0.14.1

func (req *StunnerConfig) DeepCopyInto(dst Config)

DeepCopyInto copies a configuration.

func (*StunnerConfig) DeepEqual

func (req *StunnerConfig) DeepEqual(conf Config) bool

DeepEqual compares two configurations.

func (*StunnerConfig) GetClusterConfig added in v0.11.3

func (req *StunnerConfig) GetClusterConfig(name string) (ClusterConfig, error)

GetClusterConfig finds a Cluster by name in a StunnerConfig or returns an error.

func (*StunnerConfig) GetListenerConfig added in v0.11.3

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