turn

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
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

type Server struct {
	server.Base
	// contains filtered or unexported fields
}

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

func (s *Server) Close(_ bool) error

Close tears down the pion instance and every conn the server serves.

func (*Server) GetConfig

func (s *Server) GetConfig() stnrv2.Config

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

func (s *Server) Reconcile(conf stnrv2.Config) error

Reconcile applies the spec, the filters and the policy to the next requests.

func (*Server) Serve

func (s *Server) Serve(c api.Conn) (api.Conn, api.Verdict, error)

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.

func (*Server) Sessions

func (s *Server) Sessions() int

func (*Server) Start

func (s *Server) Start() error

Start builds the pion instance, in the realm of the policy.

func (*Server) Status

func (s *Server) Status() stnrv2.Status

Jump to

Keyboard shortcuts

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