mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated SIP Agent integration tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
2161cda746
commit
84c6a0e498
@@ -45,7 +45,7 @@ func NewSIPAgent(connMgr *engine.ConnManager, cfg *config.CGRConfig,
|
||||
}
|
||||
}
|
||||
|
||||
// SIPAgent is a handler for HTTP requests
|
||||
// SIPAgent is a handler for SIP requests
|
||||
type SIPAgent struct {
|
||||
connMgr *engine.ConnManager
|
||||
filterS *engine.FilterS
|
||||
@@ -58,7 +58,7 @@ func (sa *SIPAgent) Shutdown() {
|
||||
close(sa.stopChan)
|
||||
}
|
||||
|
||||
// ListenAndServe will run the DNS handler doing also the connection to listen address
|
||||
// ListenAndServe will run the SIP handler doing also the connection to listen address
|
||||
func (sa *SIPAgent) ListenAndServe() (err error) {
|
||||
sa.stopChan = make(chan struct{})
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> start listening on <%s:%s>",
|
||||
@@ -295,7 +295,7 @@ func (sa *SIPAgent) processRequest(reqProcessor *config.RequestProcessor,
|
||||
}
|
||||
if reqProcessor.Flags.HasKey(utils.MetaLog) {
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> LOG, processorID: %s, http message: %s",
|
||||
fmt.Sprintf("<%s> LOG, processorID: %s, SIP message: %s",
|
||||
utils.SIPAgent, reqProcessor.ID, agReq.Request.String()))
|
||||
}
|
||||
switch reqType {
|
||||
@@ -446,12 +446,12 @@ func (sa *SIPAgent) processRequest(reqProcessor *config.RequestProcessor,
|
||||
}
|
||||
if reqProcessor.Flags.HasKey(utils.MetaLog) {
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> LOG, HTTP reply: %s",
|
||||
fmt.Sprintf("<%s> LOG, SIP reply: %s",
|
||||
utils.SIPAgent, agReq.Reply))
|
||||
}
|
||||
if reqType == utils.MetaDryRun {
|
||||
utils.Logger.Info(
|
||||
fmt.Sprintf("<%s> DRY_RUN, HTTP reply: %s",
|
||||
fmt.Sprintf("<%s> DRY_RUN, SIP reply: %s",
|
||||
utils.SIPAgent, agReq.Reply))
|
||||
}
|
||||
return true, nil
|
||||
|
||||
@@ -24,10 +24,11 @@ import (
|
||||
"net"
|
||||
"net/rpc"
|
||||
"path"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
v2 "github.com/cgrates/cgrates/apier/v2"
|
||||
v1 "github.com/cgrates/cgrates/apier/v1"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
@@ -47,9 +48,9 @@ var (
|
||||
testSAitResetStorDb,
|
||||
testSAitStartEngine,
|
||||
testSAitApierRpcConn,
|
||||
testSAitTPFromFolder,
|
||||
// testSAitTPFromFolder,
|
||||
|
||||
testSAitSetAttributeProfile,
|
||||
testSAitSetRouteProfile,
|
||||
testSAitSIPRegister,
|
||||
testSAitSIPInvite,
|
||||
|
||||
@@ -132,9 +133,6 @@ func testSAitTPFromFolder(t *testing.T) {
|
||||
if err := saRPC.Call(utils.APIerSv2LoadTariffPlanFromFolder, attrs, &loadInst); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if isDispatcherActive {
|
||||
testRadiusitTPLoadData(t)
|
||||
}
|
||||
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
|
||||
}
|
||||
|
||||
@@ -144,26 +142,42 @@ func testSAitStopCgrEngine(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testSAitSetAttributeProfile(t *testing.T) {
|
||||
attrPrf := &v2.AttributeWithCache{
|
||||
ExternalAttributeProfile: &engine.ExternalAttributeProfile{
|
||||
func testSAitSetRouteProfile(t *testing.T) {
|
||||
var reply *engine.RouteProfile
|
||||
splPrf := &v1.RouteWithCache{
|
||||
RouteProfile: &engine.RouteProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ChangeDestination",
|
||||
Contexts: []string{utils.ANY},
|
||||
ID: "SPL_ACNT_1001",
|
||||
FilterIDs: []string{"*string:~*req.Account:1001"},
|
||||
Attributes: []*engine.ExternalAttribute{{
|
||||
Path: utils.MetaReq + utils.NestingSep + "Destination",
|
||||
Value: "sip:1003@192.168.53.203:5060",
|
||||
}},
|
||||
Weight: 20,
|
||||
Sorting: utils.MetaWeight,
|
||||
Routes: []*engine.Route{
|
||||
{
|
||||
ID: "supplier1",
|
||||
Weight: 20,
|
||||
RouteParameters: "cgrates.org",
|
||||
},
|
||||
{
|
||||
ID: "supplier2",
|
||||
Weight: 10,
|
||||
RouteParameters: "cgrates.net",
|
||||
},
|
||||
},
|
||||
Weight: 10,
|
||||
},
|
||||
}
|
||||
|
||||
var result string
|
||||
if err := saRPC.Call(utils.APIerSv2SetAttributeProfile, attrPrf, &result); err != nil {
|
||||
if err := saRPC.Call(utils.APIerSv1SetRouteProfile, splPrf, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
}
|
||||
if err := saRPC.Call(utils.APIerSv1GetRouteProfile,
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "SPL_ACNT_1001"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(splPrf.RouteProfile, reply) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", splPrf.RouteProfile, reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testSAitSIPRegister(t *testing.T) {
|
||||
@@ -210,7 +224,7 @@ func testSAitSIPInvite(t *testing.T) {
|
||||
if expected := "SIP/2.0 302 Moved Temporarily"; recived["Request"] != expected {
|
||||
t.Errorf("Expected %q, received: %q", expected, recived["Request"])
|
||||
}
|
||||
if expected := "<sip:1003@192.168.53.203:5060>"; recived["Contact"] != expected {
|
||||
if expected := "\"1002\" <sip:1002@cgrates.org>;q=0.7; expires=3600,\"1002\" <sip:1002@cgrates.net>;q=0.1"; recived["Contact"] != expected {
|
||||
t.Errorf("Expected %q, received: %q", expected, recived["Contact"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,15 +118,15 @@ func (da *DiameterAgentCfg) loadFromJsonCfg(jsnCfg *DiameterAgentJsonCfg, separa
|
||||
break
|
||||
}
|
||||
}
|
||||
if err := rp.loadFromJsonCfg(reqProcJsn, separator); err != nil {
|
||||
return nil
|
||||
if err = rp.loadFromJsonCfg(reqProcJsn, separator); err != nil {
|
||||
return
|
||||
}
|
||||
if !haveID {
|
||||
da.RequestProcessors = append(da.RequestProcessors, rp)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
func (ds *DiameterAgentCfg) AsMapInterface(separator string) map[string]interface{} {
|
||||
|
||||
@@ -71,15 +71,15 @@ func (da *DNSAgentCfg) loadFromJsonCfg(jsnCfg *DNSAgentJsonCfg, sep string) (err
|
||||
break
|
||||
}
|
||||
}
|
||||
if err := rp.loadFromJsonCfg(reqProcJsn, sep); err != nil {
|
||||
return nil
|
||||
if err = rp.loadFromJsonCfg(reqProcJsn, sep); err != nil {
|
||||
return
|
||||
}
|
||||
if !haveID {
|
||||
da.RequestProcessors = append(da.RequestProcessors, rp)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
func (da *DNSAgentCfg) AsMapInterface(separator string) map[string]interface{} {
|
||||
|
||||
@@ -83,14 +83,14 @@ func (ca *HttpAgentCfg) appendHttpAgntProcCfgs(hps *[]*ReqProcessorJsnCfg, separ
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := rp.loadFromJsonCfg(reqProcJsn, separator); err != nil {
|
||||
return err
|
||||
if err = rp.loadFromJsonCfg(reqProcJsn, separator); err != nil {
|
||||
return
|
||||
}
|
||||
if !haveID {
|
||||
ca.RequestProcessors = append(ca.RequestProcessors, rp)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
func (ca *HttpAgentCfg) loadFromJsonCfg(jsnCfg *HttpAgentJsonCfg, separator string) (err error) {
|
||||
|
||||
@@ -89,15 +89,15 @@ func (self *RadiusAgentCfg) loadFromJsonCfg(jsnCfg *RadiusAgentJsonCfg, separato
|
||||
break
|
||||
}
|
||||
}
|
||||
if err := rp.loadFromJsonCfg(reqProcJsn, separator); err != nil {
|
||||
return nil
|
||||
if err = rp.loadFromJsonCfg(reqProcJsn, separator); err != nil {
|
||||
return
|
||||
}
|
||||
if !haveID {
|
||||
self.RequestProcessors = append(self.RequestProcessors, rp)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
func (ra *RadiusAgentCfg) AsMapInterface(separator string) map[string]interface{} {
|
||||
|
||||
@@ -35,6 +35,17 @@ func NewRSRParsers(parsersRules string, allFiltersMatch bool, rsrSeparator strin
|
||||
if parsersRules == "" {
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(parsersRules, utils.META_CONSTANT+utils.InInFieldSep) { // in case we do not want the rule to be processed at all
|
||||
// for example to compose a field in the agent request that contains `=`
|
||||
prsrs = RSRParsers{
|
||||
{
|
||||
Rules: parsersRules,
|
||||
AllFiltersMatch: allFiltersMatch,
|
||||
},
|
||||
}
|
||||
err = prsrs.Compile()
|
||||
return
|
||||
}
|
||||
return NewRSRParsersFromSlice(strings.Split(parsersRules, rsrSeparator), allFiltersMatch)
|
||||
}
|
||||
|
||||
@@ -229,6 +240,10 @@ func (prsr *RSRParser) AttrName() string {
|
||||
// Compile parses Rules string and repopulates other fields
|
||||
func (prsr *RSRParser) Compile() (err error) {
|
||||
var newPrsr *RSRParser
|
||||
if strings.HasPrefix(prsr.Rules, utils.META_CONSTANT+utils.InInFieldSep) { // in case we do not want the rule to be processed at all
|
||||
prsr.attrValue = strings.TrimPrefix(prsr.Rules, utils.META_CONSTANT+utils.InInFieldSep)
|
||||
return
|
||||
}
|
||||
if newPrsr, err = NewRSRParser(prsr.Rules, prsr.AllFiltersMatch); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -71,15 +71,15 @@ func (da *SIPAgentCfg) loadFromJsonCfg(jsnCfg *SIPAgentJsonCfg, sep string) (err
|
||||
break
|
||||
}
|
||||
}
|
||||
if err := rp.loadFromJsonCfg(reqProcJsn, sep); err != nil {
|
||||
return nil
|
||||
if err = rp.loadFromJsonCfg(reqProcJsn, sep); err != nil {
|
||||
return
|
||||
}
|
||||
if !haveID {
|
||||
da.RequestProcessors = append(da.RequestProcessors, rp)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
func (da *SIPAgentCfg) AsMapInterface(separator string) map[string]interface{} {
|
||||
|
||||
@@ -4,33 +4,71 @@
|
||||
"request_processors": [
|
||||
{
|
||||
"id": "Register",
|
||||
"filters": ["*prefix:~*req.Request:REGISTER"],
|
||||
"filters": ["*notstring:~*vars.Method:INVITE"],
|
||||
"flags": ["*none"],
|
||||
"request_fields":[],
|
||||
"reply_fields":[
|
||||
{"tag": "Request", "path": "*rep.Request", "type": "*constant",
|
||||
"value": "SIP/2.0 405 Method Not Allowed"},
|
||||
"value": "SIP/2.0 405 Method Not Allowed"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "InviteRedirect",
|
||||
"filters": ["*prefix:~*req.Request:INVITE"],
|
||||
"flags": ["*attributes","*event"],
|
||||
"id": "NAPTRRoutesQuery",
|
||||
"filters": ["*string:~*vars.Method:INVITE"],
|
||||
"flags": ["*event", "*routes","*continue"],
|
||||
"request_fields":[
|
||||
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
|
||||
"value": "~*req.From{*sipuri_user}", "mandatory": true},
|
||||
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable",
|
||||
"value": "~*req.To{*sipuri_user}", "mandatory": true}
|
||||
"value": "~*req.To{*sipuri_user}", "mandatory": true},
|
||||
],
|
||||
"reply_fields":[
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "NAPTRSuppliersOneSupplier",
|
||||
"filters": ["*string:~*vars.Method:INVITE",
|
||||
],
|
||||
"flags": ["*none","*continue","*log"], // do not send request to CGRateS
|
||||
"reply_fields":[
|
||||
{"tag": "Request", "path": "*rep.Request", "type": "*constant",
|
||||
"value": "SIP/2.0 302 Moved Temporarily"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"<"},
|
||||
"value":"\""},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*cgrep.Attributes.Destination"},
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":">"}
|
||||
"value":"\" <sip:"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"@"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value": "~*cgrep.Routes.SortedRoutes[0].RouteParameters"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"*constant:>;q=0.7; expires=3600"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "NAPTRSuppliersTwoSuppliers",
|
||||
"filters": ["*string:~*vars.Method:INVITE",
|
||||
"*gte:~*cgrep.Routes.Count:2"],
|
||||
"flags": ["*none","*continue"],
|
||||
"reply_fields":[
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":",\""},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"\" <sip:"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"@"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value": "~*cgrep.Routes.SortedRoutes[1].RouteParameters"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"*constant:>;q=0.1"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -4,33 +4,71 @@
|
||||
"request_processors": [
|
||||
{
|
||||
"id": "Register",
|
||||
"filters": ["*prefix:~*req.Request:REGISTER"],
|
||||
"filters": ["*notstring:~*vars.Method:INVITE"],
|
||||
"flags": ["*none"],
|
||||
"request_fields":[],
|
||||
"reply_fields":[
|
||||
{"tag": "Request", "path": "*rep.Request", "type": "*constant",
|
||||
"value": "SIP/2.0 405 Method Not Allowed"},
|
||||
"value": "SIP/2.0 405 Method Not Allowed"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "InviteRedirect",
|
||||
"filters": ["*prefix:~*req.Request:INVITE"],
|
||||
"flags": ["*attributes","*event"],
|
||||
"id": "NAPTRRoutesQuery",
|
||||
"filters": ["*string:~*vars.Method:INVITE"],
|
||||
"flags": ["*event", "*routes","*continue"],
|
||||
"request_fields":[
|
||||
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
|
||||
"value": "~*req.From{*sipuri_user}", "mandatory": true},
|
||||
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable",
|
||||
"value": "~*req.To{*sipuri_user}", "mandatory": true}
|
||||
"value": "~*req.To{*sipuri_user}", "mandatory": true},
|
||||
],
|
||||
"reply_fields":[
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "NAPTRSuppliersOneSupplier",
|
||||
"filters": ["*string:~*vars.Method:INVITE",
|
||||
],
|
||||
"flags": ["*none","*continue","*log"], // do not send request to CGRateS
|
||||
"reply_fields":[
|
||||
{"tag": "Request", "path": "*rep.Request", "type": "*constant",
|
||||
"value": "SIP/2.0 302 Moved Temporarily"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"<"},
|
||||
"value":"\""},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*cgrep.Attributes.Destination"},
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":">"}
|
||||
"value":"\" <sip:"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"@"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value": "~*cgrep.Routes.SortedRoutes[0].RouteParameters"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"*constant:>;q=0.7; expires=3600"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "NAPTRSuppliersTwoSuppliers",
|
||||
"filters": ["*string:~*vars.Method:INVITE",
|
||||
"*gte:~*cgrep.Routes.Count:2"],
|
||||
"flags": ["*none","*continue"],
|
||||
"reply_fields":[
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":",\""},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"\" <sip:"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"@"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value": "~*cgrep.Routes.SortedRoutes[1].RouteParameters"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"*constant:>;q=0.1"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -4,33 +4,71 @@
|
||||
"request_processors": [
|
||||
{
|
||||
"id": "Register",
|
||||
"filters": ["*notprefix:~*vars.Method:INVITE"],
|
||||
"filters": ["*notstring:~*vars.Method:INVITE"],
|
||||
"flags": ["*none"],
|
||||
"request_fields":[],
|
||||
"reply_fields":[
|
||||
{"tag": "Request", "path": "*rep.Request", "type": "*constant",
|
||||
"value": "SIP/2.0 405 Method Not Allowed"},
|
||||
"value": "SIP/2.0 405 Method Not Allowed"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "InviteRedirect",
|
||||
"filters": ["*prefix:~*vars.Method:INVITE"],
|
||||
"flags": ["*attributes","*event"],
|
||||
"id": "NAPTRRoutesQuery",
|
||||
"filters": ["*string:~*vars.Method:INVITE"],
|
||||
"flags": ["*event", "*routes","*continue"],
|
||||
"request_fields":[
|
||||
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
|
||||
"value": "~*req.From{*sipuri_user}", "mandatory": true},
|
||||
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable",
|
||||
"value": "~*req.To{*sipuri_user}", "mandatory": true}
|
||||
"value": "~*req.To{*sipuri_user}", "mandatory": true},
|
||||
],
|
||||
"reply_fields":[
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "NAPTRSuppliersOneSupplier",
|
||||
"filters": ["*string:~*vars.Method:INVITE",
|
||||
],
|
||||
"flags": ["*none","*continue","*log"], // do not send request to CGRateS
|
||||
"reply_fields":[
|
||||
{"tag": "Request", "path": "*rep.Request", "type": "*constant",
|
||||
"value": "SIP/2.0 302 Moved Temporarily"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"<"},
|
||||
"value":"\""},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*cgrep.Attributes.Destination"},
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":">"}
|
||||
"value":"\" <sip:"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"@"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value": "~*cgrep.Routes.SortedRoutes[0].RouteParameters"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"*constant:>;q=0.7; expires=3600"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "NAPTRSuppliersTwoSuppliers",
|
||||
"filters": ["*string:~*vars.Method:INVITE",
|
||||
"*gte:~*cgrep.Routes.Count:2"],
|
||||
"flags": ["*none","*continue"],
|
||||
"reply_fields":[
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":",\""},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"\" <sip:"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*req.To{*sipuri_user}"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"@"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value": "~*cgrep.Routes.SortedRoutes[1].RouteParameters"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"*constant:>;q=0.1"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
{
|
||||
"sip_agent": {
|
||||
"request_processors": [
|
||||
{
|
||||
"id": "NAPTRRoutesQuery",
|
||||
"filters": ["*string:~*vars.Method:INVITE"],
|
||||
"flags": ["*event", "*routes","*continue"],
|
||||
"request_fields":[
|
||||
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
|
||||
"value": "~*req.From{*sipuri_user}", "mandatory": true},
|
||||
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable",
|
||||
"value": "~*req.To{*sipuri_user}", "mandatory": true}
|
||||
],
|
||||
"reply_fields":[
|
||||
],
|
||||
},
|
||||
{
|
||||
"id": "NAPTRSuppliersOneSupplier",
|
||||
"filters": ["*string:~*vars.Method:INVITE",
|
||||
"*gte:~*cgrep.Routes.Count:1"],
|
||||
"flags": ["*none","*continue"], // do not send request to CGRateS
|
||||
"reply_fields":[
|
||||
{"tag": "Request", "path": "*rep.Request", "type": "*constant",
|
||||
"value": "SIP/2.0 302 Moved Temporarily"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"\""},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*cgreq.Destination"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"\" <sip:"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*cgreq.Destination"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"@"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value": "~*cgrep.Routes.SortedRoutes[0].RouteParameters"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":">;q=0.7; expires=3600"},
|
||||
],
|
||||
},
|
||||
{
|
||||
"id": "NAPTRSuppliersTwoSuppliers",
|
||||
"filters": ["*string:~*vars.Method:INVITE",
|
||||
"*gte:~*cgrep.Routes.Count:2"],
|
||||
"flags": ["*none","*continue"],
|
||||
"reply_fields":[
|
||||
{"tag": "Request", "path": "*rep.Request", "type": "*constant",
|
||||
"value": "SIP/2.0 302 Moved Temporarily"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"\""},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*cgreq.Destination"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"\" <sip:"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"~*cgreq.Destination"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":"@"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value": "~*cgrep.Routes.SortedRoutes[1].RouteParameters"},
|
||||
{"tag": "Contact", "path": "*rep.Contact", "type": "*composed",
|
||||
"value":">;q=0.1"},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
}
|
||||
2
go.mod
2
go.mod
@@ -25,7 +25,7 @@ require (
|
||||
github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca
|
||||
github.com/cgrates/radigo v0.0.0-20200324152710-35e651804ad1
|
||||
github.com/cgrates/rpcclient v0.0.0-20200326100105-a579e2c47453
|
||||
github.com/cgrates/sipd v1.0.1-0.20200513092040-728b130a73d6
|
||||
github.com/cgrates/sipd v1.0.1-0.20200514091151-e426e71861e8
|
||||
github.com/creack/pty v1.1.7
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/fiorix/go-diameter v3.0.3-0.20190716165154-f4823472d0e0+incompatible
|
||||
|
||||
2
go.sum
2
go.sum
@@ -66,6 +66,8 @@ github.com/cgrates/rpcclient v0.0.0-20200326100105-a579e2c47453/go.mod h1:xXLqAK
|
||||
github.com/cgrates/sipd v1.0.0/go.mod h1:Itz4HoJHqckX9XAbGRanB1PvXfKrIO/UtMB8JwCFsT4=
|
||||
github.com/cgrates/sipd v1.0.1-0.20200513092040-728b130a73d6 h1:yKEwGpD79Pbss7/03mwPh9MvbBXmttiUX+iyA67PRA8=
|
||||
github.com/cgrates/sipd v1.0.1-0.20200513092040-728b130a73d6/go.mod h1:yAWcE5qt60PMrWME9Ijp6IWlWwL5d+/VflUYudO1Xm0=
|
||||
github.com/cgrates/sipd v1.0.1-0.20200514091151-e426e71861e8 h1:4QTOvFTqLOWHUQCUs22mGfiw3WZaZRzaEstTjYlXsgo=
|
||||
github.com/cgrates/sipd v1.0.1-0.20200514091151-e426e71861e8/go.mod h1:yAWcE5qt60PMrWME9Ijp6IWlWwL5d+/VflUYudO1Xm0=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/creack/pty v1.1.7 h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
|
||||
@@ -12,12 +12,12 @@ cgrates (0.11.0~dev) UNRELEASED; urgency=medium
|
||||
ToJSON for request String method
|
||||
* [DiameterAgent] Updated 3gp_vendor dictionary
|
||||
* [Templates] Added new dataconvertor: *ip2hex
|
||||
* [AgentRequest] Added support for *group type and correctly overwrite
|
||||
* [AgentS] Added support for *group type and correctly overwrite
|
||||
the values in case of *variable
|
||||
* [EventReader] Correctly populate ConcurrentRequest from config
|
||||
* [FilterS] Updated *exists to dynamically compute the path if the
|
||||
path
|
||||
* [AgentRequest] Added support for *tmp path
|
||||
* [AgentS] Added support for *tmp path
|
||||
* [SessionS] Added new API SessionSv1.GetCost
|
||||
* [SessionS] Updateed MaxUsage field from API replies
|
||||
* [SessionS] Added support for *cdrs flag in SessionSv1.ProcessEvent
|
||||
@@ -54,12 +54,14 @@ cgrates (0.11.0~dev) UNRELEASED; urgency=medium
|
||||
* [SessionS] Added support for *stir_authenticate
|
||||
* [SessionS] Added support for *stir_initiate
|
||||
* [RouteS] Renaming from SupplierS to RouteS
|
||||
* [AgentRequest] Improved NavigableMap
|
||||
* [AgentS] Improved NavigableMap
|
||||
* [General] Default timingIDs start from time.Now() (i.e. *monthly time.Now() + 1 month )
|
||||
* [AgentS] FieldAsInterface return data instead of NMItem
|
||||
* [RouteS] Add posibility to load routes with the sameID and different filters
|
||||
* [RouteS] Correctly populate Sorting out of models
|
||||
* [AgentS] Added SIPAgent for SIP redirection
|
||||
* [AgentS] Added *constant: prefix to do not proccess the value
|
||||
with RSRParsers
|
||||
|
||||
-- DanB <danb@cgrates.org> Wed, 19 Feb 2020 13:25:52 +0200
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ type SIPURIUserConverter struct{}
|
||||
// Convert implements DataConverter interface
|
||||
func (*SIPURIUserConverter) Convert(in interface{}) (out interface{}, err error) {
|
||||
val := IfaceAsString(in)
|
||||
return sipd.NameFrom(val), nil
|
||||
return sipd.UserFrom(val), nil
|
||||
}
|
||||
|
||||
// SIPURIMethodConverter will return the
|
||||
|
||||
Reference in New Issue
Block a user