agents

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: AGPL-3.0 Imports: 43 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CGRAuthAPP            = "cgrates_auth"
	CGRMaxSessionTime     = "CGRMaxSessionTime"
	CGRRoute              = "CGRRoute"
	ARIStasisStart        = "StasisStart"
	ARIChannelStateChange = "ChannelStateChange"
	ARIChannelDestroyed   = "ChannelDestroyed"
	ARIRESTResponse       = "RESTResponse"

	SMAAuthorization         = "SMA_AUTHORIZATION"
	SMASessionStart          = "SMA_SESSION_START"
	SMASessionTerminate      = "SMA_SESSION_TERMINATE"
	ARICGRResourceAllocation = "CGRResourceAllocation"
)

constants used by AsteriskAgent

View Source
const (

	// Freswitch event proprities names
	SUBJECT                  = varPrefix + utils.CGRSubject
	ACCOUNT                  = varPrefix + utils.CGRAccount
	DESTINATION              = varPrefix + utils.CGRDestination
	REQTYPE                  = varPrefix + utils.CGRReqType //prepaid or postpaid
	CATEGORY                 = varPrefix + utils.CGRCategory
	VAR_CGR_ROUTE            = varPrefix + utils.CGRRoute
	UUID                     = "Unique-ID" // -Unique ID for this call leg
	CSTMID                   = varPrefix + utils.CGRTenant
	CALL_DEST_NR             = "Caller-Destination-Number"
	SIP_REQ_USER             = "variable_sip_req_user"
	PARK_TIME                = "Caller-Profile-Created-Time"
	SETUP_TIME               = "Caller-Channel-Created-Time"
	ANSWER_TIME              = "Caller-Channel-Answered-Time"
	END_TIME                 = "Caller-Channel-Hangup-Time"
	DURATION                 = "variable_billsec"
	NAME                     = "Event-Name"
	HEARTBEAT                = "HEARTBEAT"
	ANSWER                   = "CHANNEL_ANSWER"
	HANGUP                   = "CHANNEL_HANGUP_COMPLETE"
	PARK                     = "CHANNEL_PARK"
	AUTH_OK                  = "AUTH_OK"
	DISCONNECT               = "SWITCH DISCONNECT"
	MANAGER_REQUEST          = "MANAGER_REQUEST"
	USERNAME                 = "Caller-Username"
	FS_IPv4                  = "FreeSWITCH-IPv4"
	HANGUP_CAUSE             = "Hangup-Cause"
	PDD_MEDIA_MS             = "variable_progress_mediamsec"
	PDD_NOMEDIA_MS           = "variable_progressmsec"
	IGNOREPARK               = "variable_cgr_ignorepark"
	FS_VARPREFIX             = "variable_"
	VarCGRFlags              = varPrefix + utils.CGRFlags
	VarCGROpts               = varPrefix + utils.CGROpts
	CGRResourceAllocation    = "cgr_resource_allocation"
	VAR_CGR_DISCONNECT_CAUSE = varPrefix + utils.CGRDisconnectCause
	VAR_CGR_CMPUTELCR        = varPrefix + utils.CGRComputeLCR
	FsConnID                 = "FsConnID" // used to share connID info in event for remote disconnects
	VarAnswerEpoch           = "variable_answer_epoch"
	VarCGRACD                = varPrefix + utils.CgrAcd
	VarCGROriginHost         = varPrefix + utils.CGROriginHost
	VarCGRMaxUsage           = "cgr_max_usage"
)
View Source
const (
	EVENT                  = "event"
	CGR_AUTH_REQUEST       = "CGR_AUTH_REQUEST"
	CGR_AUTH_REPLY         = "CGR_AUTH_REPLY"
	CGR_SESSION_DISCONNECT = "CGR_SESSION_DISCONNECT"
	CGR_CALL_START         = "CGR_CALL_START"
	CGR_CALL_END           = "CGR_CALL_END"
	CGR_PROCESS_MESSAGE    = "CGR_PROCESS_MESSAGE"
	CGR_PROCESS_CDR        = "CGR_PROCESS_CDR"
	KamTRIndex             = "tr_index"
	KamTRLabel             = "tr_label"
	KamHashEntry           = "h_entry"
	KamHashID              = "h_id"
	KamReplyRoute          = "reply_route"
	EvapiConnID            = "EvapiConnID" // used to share connID info in event for remote disconnects
	CGR_DLG_LIST           = "CGR_DLG_LIST"
)
View Source
const (
	MetaRadReqType     = "*radReqType"
	MetaRadAuth        = "*radAuth"
	MetaRadAccount     = "*radAccount"
	MetaRadReqCode     = "*radReqCode"
	MetaRadReplyCode   = "*radReplyCode"
	UserPasswordAVP    = "User-Password"
	CHAPPasswordAVP    = "CHAP-Password"
	CHAPChallengeAVP   = "CHAP-Challenge"
	MSCHAPChallengeAVP = "MS-CHAP-Challenge"
	MSCHAP2ResponseAVP = "MS-CHAP2-Response"
	MicrosoftVendor    = "Microsoft"
	MSCHAP2SuccessAVP  = "MS-CHAP2-Success"
)
View Source
const (
	SSN = 8388636 // Spending Status Notification Command Code
)

Variables

This section is empty.

Functions

func SliceAsFsArray

func SliceAsFsArray(slc []string) (arry string)

SliceAsFsArray Converts a slice of strings into a FS array string, contains len(array) at first index since FS does not support len(ARRAY::) for now

Types

type ARIConnector added in v0.10.5

type ARIConnector interface {
	Call(method, uri string, queryStr map[string]string, body []byte) (aringo.RESTResponse, error)
}

ARIConnector abstracts the transport layer (HTTP or WebSocket) for sending ARI commands.

type AgentRequest

type AgentRequest struct {
	Request    utils.DataProvider         // request
	Vars       *utils.DataNode            // shared data
	CGRRequest *utils.OrderedNavigableMap // Used in reply to access the request that was send
	CGRReply   *utils.DataNode
	Reply      *utils.OrderedNavigableMap
	Tenant     string
	Timezone   string

	Opts    utils.MapStorage
	Cfg     utils.DataProvider
	ExtraDP map[string]utils.DataProvider
	// contains filtered or unexported fields
}

AgentRequest represents data related to one request towards agent implements utils.DataProvider so we can pass it to filters

func NewAgentRequest

func NewAgentRequest(req utils.DataProvider,
	vars, cgrRply *utils.DataNode,
	rply *utils.OrderedNavigableMap,
	opts utils.MapStorage,
	tntTpl config.RSRParsers,
	dfltTenant, timezone string,
	filterS *engine.FilterS,
	extraDP map[string]utils.DataProvider) (ar *AgentRequest)

NewAgentRequest returns a new AgentRequest

func (*AgentRequest) Append added in v0.11.0

func (ar *AgentRequest) Append(fullPath *utils.FullPath, val *utils.DataLeaf) (err error)

Append sets the value at the given path this used with full path and the processed path to not calculate them for every set

func (*AgentRequest) Compose added in v0.11.0

func (ar *AgentRequest) Compose(fullPath *utils.FullPath, val *utils.DataLeaf) (err error)

Set sets the value at the given path this used with full path and the processed path to not calculate them for every set

func (*AgentRequest) FieldAsInterface

func (ar *AgentRequest) FieldAsInterface(fldPath []string) (val any, err error)

FieldAsInterface implements utils.DataProvider

func (*AgentRequest) FieldAsString

func (ar *AgentRequest) FieldAsString(fldPath []string) (val string, err error)

FieldAsString implements utils.DataProvider

func (*AgentRequest) ParseField

func (ar *AgentRequest) ParseField(
	cfgFld *config.FCTemplate) (out any, err error)

ParseField outputs the value based on the template item

func (*AgentRequest) Remove added in v0.10.1

func (ar *AgentRequest) Remove(fullPath *utils.FullPath) error

Remove deletes the fields found at path with the given prefix

func (*AgentRequest) RemoveAll added in v0.10.1

func (ar *AgentRequest) RemoveAll(prefix string) error

RemoveAll deletes all fields at given prefix

func (*AgentRequest) SetAsSlice added in v0.11.0

func (ar *AgentRequest) SetAsSlice(fullPath *utils.FullPath, nm *utils.DataLeaf) error

Set implements utils.NMInterface

func (*AgentRequest) SetFields

func (ar *AgentRequest) SetFields(tplFlds []*config.FCTemplate) (err error)

SetFields will populate fields of AgentRequest out of templates

func (*AgentRequest) String

func (ar *AgentRequest) String() string

String implements utils.DataProvider

type AsteriskAgent

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

AsteriskAgent used to cominicate with asterisk

func NewAsteriskAgent

func NewAsteriskAgent(cgrCfg *config.CGRConfig, astConnIdx int,
	connMgr *engine.ConnManager, caps *engine.Caps) (*AsteriskAgent, error)

NewAsteriskAgent constructs a new Asterisk Agent

func (*AsteriskAgent) ListenAndServe

func (sma *AsteriskAgent) ListenAndServe(stopChan <-chan struct{}) (err error)

ListenAndServe is called to start the service

func (*AsteriskAgent) V1AlterSession added in v0.11.0

func (*AsteriskAgent) V1AlterSession(*context.Context, utils.CGREvent, *string) error

V1AlterSession is used to implement the sessions.BiRPClient interface

func (*AsteriskAgent) V1DisconnectPeer added in v0.11.0

func (*AsteriskAgent) V1DisconnectPeer(*context.Context, *utils.DPRArgs, *string) error

V1DisconnectPeer is used to implement the sessions.BiRPClient interface

func (*AsteriskAgent) V1DisconnectSession

func (sma *AsteriskAgent) V1DisconnectSession(ctx *context.Context, cgrEv utils.CGREvent, reply *string) error

V1DisconnectSession is internal method to disconnect session in asterisk

func (*AsteriskAgent) V1GetActiveSessionIDs

func (sma *AsteriskAgent) V1GetActiveSessionIDs(ctx *context.Context, ignParam string,
	sessionIDs *[]*sessions.SessionID) error

V1GetActiveSessionIDs is internal method to get all active sessions in asterisk

func (*AsteriskAgent) V1SpendingStatusNotification added in v0.11.0

func (sma *AsteriskAgent) V1SpendingStatusNotification(*context.Context, *utils.CGREvent, *string) error

V1SpendingStatusNotification is used to implement the sessions.BiRPClient interface

func (*AsteriskAgent) V1WarnDisconnect added in v0.11.0

func (sma *AsteriskAgent) V1WarnDisconnect(*context.Context, map[string]any, *string) error

V1WarnDisconnect is used to implement the sessions.BiRPClient interface

type DNSAgent

type DNSAgent struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

DNSAgent translates DNS requests towards CGRateS infrastructure

func NewDNSAgent

func NewDNSAgent(cgrCfg *config.CGRConfig, fltrS *engine.FilterS,
	connMgr *engine.ConnManager, caps *engine.Caps) (da *DNSAgent, err error)

NewDNSAgent is the constructor for DNSAgent

func (*DNSAgent) ListenAndServe

func (da *DNSAgent) ListenAndServe(stopChan chan struct{}) error

ListenAndServe will run the DNS handler doing also the connection to listen address

func (*DNSAgent) Reload

func (da *DNSAgent) Reload() (err error)

Reload will reinitialize the server this is in order to monitor if we receive error on ListenAndServe

func (*DNSAgent) Shutdown

func (da *DNSAgent) Shutdown() error

Shutdown stops the DNS server

type DiameterAgent

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

DiameterAgent describes the diameter server

func NewDiameterAgent

func NewDiameterAgent(cgrCfg *config.CGRConfig, filterS *engine.FilterS,
	connMgr *engine.ConnManager, caps *engine.Caps) (*DiameterAgent, error)

NewDiameterAgent initializes a new DiameterAgent

func (*DiameterAgent) ListenAndServe

func (da *DiameterAgent) ListenAndServe(stopChan <-chan struct{}) (err error)

ListenAndServe is called when DiameterAgent is started, usually from within cmd/cgr-engine

func (*DiameterAgent) V1AlterSession added in v0.11.0

func (da *DiameterAgent) V1AlterSession(ctx *context.Context, cgrEv utils.CGREvent, reply *string) (err error)

V1AlterSession sends a rar message to diameter client

func (*DiameterAgent) V1DisconnectPeer added in v0.11.0

func (da *DiameterAgent) V1DisconnectPeer(ctx *context.Context, args *utils.DPRArgs, reply *string) (err error)

V1DisconnectPeer sends a DPR message to diameter client. Looks up connection by RemoteAddr if provided, otherwise by OriginHost+OriginRealm.

func (*DiameterAgent) V1DisconnectSession

func (da *DiameterAgent) V1DisconnectSession(ctx *context.Context, cgrEv utils.CGREvent, reply *string) (err error)

V1DisconnectSession is part of the sessions.BiRPClient

func (*DiameterAgent) V1GetActiveSessionIDs

func (da *DiameterAgent) V1GetActiveSessionIDs(*context.Context, string,
	*[]*sessions.SessionID) error

V1GetActiveSessionIDs is part of the sessions.BiRPClient

func (*DiameterAgent) V1SpendingStatusNotification added in v0.11.0

func (da *DiameterAgent) V1SpendingStatusNotification(ctx *context.Context, cgrEv *utils.CGREvent, reply *string) (err error)

V1SpendingStatusNotification creates and sends SNR to diameter agent

func (*DiameterAgent) V1WarnDisconnect added in v0.11.0

func (*DiameterAgent) V1WarnDisconnect(*context.Context, map[string]any, *string) error

V1WarnDisconnect is used to implement the sessions.BiRPClient interface

type DiameterClient

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

func NewDiameterClient

func NewDiameterClient(addr, originHost, originRealm string, vendorId int, productName string,
	firmwareRev int, dictsDir string, network string) (dc *DiameterClient, err error)

func (*DiameterClient) Close added in v0.11.0

func (dc *DiameterClient) Close() error

Close disconnects the DiameterClient. Implements io.Closer.

func (*DiameterClient) ReceivedMessage

func (dc *DiameterClient) ReceivedMessage(rplyTimeout time.Duration) *diam.Message

Returns the message out of received buffer

func (*DiameterClient) SendMessage

func (dc *DiameterClient) SendMessage(m *diam.Message) error

type FSEvent

type FSEvent map[string]string

Event type holding a mapping of all event's proprieties

func NewFSEvent

func NewFSEvent(strEv string) (fsev FSEvent)

func (FSEvent) AsCGREvent

func (fsev FSEvent) AsCGREvent(timezone string) (cgrEv *utils.CGREvent, err error)

AsCGREvent converts FSEvent into CGREvent

func (FSEvent) AsMapStringInterface

func (fsev FSEvent) AsMapStringInterface(timezone string) map[string]any

Used with RLs

func (FSEvent) GetADC

func (fsev FSEvent) GetADC(fieldName string) (time.Duration, error)

func (FSEvent) GetAccount

func (fsev FSEvent) GetAccount(fieldName string) string

Account calling

func (FSEvent) GetAnswerTime

func (fsev FSEvent) GetAnswerTime(fieldName, timezone string) (t time.Time, err error)

func (FSEvent) GetCallDestNr

func (fsev FSEvent) GetCallDestNr(fieldName string) string

Original dialed destination number, useful in case of unpark

func (FSEvent) GetCategory

func (fsev FSEvent) GetCategory(fieldName string) string

func (FSEvent) GetDestination

func (fsev FSEvent) GetDestination(fieldName string) string

Charging destination number

func (FSEvent) GetDisconnectCause

func (fsev FSEvent) GetDisconnectCause(fieldName string) string

func (FSEvent) GetDuration

func (fsev FSEvent) GetDuration(fieldName string) (time.Duration, error)

func (FSEvent) GetEndTime

func (fsev FSEvent) GetEndTime(fieldName, timezone string) (t time.Time, err error)

func (FSEvent) GetExtraFields

func (fsev FSEvent) GetExtraFields() map[string]string

func (FSEvent) GetName

func (fsev FSEvent) GetName() string

func (FSEvent) GetOptions added in v0.11.0

func (fsev FSEvent) GetOptions() (mp map[string]any)

GetOptions returns the possible options

func (FSEvent) GetOriginHost

func (fsev FSEvent) GetOriginHost() string

GetOriginHost returns the first non empty between: fsev[VarCGROriginHost], conns[connId].cfg.Alias and fsev[FS_IPv4]

func (FSEvent) GetOriginatorIP

func (fsev FSEvent) GetOriginatorIP(fieldName string) string

func (FSEvent) GetPdd

func (fsev FSEvent) GetPdd(fieldName string) (time.Duration, error)

func (FSEvent) GetReqType

func (fsev FSEvent) GetReqType(fieldName string) string

func (FSEvent) GetRoute added in v0.11.0

func (fsev FSEvent) GetRoute(fieldName string) string

func (FSEvent) GetSessionIds

func (fsev FSEvent) GetSessionIds() []string

func (FSEvent) GetSetupTime

func (fsev FSEvent) GetSetupTime(fieldName, timezone string) (t time.Time, err error)

func (FSEvent) GetSubject

func (fsev FSEvent) GetSubject(fieldName string) string

Rating subject being charged

func (FSEvent) GetTenant

func (fsev FSEvent) GetTenant(fieldName string) string

func (FSEvent) GetUUID

func (fsev FSEvent) GetUUID() string

func (FSEvent) MissingParameter

func (fsev FSEvent) MissingParameter(timezone string) string

func (FSEvent) ParseEventValue

func (fsev FSEvent) ParseEventValue(attrName string, rsrFld *config.RSRParser, timezone string) (parsed string, err error)

Used in derived charging and sittuations when we need to run regexp on fields

func (FSEvent) String

func (fsev FSEvent) String() (result string)

Nice printing for the event object.

func (FSEvent) V1AuthorizeArgs

func (fsev FSEvent) V1AuthorizeArgs() (args *sessions.V1AuthorizeArgs)

V1AuthorizeArgs returns the arguments used in SMGv1.Authorize

func (FSEvent) V1InitSessionArgs

func (fsev FSEvent) V1InitSessionArgs() (args *sessions.V1InitSessionArgs)

V1InitSessionArgs returns the arguments used in SessionSv1.InitSession

func (FSEvent) V1TerminateSessionArgs

func (fsev FSEvent) V1TerminateSessionArgs() (args *sessions.V1TerminateSessionArgs)

V1TerminateSessionArgs returns the arguments used in SMGv1.TerminateSession

type FSsessions

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

FSsessions is the freeswitch session manager it holds a buffer for the network connection and the active sessions

func NewFSsessions

func NewFSsessions(fsAgentConfig *config.FsAgentCfg,
	timezone string, connMgr *engine.ConnManager, caps *engine.Caps) (*FSsessions, error)

func (*FSsessions) Connect

func (fsa *FSsessions) Connect() error

Connect connects to the freeswitch mod_event_socket server and starts listening for events.

func (*FSsessions) Reload

func (fsa *FSsessions) Reload()

Reload recreates the connection buffers only used on reload

func (*FSsessions) Shutdown

func (fsa *FSsessions) Shutdown() (err error)

Shutdown stops all connected fsock connections

func (*FSsessions) V1AlterSession added in v0.11.0

func (*FSsessions) V1AlterSession(*context.Context, utils.CGREvent, *string) error

V1AlterSession is used to implement the sessions.BiRPClient interface

func (*FSsessions) V1DisconnectPeer added in v0.11.0

func (*FSsessions) V1DisconnectPeer(*context.Context, *utils.DPRArgs, *string) error

V1DisconnectPeer is used to implement the sessions.BiRPClient interface

func (*FSsessions) V1DisconnectSession

func (fsa *FSsessions) V1DisconnectSession(ctx *context.Context, cgrEv utils.CGREvent, reply *string) (err error)

V1DisconnectSession internal method to disconnect session in FreeSWITCH

func (*FSsessions) V1GetActiveSessionIDs

func (fsa *FSsessions) V1GetActiveSessionIDs(ctx *context.Context, _ string,
	sessionIDs *[]*sessions.SessionID) (err error)

V1GetActiveSessionIDs used to return all active sessions

func (*FSsessions) V1SpendingStatusNotification added in v0.11.0

func (*FSsessions) V1SpendingStatusNotification(*context.Context, *utils.CGREvent, *string) error

V1SpendingStatusNotification is used to implement the sessions.BiRPClient interface

func (*FSsessions) V1WarnDisconnect added in v0.11.0

func (fsa *FSsessions) V1WarnDisconnect(ctx *context.Context, args map[string]any, reply *string) (err error)

V1WarnDisconnect is called when call goes under the minimum duration threshold, so FreeSWITCH can play an announcement message

type HTTPAgent

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

HTTPAgent is a handler for HTTP requests

func NewHTTPAgent

func NewHTTPAgent(connMgr *engine.ConnManager,
	sessionConns, statsConns, thresholdsConns []string,
	filterS *engine.FilterS, dfltTenant, reqPayload, rplyPayload string,
	reqProcessors []*config.RequestProcessor, caps *engine.Caps) *HTTPAgent

NewHttpAgent will construct a HTTPAgent

func (*HTTPAgent) ServeHTTP

func (ha *HTTPAgent) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler interface

type JanusAgent added in v0.11.0

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

JanusAgent is a gateway between HTTP and Janus Server over Websocket

func NewJanusAgent added in v0.11.0

func NewJanusAgent(cgrCfg *config.CGRConfig,
	connMgr *engine.ConnManager,
	filterS *engine.FilterS, caps *engine.Caps) (*JanusAgent, error)

NewJanusAgent will construct a JanusAgent

func (*JanusAgent) AttachPlugin added in v0.11.0

func (ja *JanusAgent) AttachPlugin(w http.ResponseWriter, r *http.Request)

AttachPlugin will attach a plugin to a session

func (*JanusAgent) CORSOptions added in v0.11.0

func (ja *JanusAgent) CORSOptions(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler interface

func (*JanusAgent) Connect added in v0.11.0

func (ja *JanusAgent) Connect() (err error)

Connect will create the connection to the Janus Server

func (*JanusAgent) CreateSession added in v0.11.0

func (ja *JanusAgent) CreateSession(w http.ResponseWriter, req *http.Request)

CreateSession will create a new session within janusgo

func (*JanusAgent) HandlePlugin added in v0.11.0

func (ja *JanusAgent) HandlePlugin(w http.ResponseWriter, r *http.Request)

HandlePlugin will handle requests towards a plugin

func (*JanusAgent) PollSession added in v0.11.0

func (ja *JanusAgent) PollSession(w http.ResponseWriter, req *http.Request)

PollSession will create a long-poll request to be notified about events and incoming messages from session

func (*JanusAgent) SessionKeepalive added in v0.11.0

func (ja *JanusAgent) SessionKeepalive(w http.ResponseWriter, r *http.Request)

SessioNKeepalive sends keepalive once OPTIONS are coming for the session from HTTP

func (*JanusAgent) Shutdown added in v0.11.0

func (ja *JanusAgent) Shutdown() (err error)

Shutdown will close the connection to the Janus Server

func (*JanusAgent) V1AlterSession added in v0.11.0

func (ja *JanusAgent) V1AlterSession(*context.Context, utils.CGREvent, *string) error

func (*JanusAgent) V1DisconnectPeer added in v0.11.0

func (ja *JanusAgent) V1DisconnectPeer(*context.Context, *utils.DPRArgs, *string) error

func (*JanusAgent) V1DisconnectSession added in v0.11.0

func (ja *JanusAgent) V1DisconnectSession(ctx *context.Context, cgrEv utils.CGREvent, reply *string) (err error)

func (*JanusAgent) V1GetActiveSessionIDs added in v0.11.0

func (ja *JanusAgent) V1GetActiveSessionIDs(ctx *context.Context, ignParam string,
	sessionIDs *[]*sessions.SessionID) error

func (*JanusAgent) V1SpendingStatusNotification added in v0.11.0

func (ja *JanusAgent) V1SpendingStatusNotification(*context.Context, *utils.CGREvent, *string) error

V1SpendingStatusNotification is used to implement the sessions.BiRPClient interface

func (*JanusAgent) V1WarnDisconnect added in v0.11.0

func (ja *JanusAgent) V1WarnDisconnect(*context.Context, map[string]any, *string) error

type KamEvent

type KamEvent map[string]string

KamEvent represents one event received from Kamailio

func NewKamEvent

func NewKamEvent(kamEvData []byte, alias, adress string) (KamEvent, error)

NewKamEvent parses bytes received over the wire from Kamailio into KamEvent

func (KamEvent) AsCGREvent

func (kev KamEvent) AsCGREvent(timezone string) (cgrEv *utils.CGREvent, err error)

AsCGREvent converts KamEvent into CGREvent

func (KamEvent) AsKamAuthReply

func (kev KamEvent) AsKamAuthReply(authArgs *sessions.V1AuthorizeArgs,
	authReply *sessions.V1AuthorizeReply, rplyErr error) (kar *KamReply, err error)

AsKamAuthReply builds up a Kamailio AuthReply based on arguments and reply from SessionS

func (KamEvent) AsKamProcessCDRReply

func (kev KamEvent) AsKamProcessCDRReply(cgrEvWithArgDisp *utils.CGREvent,
	rply *string, rplyErr error) (kar *KamReply, err error)

AsKamProcessCDRReply builds up a Kamailio ProcessEvent based on arguments and reply from SessionS

func (KamEvent) AsKamProcessMessageEmptyReply

func (kev KamEvent) AsKamProcessMessageEmptyReply() (kar *KamReply)

AsKamProcessMessageEmptyReply builds up a Kamailio ProcessEventEmpty

func (KamEvent) AsKamProcessMessageReply

func (kev KamEvent) AsKamProcessMessageReply(procEvArgs *sessions.V1ProcessMessageArgs,
	procEvReply *sessions.V1ProcessMessageReply, rplyErr error) (kar *KamReply, err error)

AsKamProcessMessageReply builds up a Kamailio ProcessEvent based on arguments and reply from SessionS

func (KamEvent) AsMapStringInterface

func (kev KamEvent) AsMapStringInterface() (mp map[string]any)

AsMapStringInterface converts KamEvent into event used by other subsystems

func (KamEvent) GetOptions added in v0.11.0

func (kev KamEvent) GetOptions() (mp map[string]any)

GetOptions returns the posible options

func (KamEvent) MissingParameter

func (kev KamEvent) MissingParameter() bool

func (KamEvent) String

func (kev KamEvent) String() string

String is used for pretty printing event in logs

func (KamEvent) V1AuthorizeArgs

func (kev KamEvent) V1AuthorizeArgs() (args *sessions.V1AuthorizeArgs)

V1AuthorizeArgs returns the arguments used in SessionSv1.AuthorizeEvent

func (KamEvent) V1InitSessionArgs

func (kev KamEvent) V1InitSessionArgs() (args *sessions.V1InitSessionArgs)

V1InitSessionArgs returns the arguments used in SessionSv1.InitSession

func (KamEvent) V1ProcessCDRArgs

func (kev KamEvent) V1ProcessCDRArgs() (args *utils.CGREvent)

V1ProcessCDRArgs returns the arguments used in SessionSv1.ProcessCDR

func (KamEvent) V1ProcessMessageArgs

func (kev KamEvent) V1ProcessMessageArgs() (args *sessions.V1ProcessMessageArgs)

V1ProcessMessageArgs returns the arguments used in SessionSv1.ProcessMessage

func (KamEvent) V1TerminateSessionArgs

func (kev KamEvent) V1TerminateSessionArgs() (args *sessions.V1TerminateSessionArgs)

V1TerminateSessionArgs returns the arguments used in SMGv1.TerminateSession

type KamReply

type KamReply struct {
	Event              string // Kamailio will use this to differentiate between requests and replies
	TransactionIndex   string // Original transaction index
	TransactionLabel   string // Original transaction label
	Attributes         string
	ResourceAllocation string
	MaxUsage           int    // Maximum session time in case of success, -1 for unlimited
	Routes             string // List of routes, comma separated
	Thresholds         string
	StatQueues         string
	Error              string // Reply in case of error
}

KamReply will be used to send back to kamailio from Authrization,ProcessEvent and ProcessEvent empty (pingPong)

func (*KamReply) String

func (krply *KamReply) String() string

type KamSessionDisconnect

type KamSessionDisconnect struct {
	Event     string
	HashEntry string
	HashId    string
	Reason    string
}

func NewKamSessionDisconnect

func NewKamSessionDisconnect(hEntry, hID, reason string) *KamSessionDisconnect

func (*KamSessionDisconnect) String

func (ksd *KamSessionDisconnect) String() string

type KamailioAgent

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

func NewKamailioAgent

func NewKamailioAgent(kaCfg *config.KamAgentCfg,
	connMgr *engine.ConnManager, timezone string, caps *engine.Caps) (*KamailioAgent, error)

func (*KamailioAgent) Connect

func (self *KamailioAgent) Connect() (err error)

func (*KamailioAgent) Reload

func (ka *KamailioAgent) Reload()

Reload recreates the connection buffers only used on reload

func (*KamailioAgent) Shutdown

func (self *KamailioAgent) Shutdown() (err error)

func (*KamailioAgent) V1AlterSession added in v0.11.0

func (*KamailioAgent) V1AlterSession(*context.Context, utils.CGREvent, *string) error

V1AlterSession is used to implement the sessions.BiRPClient interface

func (*KamailioAgent) V1DisconnectPeer added in v0.11.0

func (*KamailioAgent) V1DisconnectPeer(*context.Context, *utils.DPRArgs, *string) error

V1DisconnectPeer is used to implement the sessions.BiRPClient interface

func (*KamailioAgent) V1DisconnectSession

func (ka *KamailioAgent) V1DisconnectSession(ctx *context.Context, cgrEv utils.CGREvent, reply *string) (err error)

Internal method to disconnect session in Kamailio

func (*KamailioAgent) V1GetActiveSessionIDs

func (ka *KamailioAgent) V1GetActiveSessionIDs(ctx *context.Context, ignParam string, sessionIDs *[]*sessions.SessionID) error

V1GetActiveSessionIDs returns a list of CGRIDs based on active sessions from agent

func (*KamailioAgent) V1SpendingStatusNotification added in v0.11.0

func (*KamailioAgent) V1SpendingStatusNotification(*context.Context, *utils.CGREvent, *string) error

V1SpendingStatusNotification is used to implement the sessions.BiRPClient interface

func (*KamailioAgent) V1WarnDisconnect added in v0.11.0

func (*KamailioAgent) V1WarnDisconnect(*context.Context, map[string]any, *string) error

V1WarnDisconnect is used to implement the sessions.BiRPClient interface

type PrometheusAgent added in v0.11.0

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

PrometheusAgent handles metrics collection for Prometheus. It collects stats from StatQueues and exposes them alongside optional Go runtime and process metrics.

func NewPrometheusAgent added in v0.11.0

func NewPrometheusAgent(cfg *config.CGRConfig, cm *engine.ConnManager) *PrometheusAgent

NewPrometheusAgent creates and initializes a PrometheusAgent with pre-registered metrics based on the provided configuration.

func (*PrometheusAgent) ServeHTTP added in v0.11.0

func (pa *PrometheusAgent) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler interface. It updates all metrics on each scrape request before exposing them via the Prometheus HTTP handler.

type RadiusAgent

type RadiusAgent struct {
	sync.RWMutex

	sync.WaitGroup
	// contains filtered or unexported fields
}

func NewRadiusAgent

func NewRadiusAgent(cgrCfg *config.CGRConfig, filterS *engine.FilterS, connMgr *engine.ConnManager,
	caps *engine.Caps) (*RadiusAgent, error)

func (*RadiusAgent) ListenAndServe

func (ra *RadiusAgent) ListenAndServe(stopChan <-chan struct{}) (err error)

func (*RadiusAgent) V1AlterSession added in v0.11.0

func (ra *RadiusAgent) V1AlterSession(_ *context.Context, cgrEv utils.CGREvent, reply *string) error

V1AlterSession updates session authorization using RADIUS CoA functionality.

func (*RadiusAgent) V1DisconnectPeer added in v0.11.0

func (*RadiusAgent) V1DisconnectPeer(_ *context.Context, _ *utils.DPRArgs, _ *string) error

V1DisconnectPeer is needed to satisfy the sessions.BiRPClient interface

func (*RadiusAgent) V1DisconnectSession added in v0.11.0

func (ra *RadiusAgent) V1DisconnectSession(_ *context.Context, cgrEv utils.CGREvent, reply *string) error

V1DisconnectSession remotely disconnects a session by making use of the RADIUS Disconnect Message functionality.

func (*RadiusAgent) V1GetActiveSessionIDs added in v0.11.0

func (*RadiusAgent) V1GetActiveSessionIDs(_ *context.Context, _ string, _ *[]*sessions.SessionID) error

V1GetActiveSessionIDs is needed to satisfy the sessions.BiRPClient interface

func (*RadiusAgent) V1SpendingStatusNotification added in v0.11.0

func (*RadiusAgent) V1SpendingStatusNotification(*context.Context, *utils.CGREvent, *string) error

V1SpendingStatusNotification is used to implement the sessions.BiRPClient interface

func (*RadiusAgent) V1WarnDisconnect added in v0.11.0

func (*RadiusAgent) V1WarnDisconnect(_ *context.Context, _ map[string]any, _ *string) error

V1WarnDisconnect is needed to satisfy the sessions.BiRPClient interface

type SIPAgent added in v0.11.0

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

SIPAgent is a handler for SIP requests

func NewSIPAgent added in v0.11.0

func NewSIPAgent(connMgr *engine.ConnManager, cfg *config.CGRConfig,
	filterS *engine.FilterS, caps *engine.Caps) (sa *SIPAgent, err error)

NewSIPAgent will construct a SIPAgent

func (*SIPAgent) InitStopChan added in v0.11.0

func (sa *SIPAgent) InitStopChan()

func (*SIPAgent) ListenAndServe added in v0.11.0

func (sa *SIPAgent) ListenAndServe() (err error)

ListenAndServe will run the SIP handler doing also the connection to listen address

func (*SIPAgent) Shutdown added in v0.11.0

func (sa *SIPAgent) Shutdown()

Shutdown will stop the SIPAgent server

type SMAsteriskEvent

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

func NewSMAsteriskEvent

func NewSMAsteriskEvent(ariEv map[string]any, asteriskIP, asteriskAlias string) *SMAsteriskEvent

func (*SMAsteriskEvent) Account

func (smaEv *SMAsteriskEvent) Account() string

func (*SMAsteriskEvent) AsCGREvent

func (smaEv *SMAsteriskEvent) AsCGREvent(timezone string) (cgrEv *utils.CGREvent, err error)

AsCGREvent converts AsteriskEvent into CGREvent

func (*SMAsteriskEvent) AsMapStringInterface

func (smaEv *SMAsteriskEvent) AsMapStringInterface() (mp map[string]any)

func (*SMAsteriskEvent) Category

func (smaEv *SMAsteriskEvent) Category() string

func (*SMAsteriskEvent) ChannelID

func (smaEv *SMAsteriskEvent) ChannelID() string

func (*SMAsteriskEvent) ChannelState

func (smaEv *SMAsteriskEvent) ChannelState() string

func (*SMAsteriskEvent) Clone added in v0.11.0

func (e *SMAsteriskEvent) Clone() *SMAsteriskEvent

Clone returns a deep copy of SMAsteriskEvent.

func (*SMAsteriskEvent) Destination

func (smaEv *SMAsteriskEvent) Destination() string

func (*SMAsteriskEvent) DisconnectCause

func (smaEv *SMAsteriskEvent) DisconnectCause() string

func (*SMAsteriskEvent) EventType

func (smaEv *SMAsteriskEvent) EventType() string

func (*SMAsteriskEvent) ExtraParameters

func (smaEv *SMAsteriskEvent) ExtraParameters() (extraParams map[string]string)

func (*SMAsteriskEvent) IsCGRChannel added in v0.11.0

func (smaEv *SMAsteriskEvent) IsCGRChannel() bool

IsCGRChannel checks whether the channel belongs to a CGRateS-managed session

func (*SMAsteriskEvent) OriginHost

func (smaEv *SMAsteriskEvent) OriginHost() string

func (*SMAsteriskEvent) OriginatorIP

func (smaEv *SMAsteriskEvent) OriginatorIP() string

func (*SMAsteriskEvent) PDD

func (smaEv *SMAsteriskEvent) PDD() string

func (*SMAsteriskEvent) RequestType

func (smaEv *SMAsteriskEvent) RequestType() string

func (*SMAsteriskEvent) RestoreAndUpdateFields added in v0.11.0

func (smaEv *SMAsteriskEvent) RestoreAndUpdateFields(cgrEv *utils.CGREvent) error

func (*SMAsteriskEvent) Route added in v0.11.0

func (smaEv *SMAsteriskEvent) Route() string

func (*SMAsteriskEvent) SetupTime

func (smaEv *SMAsteriskEvent) SetupTime() string

func (*SMAsteriskEvent) Subject

func (smaEv *SMAsteriskEvent) Subject() string

func (*SMAsteriskEvent) Subsystems

func (smaEv *SMAsteriskEvent) Subsystems() string

func (*SMAsteriskEvent) Tenant

func (smaEv *SMAsteriskEvent) Tenant() string

func (*SMAsteriskEvent) Timestamp

func (smaEv *SMAsteriskEvent) Timestamp() string

func (*SMAsteriskEvent) V1AuthorizeArgs

func (smaEv *SMAsteriskEvent) V1AuthorizeArgs() (args *sessions.V1AuthorizeArgs)

func (*SMAsteriskEvent) V1InitSessionArgs

func (smaEv *SMAsteriskEvent) V1InitSessionArgs(cgrEvDisp utils.CGREvent) (args *sessions.V1InitSessionArgs)

func (*SMAsteriskEvent) V1TerminateSessionArgs

func (smaEv *SMAsteriskEvent) V1TerminateSessionArgs(cgrEvDisp utils.CGREvent) (args *sessions.V1TerminateSessionArgs)

Jump to

Keyboard shortcuts

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