server

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package server holds what the TURN and L4 servers (the subpackages) share: the accept queue, the conntrack and ErrNotServing.

Index

Constants

View Source
const Backlog = 128

Backlog bounds the accept queue of a server.

Variables

View Source
var ErrNotServing = errors.New("server is not serving")

ErrNotServing answers a conn handed to a server that is stopped or restarting.

Functions

This section is empty.

Types

type AcceptQueue

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

AcceptQueue holds the conns handed to a server until its accept loop takes them. It is a net.Listener, so a library with its own accept loop can take from it.

func NewAcceptQueue

func NewAcceptQueue(backlog int) *AcceptQueue

NewAcceptQueue creates an accept queue of backlog conns.

func (*AcceptQueue) Accept

func (q *AcceptQueue) Accept() (net.Conn, error)

func (*AcceptQueue) Addr

func (q *AcceptQueue) Addr() net.Addr

func (*AcceptQueue) Close

func (q *AcceptQueue) Close() error

Close unblocks the waiting pushes and closes the queued conns.

func (*AcceptQueue) Push

func (q *AcceptQueue) Push(c net.Conn) error

Push queues a conn, blocking while the queue is full.

type Base

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

Base is the server object of the fields every server has, its spec: the name, the type, the clusters and the filters. A server of a type embeds it, calls into it for the spec and adds the options of its type. Reconcile writes the clusters and the filters, the data path reads them, under mu.

func (*Base) Admits

func (b *Base) Admits(peer net.Addr) bool

Admits tells whether the filters of the server admit a peer: a peer no rule matches is refused. Port 0 asks for the address of the peer on any port.

func (*Base) Close

func (b *Base) Close(bool) error

func (*Base) Clusters

func (b *Base) Clusters() []string

Clusters returns the clusters the server uses, in order; the caller must not modify it.

func (*Base) Desired

func (b *Base) Desired(conf stnrv2.Config) (*stnrv2.ServerConfig, error)

Desired returns the validated server config of an Inspect or a Reconcile.

func (*Base) GetConfig

func (b *Base) GetConfig() stnrv2.Config

GetConfig returns the config of the spec the server runs with; a server of a type adds the options of its type.

func (*Base) Init

func (b *Base) Init(conf *stnrv2.ServerConfig, rt *runtime.Runtime)

Init sets the name and the type of the server of a validated config, and the runtime its filters are looked up in.

func (*Base) Inspect

func (b *Base) Inspect(old, new stnrv2.Config, _ *stnrv2.StunnerConfig) (runtime.Action, error)

Inspect restarts on a type change and reconciles any other change in place.

func (*Base) Name

func (b *Base) Name() string

func (*Base) Reconcile

func (b *Base) Reconcile(conf stnrv2.Config) error

Reconcile applies the spec of a config: the clusters change in place, the name and the type never do (a type change restarts).

func (*Base) Serve

func (b *Base) Serve(api.Conn) (api.Conn, api.Verdict, error)

func (*Base) Sessions

func (b *Base) Sessions() int

func (*Base) Start

func (b *Base) Start() error

func (*Base) Status

func (b *Base) Status() stnrv2.Status

func (*Base) Type

func (b *Base) Type() runtime.ObjectType

type Unimplemented

type Unimplemented struct {
	Base
	// contains filtered or unexported fields
}

Unimplemented is a server of a type this build has no implementation of: it keeps the options of its type as they are, warns on start and serves no conn.

func NewUnimplemented

func NewUnimplemented(conf *stnrv2.ServerConfig, rt *runtime.Runtime) (*Unimplemented, error)

NewUnimplemented creates the server of a validated config of a type this build does not implement.

func (*Unimplemented) GetConfig

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

func (*Unimplemented) Reconcile

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

func (*Unimplemented) Start

func (s *Unimplemented) Start() error

func (*Unimplemented) Status

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

Directories

Path Synopsis
Package balancer chooses the peers of a server among the targets of its clusters, by a load-balancing policy.
Package balancer chooses the peers of a server among the targets of its clusters, by a load-balancing policy.
Package l4 implements the L4 server: every client conn becomes a flow to an endpoint of the server's clusters.
Package l4 implements the L4 server: every client conn becomes a flow to an endpoint of the server's clusters.
Package rtp implements the RTP server, a media proxy driven over ng.
Package rtp implements the RTP server, a media proxy driven over ng.
Package sip implements the SIP server, a transaction-stateful proxy of inbound calls.
Package sip implements the SIP server, a transaction-stateful proxy of inbound calls.
Package srt implements the SRT server: it routes every SRT flow by the stream it names to the endpoint holding the stream and relays it, the stream's encryption untouched.
Package srt implements the SRT server: it routes every SRT flow by the stream it names to the endpoint holding the stream and relays it, the stream's encryption untouched.
Package turn implements the TURN server: one pion/turn instance serving the client conns handed to it, relaying through the server's clusters.
Package turn implements the TURN server: one pion/turn instance serving the client conns handed to it, relaying through the server's clusters.

Jump to

Keyboard shortcuts

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