Documentation
¶
Overview ¶
Package sip implements the SIP server, a transaction-stateful proxy of inbound calls.
Index ¶
- Variables
- func New(conf *stnrv2.ServerConfig, rt *objruntime.Runtime) (objruntime.Object, error)
- type CallEvent
- type EventHandler
- type Server
- func (s *Server) Close(_ bool) error
- func (s *Server) GetConfig() stnrv2.Config
- func (s *Server) Reconcile(conf stnrv2.Config) error
- func (s *Server) Serve(c api.Conn) (api.Conn, api.Verdict, error)
- func (s *Server) Sessions() int
- func (s *Server) Start() error
- func (s *Server) Status() stnrv2.Status
Constants ¶
This section is empty.
Variables ¶
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 )
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 )
var CallSweepInterval = 30 * time.Second
CallSweepInterval is how often the server asks the media proxy whether its calls still run.
Functions ¶
func New ¶
func New(conf *stnrv2.ServerConfig, rt *objruntime.Runtime) (objruntime.Object, error)
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 ¶
Server is a sip server.