Documentation
¶
Overview ¶
Package turn implements the TURN server: one pion/turn instance serving the client conns handed to it, relaying through the server's clusters.
Index ¶
- Variables
- type AllocationEventType
- type Quota
- type Server
- func (s *Server) AuthHandler() a12n.AuthHandler
- func (s *Server) Close(_ bool) error
- func (s *Server) GetConfig() stnrv2.Config
- func (s *Server) Inspect(old, new stnrv2.Config, full *stnrv2.StunnerConfig) (objruntime.Action, error)
- func (s *Server) Reconcile(conf stnrv2.Config) error
- func (s *Server) Serve(c api.Conn) (api.Conn, api.Verdict, error)
- func (s *Server) Sessions() int
- func (s *Server) Start() error
- func (s *Server) Status() stnrv2.Status
Constants ¶
This section is empty.
Variables ¶
var PreAllocationTimeout = 30 * time.Second
PreAllocationTimeout is how long a datagram conn may live without an allocation.
Functions ¶
This section is empty.
Types ¶
type AllocationEventType ¶
type AllocationEventType int
AllocationEventType is a helper type to administer allocations.
const ( AllocationCreated AllocationEventType = iota + 1 AllocationDeleted )
type Quota ¶
type Quota struct {
// contains filtered or unexported fields
}
Quota is the per-user session quota shared by the TURN and L4 servers.
func NewQuotaHandler ¶
func NewQuotaHandler(rt *objruntime.Runtime) *Quota
NewQuotaHandler creates a quota handler.
func (*Quota) AllocationHandler ¶
func (q *Quota) AllocationHandler(_ net.Addr, _ net.Addr, _ string, username, realm string, event AllocationEventType)
AllocationHandler updates quota accounting on session lifecycle events.
func (*Quota) QuotaHandler ¶
func (q *Quota) QuotaHandler() turn.QuotaHandler
QuotaHandler returns a callback that checks and reserves a session's quota in one step.
type Server ¶
Server is a TURN server object. Reconcile and the lifecycle write its fields, the data path (the pion handlers, Serve) reads them, under mu.
func New ¶
func New(conf *stnrv2.ServerConfig, rt *objruntime.Runtime) (*Server, error)
New creates the TURN server of a validated config.
func (*Server) AuthHandler ¶
func (s *Server) AuthHandler() a12n.AuthHandler
AuthHandler returns the authentication handler callback of the server, which authenticates by the policy the server names, looked up on every request. A policy of type none makes a pure STUN server (a nil handler); a missing one refuses every client.
func (*Server) Inspect ¶
func (s *Server) Inspect(old, new stnrv2.Config, full *stnrv2.StunnerConfig) (objruntime.Action, error)
Inspect inspects whether to restart the server: a change of the realm of the policy, of whether the policy is of type none, or of the relay address family, restarts.
func (*Server) Reconcile ¶
Reconcile applies the spec, the filters and the policy to the next requests.
func (*Server) Serve ¶
Serve hands a client conn to pion's accept loop. Stream conns get STUN framing here, outermost, where RFC 6062 ConnectionBind finds the stream underneath.