Adding MinSessionTTL and MaxSessionTTL in SMG config

This commit is contained in:
DanB
2017-03-09 20:25:49 +01:00
parent 47dfa5af91
commit b8964cd684
3 changed files with 20 additions and 0 deletions

View File

@@ -272,6 +272,8 @@ const CGRATES_CFG_JSON = `
"min_call_duration": "0s", // only authorize calls with allowed duration higher than this
"max_call_duration": "3h", // maximum call duration a prepaid call can last
"session_ttl": "0s", // time after a session with no updates is terminated, not defined by default
//"min_session_ttl": "", // activates session_ttl randomization as minimum possible session_ttl
//"max_session_ttl": "", // used in case of session_ttl randomization as maximum possible session_ttl, unlimited if not defined
//"session_ttl_last_used": "", // tweak LastUsed for sessions timing-out, not defined by default
//"session_ttl_usage": "", // tweak Usage for sessions timing-out, not defined by default
"session_indexes": [], // index sessions based on these fields for GetActiveSessions API

View File

@@ -196,6 +196,8 @@ type SmGenericJsonCfg struct {
Min_call_duration *string
Max_call_duration *string
Session_ttl *string
Min_session_ttl *string
Max_session_ttl *string
Session_ttl_last_used *string
Session_ttl_usage *string
Session_indexes *[]string

View File

@@ -97,6 +97,8 @@ type SmGenericConfig struct {
MinCallDuration time.Duration
MaxCallDuration time.Duration
SessionTTL time.Duration
MinSessionTTL *time.Duration
MaxSessionTTL *time.Duration
SessionTTLLastUsed *time.Duration
SessionTTLUsage *time.Duration
SessionIndexes utils.StringMap
@@ -154,6 +156,20 @@ func (self *SmGenericConfig) loadFromJsonCfg(jsnCfg *SmGenericJsonCfg) error {
return err
}
}
if jsnCfg.Min_session_ttl != nil {
if minSesTTL, err := utils.ParseDurationWithSecs(*jsnCfg.Min_session_ttl); err != nil {
return err
} else {
self.MinSessionTTL = &minSesTTL
}
}
if jsnCfg.Max_session_ttl != nil {
if maxSesTTL, err := utils.ParseDurationWithSecs(*jsnCfg.Max_session_ttl); err != nil {
return err
} else {
self.MaxSessionTTL = &maxSesTTL
}
}
if jsnCfg.Session_ttl_last_used != nil {
if sessionTTLLastUsed, err := utils.ParseDurationWithSecs(*jsnCfg.Session_ttl_last_used); err != nil {
return err