sip

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TrunkFilteredInvalid = TrunkFilteredReason(iota)
	TrunkFilteredCallingNumberDisallowed
	TrunkFilteredCalledNumberDisallowed
	TrunkFilteredSourceAddressDisallowed
)
View Source
const (
	TrunkConflictDefault = TrunkConflictReason(iota)
	TrunkConflictCalledNumber
	TrunkConflictCallingNumber
)
View Source
const (
	DispatchRuleConflictGeneric = DispatchRuleConflictReason(iota)
)

Variables

This section is empty.

Functions

func BuildSIPToken

func BuildSIPToken(params SIPTokenParams) (string, error)

func DispatchRulePriority

func DispatchRulePriority(info *livekit.SIPDispatchRuleInfo) int32

DispatchRulePriority returns sorting priority for dispatch rules. Lower value means higher priority.

func EvaluateDispatchRule

EvaluateDispatchRule checks a selected Dispatch Rule against the provided request.

func GetPinAndRoom

func GetPinAndRoom(info *livekit.SIPDispatchRuleInfo) (room, pin string, err error)

GetPinAndRoom returns a room name/prefix and the pin for a dispatch rule. Just a convenience wrapper.

func MatchDispatchRule deprecated

MatchDispatchRule finds the best dispatch rule matching the request parameters. Returns an error if no rule matched. Trunk parameter can be nil, in which case only wildcard dispatch rules will be effective (ones without Trunk IDs).

Deprecated: use MatchDispatchRuleIter

func MatchDispatchRuleIter

MatchDispatchRuleIter finds the best dispatch rule matching the request parameters. Returns an error if no rule matched. Trunk parameter can be nil, in which case only wildcard dispatch rules will be effective (ones without Trunk IDs).

func MatchTrunk deprecated

func MatchTrunk(trunks []*livekit.SIPInboundTrunkInfo, call *rpc.SIPCall, opts ...MatchTrunkOpt) (*livekit.SIPInboundTrunkInfo, error)

MatchTrunk finds a SIP Trunk definition matching the request. Returns nil if no rules matched or an error if there are conflicting definitions.

Deprecated: use MatchTrunkIter

func MatchTrunkIter

MatchTrunkIter finds a SIP Trunk definition matching the request. Returns nil if no rules matched or an error if there are conflicting definitions.

func NewCallID

func NewCallID() string

func NormalizeNumber

func NormalizeNumber(num string) string

func SelectDispatchRule deprecated

SelectDispatchRule takes a list of dispatch rules, and takes the decision which one should be selected. It returns an error if there are conflicting rules. Returns nil if no rules match.

Deprecated: use MatchDispatchRuleIter

func SortDispatchRules

func SortDispatchRules(rules []*livekit.SIPDispatchRuleInfo)

SortDispatchRules predictably sorts dispatch rules by priority (first one is highest).

func ValidateDispatchRules deprecated

func ValidateDispatchRules(rules []*livekit.SIPDispatchRuleInfo, opts ...MatchDispatchRuleOpt) error

ValidateDispatchRules checks a set of dispatch rules for conflicts.

Deprecated: use ValidateDispatchRulesIter

func ValidateDispatchRulesIter

func ValidateDispatchRulesIter(it iters.Iter[*livekit.SIPDispatchRuleInfo], opts ...MatchDispatchRuleOpt) (best *livekit.SIPDispatchRuleInfo, _ error)

ValidateDispatchRulesIter checks a set of dispatch rules for conflicts.

func ValidateTrunks deprecated

func ValidateTrunks(trunks []*livekit.SIPInboundTrunkInfo, opts ...MatchTrunkOpt) error

ValidateTrunks checks a set of trunks for conflicts.

Deprecated: use ValidateTrunksIter

func ValidateTrunksIter

func ValidateTrunksIter(it iters.Iter[*livekit.SIPInboundTrunkInfo], opts ...MatchTrunkOpt) error

ValidateTrunksIter checks a set of trunks for conflicts.

Types

type DispatchRuleConflictFunc

type DispatchRuleConflictFunc func(r1, r2 *livekit.SIPDispatchRuleInfo, reason DispatchRuleConflictReason)

type DispatchRuleConflictReason

type DispatchRuleConflictReason int

func (DispatchRuleConflictReason) String

type DispatchRuleValidator

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

func NewDispatchRuleValidator

func NewDispatchRuleValidator(opts ...MatchDispatchRuleOpt) *DispatchRuleValidator

func (*DispatchRuleValidator) Validate

func (*DispatchRuleValidator) ValidateIter

type ErrNoDispatchMatched

type ErrNoDispatchMatched struct {
	NoRules      bool
	NoTrunks     bool
	CalledNumber string
}

func (*ErrNoDispatchMatched) Error

func (e *ErrNoDispatchMatched) Error() string

type MatchDispatchRuleOpt

type MatchDispatchRuleOpt func(opt *matchDispatchRuleOpts)

func WithAllowDispatchRuleConflicts

func WithAllowDispatchRuleConflicts() MatchDispatchRuleOpt

WithAllowDispatchRuleConflicts allows conflicting DispatchRule definitions.

func WithDispatchRuleConflict

func WithDispatchRuleConflict(fnc DispatchRuleConflictFunc) MatchDispatchRuleOpt

WithDispatchRuleConflict sets a callback that is called when two DispatchRules conflict.

func WithDispatchRuleReplace

func WithDispatchRuleReplace(fnc DispatchRuleReplaceFunc) MatchDispatchRuleOpt

WithDispatchRuleReplace sets a callback that is called to potentially replace dispatch rules before matching runs.

type MatchTrunkOpt

type MatchTrunkOpt func(opt *matchTrunkOpts)

func WithAllowTrunkConflicts

func WithAllowTrunkConflicts() MatchTrunkOpt

WithAllowTrunkConflicts allows conflicting Trunk definitions by picking the first match.

Using this option will prevent TrunkConflictFunc from firing, since the first match will be returned immediately.

func WithTrunkConflict

func WithTrunkConflict(fnc TrunkConflictFunc) MatchTrunkOpt

WithTrunkConflict sets a callback that is called when two Trunks conflict.

func WithTrunkFiltered

func WithTrunkFiltered(fnc TrunkFilteredFunc) MatchTrunkOpt

WithTrunkFiltered sets a callback that is called when selected Trunk(s) doesn't match the call. If the callback returns true, trunk will not be filtered.

func WithTrunkReplace

func WithTrunkReplace(fnc TrunkReplaceFunc) MatchTrunkOpt

WithTrunkReplace sets a callback that is called to potentially replace trunks before matching runs.

type SIPTokenParams

type SIPTokenParams struct {
	APIKey                string
	APISecret             string
	RoomName              string
	ParticipantIdentity   string
	ParticipantName       string
	ParticipantMetadata   string
	ParticipantAttributes map[string]string
	RoomPreset            string
	RoomConfig            *livekit.RoomConfiguration
}

type TrunkConflictFunc

type TrunkConflictFunc func(t1, t2 *livekit.SIPInboundTrunkInfo, reason TrunkConflictReason)

type TrunkConflictReason

type TrunkConflictReason int

func (TrunkConflictReason) String

func (i TrunkConflictReason) String() string

type TrunkFilteredFunc

type TrunkFilteredFunc func(tr *livekit.SIPInboundTrunkInfo, reason TrunkFilteredReason) bool

type TrunkFilteredReason

type TrunkFilteredReason int

func (TrunkFilteredReason) String

func (i TrunkFilteredReason) String() string

type TrunkMatchResult

type TrunkMatchResult struct {
	// The matched trunk, if any
	Trunk *livekit.SIPInboundTrunkInfo
	// How the trunk was matched
	MatchType TrunkMatchType
	// Number of default trunks found
	DefaultTrunkCount int
}

TrunkMatchResult provides detailed information about the trunk matching process

func MatchTrunkDetailed

func MatchTrunkDetailed(it iters.Iter[*livekit.SIPInboundTrunkInfo], call *rpc.SIPCall, opts ...MatchTrunkOpt) (*TrunkMatchResult, error)

MatchTrunkDetailed is like MatchTrunkIter but returns detailed match information

type TrunkMatchType

type TrunkMatchType int

TrunkMatchType indicates how a trunk was matched

const (
	// TrunkMatchEmpty indicates no trunks were defined
	TrunkMatchEmpty TrunkMatchType = iota
	// TrunkMatchNone indicates trunks exist but none matched
	TrunkMatchNone
	// TrunkMatchDefault indicates only a default trunk (with no specific numbers) matched
	TrunkMatchDefault
	// TrunkMatchSpecific indicates a trunk with specific numbers matched
	TrunkMatchSpecific
)

Jump to

Keyboard shortcuts

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