sip

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: 33 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 sip implements the SIP server, a transaction-stateful proxy of inbound calls.

Index

Constants

This section is empty.

Variables

View Source
var (
	// RegisterTimeout bounds a REGISTER transaction.
	RegisterTimeout = 10 * time.Second
	// KeepaliveInterval is the range the STUN keepalives of a datagram flow are sent at, at a
	// random point each time (RFC 5626 section 4.4.1).
	KeepaliveInterval = [2]time.Duration{24 * time.Second, 29 * time.Second}
	// KeepaliveMisses is the number of consecutive unanswered keepalives that fail a flow whose
	// registrar has answered one.
	KeepaliveMisses = 2
)
View Source
var (
	// PeerTimeout is how long a SIP peer conn lives without traffic.
	PeerTimeout = 30 * time.Minute
	// MediaProxyTimeout bounds an ng request to the media proxy.
	MediaProxyTimeout = 5 * time.Second
)
View Source
var CallSweepInterval = 30 * time.Second

CallSweepInterval is how often the server asks the media proxy whether its calls still run.

Functions

func New

New creates the SIP server of a validated config.

Types

type CallEvent

type CallEvent struct {
	// SrcAddr and DstAddr are the trunk's address and the listener-side address serving it.
	SrcAddr, DstAddr net.Addr
	// Protocol is the transport of the trunk's conn.
	Protocol stnrv2.Protocol
	// CallID is the SIP Call-ID of the call.
	CallID string
	// Username and Realm are the call's quota identity.
	Username, Realm string
}

CallEvent is a call lifecycle event.

type EventHandler

type EventHandler struct {
	// OnCallCreated is called when a call is established.
	OnCallCreated func(ev CallEvent)
	// OnCallDeleted is called when an established call ends.
	OnCallDeleted func(ev CallEvent)
	// OnCallError is called when a call fails.
	OnCallError func(srcAddr net.Addr, protocol stnrv2.Protocol, message string)
}

EventHandler is the set of callbacks of the SIP server on call lifecycle events.

func NewEventHandler

func NewEventHandler(log logging.LeveledLogger, q *turnsrv.Quota) EventHandler

NewEventHandler returns the default call event wiring: logging and the quota accounting shared with the TURN server.

type Server

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

Server is a sip server.

func (*Server) Close

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

Close closes every SIP peer conn and the media proxy conn.

func (*Server) GetConfig

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

func (*Server) Reconcile

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

Reconcile applies the spec and the options to the next requests.

func (*Server) Serve

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

Serve takes a SIP conn from a listener.

func (*Server) Sessions

func (s *Server) Sessions() int

Sessions returns the number of calls the server admitted, set up or established.

func (*Server) Start

func (s *Server) Start() error

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