relay

package
v0.7.0-beta Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package relay opens one TURN allocation and keeps it alive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuthError

func IsAuthError(err error) bool

func IsQuotaError

func IsQuotaError(err error) bool

Types

type Allocation

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

func Allocate

func Allocate(ctx context.Context, o Options) (*Allocation, error)

func (*Allocation) Close

func (a *Allocation) Close() error

func (*Allocation) Keepalive

func (a *Allocation) Keepalive(ctx context.Context, every time.Duration)

Keepalive sends STUN Binding requests until ctx ends; VK relays drop silent allocations well before the 10 minute lifetime.

func (*Allocation) Relayed

func (a *Allocation) Relayed() net.PacketConn

func (*Allocation) RelayedAddr

func (a *Allocation) RelayedAddr() net.Addr

type Options

type Options struct {
	Server     string // host:port of the TURN relay
	Username   string
	Password   string
	UDP        bool // true: UDP transport (default and recommended); false: TCP
	PeerIsIPv6 bool // request an IPv6 relayed address
	Logger     logging.LoggerFactory
	// DialContext opens the socket towards the relay. nil uses the net
	// package directly. It is called once per allocation with network "udp"
	// (or "tcp" when UDP is false) and the resolved relay host:port; a UDP
	// conn must be connected to that address, since it is driven as a
	// PacketConn whose every write goes to the relay. Socket buffers are
	// enlarged only when the returned conn is a *net.UDPConn. This is the
	// hook a sing-box outbound uses for detour and bind_interface.
	DialContext func(ctx context.Context, network, address string) (net.Conn, error)
}

Directories

Path Synopsis
Package turntest runs pion/turn as a stand-in for VK's relay.
Package turntest runs pion/turn as a stand-in for VK's relay.

Jump to

Keyboard shortcuts

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