server

package
v5.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package server implements the private API to implement a TURN server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleRequest

func HandleRequest(r Request) error

HandleRequest processes the give Request.

Types

type NonceHash

type NonceHash struct {
	// contains filtered or unexported fields
}

NonceHash is used to create and verify nonces.

func (*NonceHash) Generate

func (n *NonceHash) Generate() (string, error)

Generate a nonce.

func (*NonceHash) Validate

func (n *NonceHash) Validate(nonce string) error

Validate checks that nonce is signed and is not expired.

type NonceManager

type NonceManager interface {
	Generate() (string, error)
	Validate(nonce string) error
}

NonceManager interface that both implementations satisfy.

func NewNonceHash

func NewNonceHash() (NonceManager, error)

NewNonceHash creates a NonceHash.

func NewShortNonceHash

func NewShortNonceHash(hmacLen int) (NonceManager, error)

NewShortNonceHash creates a ShortNonceHash. The hmacLen argument specifies the number of HMAC bytes to include (2-32 bytes). The total nonce size will be 4 + hmacLen bytes, default hmaclen is 12 bytes. The 4 bytes timestamp gives about ~8000 years before nonces would start to repeat (safe until year 10,135).

type Request

type Request struct {
	// Current Request State
	Conn    net.PacketConn
	SrcAddr net.Addr
	Buff    []byte
	TLS     *tls.ConnectionState

	// Server State
	AllocationManager *allocation.Manager
	NonceHash         NonceManager

	// User Configuration
	AuthHandler auth.AuthHandler

	// Quota Handler
	QuotaHandler func(username string, realm string, srcAddr net.Addr) (ok bool)

	Log   logging.LeveledLogger
	Realm string

	ChannelBindTimeout time.Duration
	PermissionTimeout  time.Duration
	AllocationLifetime time.Duration
}

Request contains all the state needed to process a single incoming datagram.

type ShortNonceHash

type ShortNonceHash struct {
	// contains filtered or unexported fields
}

ShortNonceHash is used to create and verify short nonces.

func (*ShortNonceHash) Generate

func (s *ShortNonceHash) Generate() (string, error)

Generate a short nonce (4 + hmacLen bytes encoded as base36).

func (*ShortNonceHash) Validate

func (s *ShortNonceHash) Validate(nonce string) error

Validate checks that nonce is signed and is not expired.

Jump to

Keyboard shortcuts

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