Introduced session-timeout option

That allows to set the maximum number of seconds a session can be
active.
This commit is contained in:
Nikos Mavrogiannopoulos
2015-05-19 15:07:49 +02:00
parent 4dd558b0cc
commit 6ff0a8fb07
5 changed files with 22 additions and 0 deletions

View File

@@ -278,6 +278,8 @@ VALUE_PAIR *send = NULL, *recvd = NULL;
ret = PW_ADMIN_RESET;
else if (discon_reason == REASON_IDLE_TIMEOUT)
ret = PW_ACCT_IDLE_TIMEOUT;
else if (discon_reason == REASON_SESSION_TIMEOUT)
ret = PW_ACCT_SESSION_TIMEOUT;
else if (discon_reason == REASON_DPD_TIMEOUT)
ret = PW_LOST_CARRIER;
else if (discon_reason == REASON_ERROR)

View File

@@ -132,6 +132,7 @@ static struct cfg_options available_options[] = {
{ .name = "net-priority", .type = OPTION_STRING, .mandatory = 0 },
{ .name = "output-buffer", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "cookie-timeout", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "session-timeout", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "stats-report-time", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "rekey-time", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "rekey-method", .type = OPTION_STRING, .mandatory = 0 },
@@ -843,6 +844,8 @@ unsigned urlfw_size = 0;
config->cookie_timeout = DEFAULT_COOKIE_RECON_TIMEOUT;
READ_TF("persistent-cookies", config->persistent_cookies, 0);
READ_NUMERIC("session-timeout", config->session_timeout);
READ_NUMERIC("auth-timeout", config->auth_timeout);
READ_NUMERIC("idle-timeout", config->idle_timeout);

View File

@@ -321,6 +321,10 @@ auth-timeout = 40
# before being disconnected. Unset to disable.
#idle-timeout = 1200
# The time (in seconds) that a client is allowed to stay connected
# Unset to disable.
#session-timeout = 86400
# The time (in seconds) that a mobile client is allowed to stay idle (no
# traffic) before being disconnected. Unset to disable.
#mobile-idle-timeout = 2400

View File

@@ -116,6 +116,7 @@ extern int syslog_open;
#define REASON_IDLE_TIMEOUT 4
#define REASON_DPD_TIMEOUT 5
#define REASON_ERROR 6
#define REASON_SESSION_TIMEOUT 7
#define ERR_SUCCESS 0
#define ERR_BAD_COMMAND -2
@@ -324,6 +325,7 @@ struct cfg_st {
unsigned deny_roaming; /* whether a cookie is restricted to a single IP */
time_t cookie_timeout; /* in seconds */
time_t session_timeout; /* in seconds */
unsigned persistent_cookies; /* whether cookies stay valid after disconnect */
time_t rekey_time; /* in seconds */

View File

@@ -739,6 +739,17 @@ int periodic_check(worker_st * ws, unsigned mtu_overhead, time_t now,
}
}
if (ws->config->session_timeout > 0) {
if (now - ws->session_start_time > ws->config->session_timeout) {
oclog(ws, LOG_ERR,
"session timeout reached for process (%d secs)",
(int)(now - ws->session_start_time));
terminate = 1;
terminate_reason = REASON_SESSION_TIMEOUT;
goto cleanup;
}
}
if (ws->config->stats_report_time > 0 &&
now - ws->last_stats_msg >= ws->config->stats_report_time &&
ws->sid_set) {