turnrelay

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package turnrelay runs the optional public TURN service for WebRTC clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	ICEServers []ICEServer `json:"iceServers"`
	ExpiresAt  int64       `json:"expiresAt"` // Unix seconds.
}

type ICEServer

type ICEServer struct {
	URLs       []string `json:"urls"`
	Username   string   `json:"username"`
	Credential string   `json:"credential"`
}

ICEServer can be passed directly to RTCPeerConnection's iceServers option.

type Relay

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

Relay owns TURN listeners, accepted connections and allocation sockets.

func Start

func Start(cfg config.TURNConfig, tlsConfig *tls.Config, logger *slog.Logger) (*Relay, error)

Start binds all listeners before returning. Failure closes every acquired resource. TLS reuses the HTTPS certificate provider but runs on a separate TCP listener.

func (*Relay) Close

func (r *Relay) Close() error

Close also terminates idle, unauthenticated TCP/TLS clients. Pion only closes listening sockets itself, so these accepted connections are tracked separately.

func (*Relay) Credentials

func (r *Relay) Credentials(user string) (Credentials, error)

Credentials issues TURN REST credentials for an authenticated application user. The shared secret stays on trusted servers, never in a browser.

func (*Relay) URLs

func (r *Relay) URLs() []string

URLs lists the public ICE URLs, preserving the listeners' configured ports. NAT deployments must forward these ports without renumbering them.

Jump to

Keyboard shortcuts

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