Documentation ¶
Overview ¶
Package stunner contains the public API for l7mp/stunner, a Kubernetes ingress gateway for WebRTC
Index ¶
- Constants
- func LoadConfig(config string) (*v1alpha1.StunnerConfig, error)
- func NewDefaultConfig(uri string) (*v1alpha1.StunnerConfig, error)
- type AuthGen
- type Options
- type Stunner
- func (s *Stunner) Close()
- 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) GetServer() *turn.Server
- func (s *Stunner) GetVersion() string
- func (s *Stunner) NewAuthHandler() turn.AuthHandler
- func (s *Stunner) NewPermissionHandler(l *object.Listener) turn.PermissionHandler
- func (s *Stunner) Reconcile(req v1alpha1.StunnerConfig) error
- func (s *Stunner) Start() error
- func (s *Stunner) Stop()
- func (s *Stunner) String() string
- func (s *Stunner) WithOptions(options Options) *Stunner
- type StunnerUri
- type Turncat
- type TurncatConfig
Constants ¶
const DefaultLogLevel = "all:WARN"
const UDP_PACKET_SIZE = 1500
Variables ¶
This section is empty.
Functions ¶
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)
NewDefaultStunnerConfig builds a default configuration from a STUNner URI. Example: the URI `turn://user:pass@127.0.0.1:3478` will be parsed into a STUNner configuration with a server running on the localhost at port 3478, with plain-text authentication using the username/password pair `user:pass`.
Types ¶
type Options ¶ added in v0.10.5
type Options struct { // DryRun will suppress sideeffects: it will not initialize listener sockets and it will // not bring up the TURN server. This is mostly for testing, default is false DryRun bool // SuppressRollback controls whether to rollback the last working configuration after a // failed reconciliation request. Default is false, which means to always 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 the daemon will // "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 (used mostly for // testing) Resolver resolver.DnsResolver // VNet will switch STUNner into testing mode, using a vnet.Net instance to run STUNner // over an emulated data-plane Net *vnet.Net }
Options defines various options to define the way STUNner will run
type Stunner ¶
type Stunner struct {
// contains filtered or unexported fields
}
Stunner is an instance of the STUNner deamon
func NewStunner ¶
func NewStunner() *Stunner
NewStunner creates a new empty STUNner deamon. Call Reconcle to reconcile the daemon for the given configuration
func (*Stunner) Close ¶
func (s *Stunner) Close()
Close stops the STUNner daemon, cleans up any associated state and closes all connections it is managing
func (*Stunner) GetAdmin ¶ added in v0.10.0
GetAdmin returns the adminisittive information for STUNner
func (*Stunner) GetCluster ¶ added in v0.10.0
GetCluster returns a STUNner cluster or nil of no cluster with the given name 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 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) GetServer ¶
func (s *Stunner) GetServer() *turn.Server
GetServer returns the TURN server instance running the STUNner daemon
func (*Stunner) GetVersion ¶ added in v0.10.0
GetVersion returns the STUNner API version
func (*Stunner) NewAuthHandler ¶ added in v0.10.0
func (s *Stunner) NewAuthHandler() turn.AuthHandler
NewAuthHandler returns an authentication handler callback for STUNner, suitable to be used with the TURN server for authenticating clients
func (*Stunner) NewPermissionHandler ¶ added in v0.10.0
NewPermissionHandler returns a callback for STUNner to handle client permsission requests to access peers
func (*Stunner) Reconcile ¶
func (s *Stunner) Reconcile(req v1alpha1.StunnerConfig) error
Reconcile handles the updates to the STUNner configuration. Some updates are destructive so the server must be closed and restarted with the new configuration manually (see the documentation of the corresponding STUNner objects for when STUNner may restart after a reconciliation). Reconcile returns nil if is server restart was not requred, v1alpha1.ErrRestartRequired to indicate that it performed a full shutdown-restart cycle to reconcile the new config (unless DryRun is on), and an error if an error happened during reconciliation, in which case it will rollback the last working configuration (unless SuppressRollback is on)
func (*Stunner) Start ¶ added in v0.10.0
Start starts the STUNner server and starts listining on all requested server sockets
func (*Stunner) Stop ¶ added in v0.10.5
func (s *Stunner) Stop()
Close stops the TURN server underneath STUNner
func (*Stunner) String ¶ added in v0.10.5
String returns a short description of the running STUNner instance
func (*Stunner) WithOptions ¶ added in v0.10.5
WithOptions will take into effect the options passed in
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 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 LoggerFactory logging.LoggerFactory }
TurncatConfig is the main configuration for the turncat relay