replaced sched_hangup with sched_transfer

This commit is contained in:
gezimbll
2025-08-06 16:56:44 +02:00
committed by Dan Christian Bogos
parent e194979b99
commit c233daef58
20 changed files with 536 additions and 13 deletions

View File

@@ -732,6 +732,7 @@ const CGRATES_CFG_JSON = `
"max_wait_connection": "2s", // maximum duration to wait for a connection to be retrieved from the pool
"active_session_delimiter": ",", // delimiter for 'show channels' responses and requests
"route_profile": false, // attaches RouteProfileID to RouteIDs which are sent as reply to freeswitch agent authorization requests
"sched_transfer_extension": "CGRateS", // prepaid calls will be transferred to this extension in authorization
"event_socket_conns":[ // instantiate connections to multiple FreeSWITCH servers
{
"address": "127.0.0.1:8021", // FreeSWITCH server address and port

View File

@@ -746,6 +746,7 @@ func testCGRConfigReloadFreeswitchAgent(t *testing.T) {
ExtraFields: RSRParsers{},
MaxWaitConnection: 2 * time.Second,
ActiveSessionDelimiter: ",",
SchedTransferExtension: "CGRateS",
EventSocketConns: []*FsConnCfg{
{
Address: "1.2.3.4:8021",

View File

@@ -1001,6 +1001,7 @@ func TestFsAgentJsonCfg(t *testing.T) {
EmptyBalanceAnnFile: utils.StringPointer(""),
ActiveSessionDelimiter: utils.StringPointer(","),
MaxWaitConnection: utils.StringPointer("2s"),
SchedTransferExtension: utils.StringPointer("CGRateS"),
EventSocketConns: &[]*FsConnJsonCfg{
{
Address: utils.StringPointer("127.0.0.1:8021"),

File diff suppressed because one or more lines are too long

View File

@@ -453,6 +453,7 @@ type FreeswitchAgentJsonCfg struct {
ActiveSessionDelimiter *string `json:"active_session_delimiter"`
MaxWaitConnection *string `json:"max_wait_connection"`
RouteProfile *bool `json:"route_profile"`
SchedTransferExtension *string `json:"sched_transfer_extension"`
EventSocketConns *[]*FsConnJsonCfg `json:"event_socket_conns"`
}

View File

@@ -589,6 +589,7 @@ type FsAgentCfg struct {
ActiveSessionDelimiter string
MaxWaitConnection time.Duration
RouteProfile bool
SchedTransferExtension string
EventSocketConns []*FsConnCfg
}
@@ -643,6 +644,9 @@ func (fscfg *FsAgentCfg) loadFromJSONCfg(jsnCfg *FreeswitchAgentJsonCfg) error {
return err
}
}
if jsnCfg.SchedTransferExtension != nil {
fscfg.SchedTransferExtension = *jsnCfg.SchedTransferExtension
}
if jsnCfg.EventSocketConns != nil {
fscfg.EventSocketConns = make([]*FsConnCfg, len(*jsnCfg.EventSocketConns))
for idx, jsnConnCfg := range *jsnCfg.EventSocketConns {
@@ -664,6 +668,7 @@ func (fscfg *FsAgentCfg) AsMapInterface(separator string) (initialMP map[string]
utils.EmptyBalanceContextCfg: fscfg.EmptyBalanceContext,
utils.EmptyBalanceAnnFileCfg: fscfg.EmptyBalanceAnnFile,
utils.ActiveSessionDelimiterCfg: fscfg.ActiveSessionDelimiter,
utils.SchedTransferExtensionCfg: fscfg.SchedTransferExtension,
}
if fscfg.SessionSConns != nil {
sessionSConns := make([]string, len(fscfg.SessionSConns))
@@ -709,6 +714,7 @@ func (fscfg FsAgentCfg) Clone() (cln *FsAgentCfg) {
EmptyBalanceAnnFile: fscfg.EmptyBalanceAnnFile,
ActiveSessionDelimiter: fscfg.ActiveSessionDelimiter,
MaxWaitConnection: fscfg.MaxWaitConnection,
SchedTransferExtension: fscfg.SchedTransferExtension,
}
if fscfg.SessionSConns != nil {
cln.SessionSConns = make([]string, len(fscfg.SessionSConns))

View File

@@ -534,6 +534,7 @@ func TestFsAgentCfgloadFromJsonCfgCase1(t *testing.T) {
MaxWaitConnection: 2,
ExtraFields: RSRParsers{},
ActiveSessionDelimiter: ";",
SchedTransferExtension: "CGRateS",
EventSocketConns: []*FsConnCfg{
{
Address: "1.2.3.4:8021",
@@ -590,6 +591,7 @@ func TestFsAgentCfgAsMapInterfaceCase1(t *testing.T) {
utils.EmptyBalanceAnnFileCfg: "",
utils.ActiveSessionDelimiterCfg: ",",
utils.MaxWaitConnectionCfg: "2s",
utils.SchedTransferExtensionCfg: "CGRateS",
utils.EventSocketConnsCfg: []map[string]any{
{
utils.AddressCfg: "127.0.0.1:8021",
@@ -634,6 +636,7 @@ func TestFsAgentCfgAsMapInterfaceCase2(t *testing.T) {
utils.EmptyBalanceAnnFileCfg: "",
utils.MaxWaitConnectionCfg: "7s",
utils.ActiveSessionDelimiterCfg: "\tsep\t",
utils.SchedTransferExtensionCfg: "CGRateS",
utils.EventSocketConnsCfg: []map[string]any{
{
utils.AddressCfg: "127.0.0.1:8000",
@@ -673,6 +676,7 @@ func TestFsAgentCfgAsMapInterfaceCase3(t *testing.T) {
utils.EmptyBalanceAnnFileCfg: "",
utils.MaxWaitConnectionCfg: "",
utils.ActiveSessionDelimiterCfg: "\t",
utils.SchedTransferExtensionCfg: "CGRateS",
utils.EventSocketConnsCfg: []map[string]any{
{
utils.AddressCfg: "127.0.0.1:8021",