Added RemoteCost field in *vars (in agents)

This commit is contained in:
adragusin
2020-01-27 14:16:42 +02:00
committed by Dan Christian Bogos
parent 351d3af52b
commit e73cdd0c5e
6 changed files with 24 additions and 6 deletions

View File

@@ -150,6 +150,7 @@ func (da *DiameterAgent) handleMessage(c diam.Conn, m *diam.Message) {
utils.MetaApp: dApp.Name,
utils.MetaAppID: dApp.ID,
utils.MetaCmd: dCmd.Short + "R",
utils.RemoteHost: c.RemoteAddr().String(),
}
// build the negative error answer
diamErr, err := diamErr(m, diam.UnableToComply, reqVars,

View File

@@ -111,6 +111,7 @@ func (da *DNSAgent) handleMessage(w dns.ResponseWriter, req *dns.Msg) {
reqVars[E164Address] = e164
reqVars[DomainName] = domainNameFromNAPTR(req.Question[0].Name)
}
reqVars[utils.RemoteHost] = w.RemoteAddr().String()
cgrRplyNM := config.NewNavigableMap(nil)
rplyNM := config.NewNavigableMap(nil) // share it among different processors
var processed bool

View File

@@ -56,6 +56,7 @@ type HTTPAgent struct {
// ServeHTTP implements http.Handler interface
func (ha *HTTPAgent) ServeHTTP(w http.ResponseWriter, req *http.Request) {
reqVars := make(map[string]interface{})
dcdr, err := newHADataProvider(ha.reqPayload, req) // dcdr will provide information from request
if err != nil {
utils.Logger.Warning(
@@ -65,8 +66,9 @@ func (ha *HTTPAgent) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
cgrRplyNM := config.NewNavigableMap(nil)
rplyNM := config.NewNavigableMap(nil)
reqVars[utils.RemoteHost] = req.RemoteAddr
for _, reqProcessor := range ha.reqProcessors {
agReq := NewAgentRequest(dcdr, nil, cgrRplyNM, rplyNM,
agReq := NewAgentRequest(dcdr, reqVars, cgrRplyNM, rplyNM,
reqProcessor.Tenant, ha.dfltTenant,
utils.FirstNonEmpty(reqProcessor.Timezone,
config.CgrConfig().GeneralCfg().DefaultTimezone),

View File

@@ -70,6 +70,7 @@ type RadiusAgent struct {
// handleAuth handles RADIUS Authorization request
func (ra *RadiusAgent) handleAuth(req *radigo.Packet) (rpl *radigo.Packet, err error) {
reqVars := make(map[string]interface{})
req.SetAVPValues() // populate string values in AVPs
dcdr := newRADataProvider(req) // dcdr will provide information from request
rpl = req.Reply()
@@ -77,8 +78,9 @@ func (ra *RadiusAgent) handleAuth(req *radigo.Packet) (rpl *radigo.Packet, err e
cgrRplyNM := config.NewNavigableMap(nil)
rplyNM := config.NewNavigableMap(nil)
var processed bool
reqVars[utils.RemoteHost] = req.RemoteAddr().String()
for _, reqProcessor := range ra.cgrCfg.RadiusAgentCfg().RequestProcessors {
agReq := NewAgentRequest(dcdr, nil, cgrRplyNM, rplyNM,
agReq := NewAgentRequest(dcdr, reqVars, cgrRplyNM, rplyNM,
reqProcessor.Tenant, ra.cgrCfg.GeneralCfg().DefaultTenant,
utils.FirstNonEmpty(reqProcessor.Timezone,
config.CgrConfig().GeneralCfg().DefaultTimezone),
@@ -107,6 +109,7 @@ func (ra *RadiusAgent) handleAuth(req *radigo.Packet) (rpl *radigo.Packet, err e
// handleAcct handles RADIUS Accounting request
// supports: Acct-Status-Type = Start, Interim-Update, Stop
func (ra *RadiusAgent) handleAcct(req *radigo.Packet) (rpl *radigo.Packet, err error) {
reqVars := make(map[string]interface{})
req.SetAVPValues() // populate string values in AVPs
dcdr := newRADataProvider(req) // dcdr will provide information from request
rpl = req.Reply()
@@ -114,8 +117,9 @@ func (ra *RadiusAgent) handleAcct(req *radigo.Packet) (rpl *radigo.Packet, err e
cgrRplyNM := config.NewNavigableMap(nil)
rplyNM := config.NewNavigableMap(nil)
var processed bool
reqVars[utils.RemoteHost] = req.RemoteAddr().String()
for _, reqProcessor := range ra.cgrCfg.RadiusAgentCfg().RequestProcessors {
agReq := NewAgentRequest(dcdr, nil, cgrRplyNM, rplyNM,
agReq := NewAgentRequest(dcdr, reqVars, cgrRplyNM, rplyNM,
reqProcessor.Tenant, ra.cgrCfg.GeneralCfg().DefaultTenant,
utils.FirstNonEmpty(reqProcessor.Timezone,
config.CgrConfig().GeneralCfg().DefaultTimezone),

View File

@@ -28,6 +28,9 @@ agts_internal=$?
echo 'go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*internal'
go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*internal
smg_internal=$?
echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*internal'
go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*internal
dis_internal=$?
# SQL
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql'
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*sql
@@ -53,6 +56,9 @@ agts_sql=$?
echo 'go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*sql'
go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*sql
smg_sql=$?
echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*sql'
go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*sql
dis_sql=$?
# Mongo
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo'
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*mongo
@@ -78,6 +84,9 @@ agts_mongo=$?
echo 'go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*mongo'
go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*mongo
smg_mongo=$?
echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*mongo'
go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*mongo
dis_mongo=$?
# Postgres
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres'
go test github.com/cgrates/cgrates/apier/v1 -tags=integration -dbtype=*postgres
@@ -103,6 +112,9 @@ agts_postgres=$?
echo 'go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*postgres'
go test github.com/cgrates/cgrates/sessions -tags=integration -dbtype=*postgres
smg_postgres=$?
echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*postgres'
go test github.com/cgrates/cgrates/dispatchers -tags=integration -dbtype=*postgres
dis_postgres=$?
echo 'go test github.com/cgrates/cgrates/config -tags=integration'
go test github.com/cgrates/cgrates/config -tags=integration
@@ -115,9 +127,6 @@ go test github.com/cgrates/cgrates/services -tags=integration
srv=$?
#All
echo 'go test github.com/cgrates/cgrates/dispatchers -tags=integration'
go test github.com/cgrates/cgrates/dispatchers -tags=integration
dis=$?
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=offline'
go test github.com/cgrates/cgrates/apier/v1 -tags=offline
offline=$?

View File

@@ -543,6 +543,7 @@ const (
IdxEnd = "]"
MetaLog = "*log"
MetaRemoteHost = "*remote_host"
RemoteHost = "RemoteHost"
Local = "local"
TCP = "tcp"
CGRDebitInterval = "CGRDebitInterval"