sip

package
v1.43.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 21 Imported by: 5

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 added in v1.9.4

func BuildSIPToken(params SIPTokenParams) (string, error)

func DetermineNumberType added in v1.42.0

func DetermineNumberType(phoneNumber string) livekit.PhoneNumberType

DetermineNumberType determines the phone number type using the phonenumbers library

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 ExtractAreaCode added in v1.42.0

func ExtractAreaCode(phoneNumber string) string

ExtractAreaCode extracts the area code from a phone number using the phonenumbers library

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 added in v1.32.0

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 added in v1.32.0

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 added in v1.15.0

func NewCallID() string

func NormalizeNumber added in v1.35.0

func NormalizeNumber(num string) string

NormalizeNumber normalizes a phone number by removing formatting characters and ensuring it starts with a "+". This function delegates to livekit.NormalizeNumber for the actual implementation.

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 added in v1.10.1

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

ValidateDispatchRules checks a set of dispatch rules for conflicts.

Deprecated: use ValidateDispatchRulesIter

func ValidateDispatchRulesIter added in v1.32.0

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 added in v1.10.1

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

ValidateTrunks checks a set of trunks for conflicts.

Deprecated: use ValidateTrunksIter

func ValidateTrunksIter added in v1.32.0

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

ValidateTrunksIter checks a set of trunks for conflicts.

Types

type DispatchRuleConflictFunc added in v1.34.0

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

type DispatchRuleConflictReason added in v1.34.0

type DispatchRuleConflictReason int

func (DispatchRuleConflictReason) String added in v1.34.0

type DispatchRuleReplaceFunc added in v1.36.0

type DispatchRuleReplaceFunc func(r *livekit.SIPDispatchRuleInfo) *livekit.SIPDispatchRuleInfo

type DispatchRuleValidator added in v1.32.0

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

func NewDispatchRuleValidator added in v1.32.0

func NewDispatchRuleValidator(opts ...MatchDispatchRuleOpt) *DispatchRuleValidator

func (*DispatchRuleValidator) Validate added in v1.32.0

func (*DispatchRuleValidator) ValidateIter added in v1.32.0

type ErrNoDispatchMatched added in v1.9.9

type ErrNoDispatchMatched struct {
	NoRules      bool
	NoTrunks     bool
	CalledNumber string
}

func (*ErrNoDispatchMatched) Error added in v1.9.9

func (e *ErrNoDispatchMatched) Error() string

type MatchDispatchRuleOpt added in v1.34.0

type MatchDispatchRuleOpt func(opt *matchDispatchRuleOpts)

func WithAllowDispatchRuleConflicts added in v1.34.0

func WithAllowDispatchRuleConflicts() MatchDispatchRuleOpt

WithAllowDispatchRuleConflicts allows conflicting DispatchRule definitions.

func WithDispatchRuleConflict added in v1.34.0

func WithDispatchRuleConflict(fnc DispatchRuleConflictFunc) MatchDispatchRuleOpt

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

func WithDispatchRuleReplace added in v1.36.0

func WithDispatchRuleReplace(fnc DispatchRuleReplaceFunc) MatchDispatchRuleOpt

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

type MatchTrunkOpt added in v1.34.0

type MatchTrunkOpt func(opt *matchTrunkOpts)

func WithAllowTrunkConflicts added in v1.34.0

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 added in v1.34.0

func WithTrunkConflict(fnc TrunkConflictFunc) MatchTrunkOpt

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

func WithTrunkFiltered added in v1.34.0

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 added in v1.36.0

func WithTrunkReplace(fnc TrunkReplaceFunc) MatchTrunkOpt

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

type SIPTokenParams added in v1.31.0

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 added in v1.34.0

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

type TrunkConflictReason added in v1.34.0

type TrunkConflictReason int

func (TrunkConflictReason) String added in v1.34.0

func (i TrunkConflictReason) String() string

type TrunkFilteredFunc added in v1.34.0

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

type TrunkFilteredReason added in v1.34.0

type TrunkFilteredReason int

func (TrunkFilteredReason) String added in v1.34.0

func (i TrunkFilteredReason) String() string

type TrunkMatchResult added in v1.39.1

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 added in v1.39.1

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 added in v1.39.1

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
)

type TrunkReplaceFunc added in v1.36.0

type TrunkReplaceFunc func(t *livekit.SIPInboundTrunkInfo) *livekit.SIPInboundTrunkInfo

Jump to

Keyboard shortcuts

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