Documentation ¶
Overview ¶
Package stunner contains the public API for l7mp/stunner, a Kubernetes ingress gateway for WebRTC
Index ¶
- Constants
- func GenerateSelfSignedKey() ([]byte, []byte, error)
- func GetTurnUris(req *v1alpha1.StunnerConfig) ([]string, error)
- func GetUriFromListener(req *v1alpha1.ListenerConfig) (string, error)
- func LoadConfig(config string) (*v1alpha1.StunnerConfig, error)
- func NewDefaultConfig(uri string) (*v1alpha1.StunnerConfig, error)
- func NewZeroConfig() *v1alpha1.StunnerConfig
- func WatchConfig(ctx context.Context, w Watcher) error
- type AuthGen
- type Options
- type Stunner
- func (s *Stunner) AllocationCount() int
- func (s *Stunner) Close()
- func (s *Stunner) GetActiveConnections() float64
- func (s *Stunner) GetAdmin() *object.Admin
- func (s *Stunner) GetAuth() *object.Auth
- func (s *Stunner) GetCluster(name string) *object.Cluster
- func (s *Stunner) GetConfig() *v1alpha1.StunnerConfig
- func (s *Stunner) GetListener(name string) *object.Listener
- func (s *Stunner) GetLogger() logging.LoggerFactory
- func (s *Stunner) GetRealm() string
- func (s *Stunner) GetVersion() string
- func (s *Stunner) IsReady() bool
- func (s *Stunner) NewAuthHandler() turn.AuthHandler
- func (s *Stunner) NewPermissionHandler(l *object.Listener) turn.PermissionHandler
- func (s *Stunner) NewReadinessHandler() object.ReadinessHandler
- func (s *Stunner) NewRealmHandler() object.RealmHandler
- func (s *Stunner) Reconcile(req v1alpha1.StunnerConfig) error
- func (s *Stunner) SetLogLevel(levelSpec string)
- func (s *Stunner) Shutdown()
- func (s *Stunner) StartServer(l *object.Listener) error
- func (s *Stunner) Status() string
- type StunnerUri
- type Turncat
- type TurncatConfig
- type Watcher
Constants ¶
const DefaultLogLevel = "all:WARN"
const UDP_PACKET_SIZE = 1500
Variables ¶
This section is empty.
Functions ¶
func GenerateSelfSignedKey ¶ added in v0.14.3
GenerateSelfSignedKey is a rudimentary hack to generate self-signed certificates used to bootstrap the default config for TLS/DTLS listeners and for testing. Use for testing purposes only!
func GetTurnUris ¶ added in v0.14.3
func GetTurnUris(req *v1alpha1.StunnerConfig) ([]string, error)
GetUriFromListener returns a standard TURN URI from a listener config
func GetUriFromListener ¶ added in v0.14.3
func GetUriFromListener(req *v1alpha1.ListenerConfig) (string, error)
GetUriFromListener returns a standard TURN URI from a listener config
func LoadConfig ¶ added in v0.10.0
func LoadConfig(config string) (*v1alpha1.StunnerConfig, error)
LoadConfig loads a configuration from a file, substituting environment variables for placeholders in the configuration file. Returns the new configuration or error if load fails.
func NewDefaultConfig ¶ added in v0.10.0
func NewDefaultConfig(uri string) (*v1alpha1.StunnerConfig, error)
NewDefaultConfig builds a default configuration from a TURN server URI. Example: the URI `turn://user:pass@127.0.0.1:3478?transport=udp` will be parsed into a STUNner configuration with a server running on the localhost at UDP port 3478, with plain-text authentication using the username/password pair `user:pass`. Health-checks and metric scarping are disabled.
func NewZeroConfig ¶ added in v0.14.4
func NewZeroConfig() *v1alpha1.StunnerConfig
NewZeroConfig builds a zero configuration useful for bootstrapping STUNner. It starts with plaintext authentication and opens no listeners and clusters.
func WatchConfig ¶ added in v0.14.2
WatchConfig will watch a configuration file specified in the `Watcher.ConfigFile` parameter for changes and emit a new `StunnerConfig` on `Watcher.ConfigChannel` each time the file changes. If no file exists at the given path, then WatchConfig will periodically retry until the file appears. The configuration sent through the channel is not validated, make sure to check for syntax errors on the receiver side. Use the `context` to cancel the watcher.
Types ¶
type Options ¶ added in v0.10.5
type Options struct { // DryRun suppresses sideeffects: STUNner will not initialize listener sockets and bring up // the TURN server, and it will not fire up the health-check and the metrics // servers. Intended for testing, default is false. DryRun bool // SuppressRollback controls whether to rollback to the last working configuration after a // failed reconciliation request. Default is false, which means to always do a rollback. SuppressRollback bool // LogLevel specifies the required loglevel for STUNner and each of its sub-objects, e.g., // "all:TRACE" will force maximal loglevel throughout, "all:ERROR,auth:TRACE,turn:DEBUG" // will suppress all logs except in the authentication subsystem and the TURN protocol // logic. LogLevel string // Resolver swaps the internal DNS resolver with a custom implementation. Intended for // testing. Resolver resolver.DnsResolver // UDPListenerThreadNum determines the number of readloop threads spawned per UDP listener // (default is 4, must be >0 integer). TURN allocations will be automatically load-balanced // by the kernel UDP stack based on the client 5-tuple. This setting controls the maximum // number of CPU cores UDP listeners can scale to. Note that all other listener protocol // types (TCP, TLS and DTLS) use per-client threads, so this setting affects only UDP // listeners. For more info see https://github.com/pion/turn/pull/295. UDPListenerThreadNum int // VNet will switch on testing mode, using a vnet.Net instance to run STUNner over an // emulated data-plane. Net transport.Net }
Options defines various options for the STUNner server.
type Stunner ¶
type Stunner struct {
// contains filtered or unexported fields
}
Stunner is an instance of the STUNner deamon.
func NewStunner ¶
NewStunner creates a new STUNner deamon for the specified Options. Call Reconcile to reconcile the daemon for a new configuration. Object lifecycle is as follows: the daemon is "alive" (answers liveness probes if healthchecking is enabled) once the main object is successfully initialized, and "ready" after the first successful reconciliation (answers readiness probes if healthchecking is enabled). Calling program should catch SIGTERM signals and call Shutdown(), which will keep on serving connections but will fail readiness probes.
func (*Stunner) AllocationCount ¶ added in v0.14.4
GetAllocations returns the number of active allocations summed over all listeners. It can be used to drain the server before closing.
func (*Stunner) Close ¶
func (s *Stunner) Close()
Close stops the STUNner daemon, cleans up any internal state, and closes all connections including the health-check and the metrics server listeners.
func (*Stunner) GetActiveConnections ¶ added in v0.14.1
GetActiveConnections returns the number of active downstream (listener-side) TURN allocations.
func (*Stunner) GetAuth ¶ added in v0.10.0
GetAuth returns the authenitation object underlying STUNner.
func (*Stunner) GetCluster ¶ added in v0.10.0
GetCluster returns a STUNner cluster or nil if no cluster with the given name was found.
func (*Stunner) GetConfig ¶
func (s *Stunner) GetConfig() *v1alpha1.StunnerConfig
GetConfig returns the configuration of the running STUNner daemon.
func (*Stunner) GetListener ¶ added in v0.10.0
GetListener returns a STUNner listener or nil of no listener with the given name was found.
func (*Stunner) GetLogger ¶ added in v0.10.5
func (s *Stunner) GetLogger() logging.LoggerFactory
GetLogger returns the logger factory of the running daemon. Useful for creating a sub-logger.
func (*Stunner) GetRealm ¶ added in v0.11.3
GetRealm returns the current STUN/TURN authentication realm.
func (*Stunner) GetVersion ¶ added in v0.10.0
GetVersion returns the STUNner API version.
func (*Stunner) IsReady ¶ added in v0.11.2
IsReady returns true if the STUNner instance is ready to serve allocation requests.
func (*Stunner) NewAuthHandler ¶ added in v0.10.0
func (s *Stunner) NewAuthHandler() turn.AuthHandler
NewAuthHandler returns an authentication handler callback to be used with a TURN server for authenticating clients.
func (*Stunner) NewPermissionHandler ¶ added in v0.10.0
NewPermissionHandler returns a callback to handle client permission requests to access peers.
func (*Stunner) NewReadinessHandler ¶ added in v0.11.3
func (s *Stunner) NewReadinessHandler() object.ReadinessHandler
NewReadinessHandler creates a helper function for checking the readiness of STUNner.
func (*Stunner) NewRealmHandler ¶ added in v0.11.3
func (s *Stunner) NewRealmHandler() object.RealmHandler
NewRealmHandler creates a helper function for listeners to find out the authentication realm.
func (*Stunner) Reconcile ¶
func (s *Stunner) Reconcile(req v1alpha1.StunnerConfig) error
Reconcile handles updates to the STUNner configuration. Some updates are destructive: in this case the returned error contains the names of the objects (usually, listeners) that were restarted during reconciliation (see the documentation of the corresponding STUNner objects for when STUNner may restart after a reconciliation). Reconcile returns nil no objects were restarted, v1alpha1.ErrRestarted to indicate that a shutdown-restart cycle was performed for at least one internal object (usually, a listener) for the new config (unless DryRun is enabled), and an error if an error has occurred during reconciliation, in which case it will rollback the last working configuration (unless SuppressRollback is on).
func (*Stunner) SetLogLevel ¶ added in v0.14.3
SetLogLevel sets the loglevel.
func (*Stunner) Shutdown ¶ added in v0.11.3
func (s *Stunner) Shutdown()
Shutdown causes STUNner to fail the readiness check. Manwhile, it will keep on serving connections. This function should be called after the main program catches a SIGTERM.
func (*Stunner) StartServer ¶ added in v0.11.3
Start will start the TURN server that belongs to a listener.
type StunnerUri ¶
StunnerUri is the specification of a STUNner listener URI
func ParseUri ¶
func ParseUri(uri string) (*StunnerUri, error)
ParseUri parses a STUN/TURN server URI, e.g., "turn://user1:passwd1@127.0.0.1:3478?transport=udp"
type Turncat ¶
type Turncat struct {
// contains filtered or unexported fields
}
Turncat is the internal structure for representing a turncat relay.
func NewTurncat ¶
func NewTurncat(config *TurncatConfig) (*Turncat, error)
NewTurncat creates a new turncat relay from the specified config, creating a listener socket for clients to connect to and relaying client connections through the speficied STUN/TURN server to the peer.
type TurncatConfig ¶
type TurncatConfig struct { // ListenAddr is the listeninging socket address (local tunnel endpoint). ListenerAddr string // ServerAddr is the TURN server addrees (e.g. "turn://turn.abc.com:3478"). ServerAddr string // PeerAddr specifies the remote peer to connect to. PeerAddr string // Realm is the STUN/TURN realm. Realm string // AuthGet specifies the function to generate auth tokens. AuthGen AuthGen // InsecureMode controls whether self-signed TLS certificates are accepted by the TURN // client. InsecureMode bool // LoggerFactory is an optional external logger. LoggerFactory logging.LoggerFactory }
TurncatConfig is the main configuration for the turncat relay.
type Watcher ¶ added in v0.14.2
type Watcher struct { // ConfigFile specifies the config file name to watch. ConfigFile string // ConfigChannel is used to return the configs read. ConfigChannel chan<- v1alpha1.StunnerConfig // Logger is a logger factory as returned by, e.g., stunner.GetLogger(). Logger logging.LoggerFactory // Log is a leveled logger used to report progress. Either Logger or Log must be specified. Log logging.LeveledLogger }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
pkg
|
|
apis/v1alpha1
Package v1alpha1 is the v1alpha1 version of the STUNner API.
|
Package v1alpha1 is the v1alpha1 version of the STUNner API. |
authentication
Package auth contains variuos routines to generate and check STUNner authentication credentials.
|
Package auth contains variuos routines to generate and check STUNner authentication credentials. |