diff --git a/config/config_defaults.go b/config/config_defaults.go index 6736c7093..55d9faf70 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -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 diff --git a/config/libconfig_json.go b/config/libconfig_json.go index 9800f1918..f6eb8017f 100644 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -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 diff --git a/config/smconfig.go b/config/smconfig.go index 21e874cee..19c13db63 100644 --- a/config/smconfig.go +++ b/config/smconfig.go @@ -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