Added the mobile-idle-timeout config option.

This commit is contained in:
Nikos Mavrogiannopoulos
2014-02-18 18:54:50 +01:00
parent b550489c88
commit 6ee0899e22
4 changed files with 17 additions and 11 deletions
+2
View File
@@ -92,6 +92,7 @@ static struct cfg_options available_options[] = {
{ .name = "rekey-time", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "rekey-time", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "auth-timeout", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "auth-timeout", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "idle-timeout", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "idle-timeout", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "mobile-idle-timeout", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "max-clients", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "max-clients", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "min-reauth-time", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "min-reauth-time", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "max-same-clients", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "max-same-clients", .type = OPTION_NUMERIC, .mandatory = 0 },
@@ -394,6 +395,7 @@ unsigned force_cert_auth;
READ_NUMERIC("auth-timeout", config->auth_timeout); READ_NUMERIC("auth-timeout", config->auth_timeout);
READ_NUMERIC("idle-timeout", config->idle_timeout); READ_NUMERIC("idle-timeout", config->idle_timeout);
READ_NUMERIC("mobile-idle-timeout", config->mobile_idle_timeout);
READ_NUMERIC("max-clients", config->max_clients); READ_NUMERIC("max-clients", config->max_clients);
READ_NUMERIC("min-reauth-time", config->min_reauth_time); READ_NUMERIC("min-reauth-time", config->min_reauth_time);
READ_NUMERIC("max-same-clients", config->max_same_clients); READ_NUMERIC("max-same-clients", config->max_same_clients);
+4
View File
@@ -187,6 +187,10 @@ auth-timeout = 40
# before being disconnected. Unset to disable. # before being disconnected. Unset to disable.
#idle-timeout = 1200 #idle-timeout = 1200
# 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
# The time (in seconds) that a client is not allowed to reconnect after # The time (in seconds) that a client is not allowed to reconnect after
# a failed authentication attempt. # a failed authentication attempt.
#min-reauth-time = 2 #min-reauth-time = 2
+1
View File
@@ -204,6 +204,7 @@ struct cfg_st {
time_t min_reauth_time; /* after a failed auth, how soon one can reauthenticate -> in seconds */ time_t min_reauth_time; /* after a failed auth, how soon one can reauthenticate -> in seconds */
unsigned auth_timeout; /* timeout of HTTP auth */ unsigned auth_timeout; /* timeout of HTTP auth */
unsigned idle_timeout; /* timeout when idle */ unsigned idle_timeout; /* timeout when idle */
unsigned mobile_idle_timeout; /* timeout when a mobile is idle */
unsigned keepalive; unsigned keepalive;
unsigned dpd; unsigned dpd;
unsigned mobile_dpd; unsigned mobile_dpd;
+10 -11
View File
@@ -1030,7 +1030,6 @@ static int connect_handler(worker_st * ws)
struct http_req_st *req = &ws->req; struct http_req_st *req = &ws->req;
fd_set rfds; fd_set rfds;
int l, e, max, ret, overhead, t; int l, e, max, ret, overhead, t;
int dpd;
unsigned tls_retry, dtls_mtu, cstp_mtu; unsigned tls_retry, dtls_mtu, cstp_mtu;
char *p; char *p;
#ifdef HAVE_PSELECT #ifdef HAVE_PSELECT
@@ -1121,14 +1120,14 @@ static int connect_handler(worker_st * ws)
ret = tls_puts(ws->session, "X-CSTP-Version: 1\r\n"); ret = tls_puts(ws->session, "X-CSTP-Version: 1\r\n");
SEND_ERR(ret); SEND_ERR(ret);
if (req->is_mobile) if (req->is_mobile) {
dpd = ws->config->mobile_dpd; ws->config->dpd = ws->config->mobile_dpd;
else ws->config->idle_timeout = ws->config->mobile_idle_timeout;
dpd = ws->config->dpd; }
oclog(ws, LOG_DEBUG, "suggesting DPD of %d secs", dpd); oclog(ws, LOG_DEBUG, "suggesting DPD of %d secs", ws->config->dpd);
if (dpd > 0) { if (ws->config->dpd > 0) {
ret = tls_printf(ws->session, "X-CSTP-DPD: %u\r\n", dpd); ret = tls_printf(ws->session, "X-CSTP-DPD: %u\r\n", ws->config->dpd);
SEND_ERR(ret); SEND_ERR(ret);
} }
@@ -1363,8 +1362,8 @@ static int connect_handler(worker_st * ws)
ws->buffer); ws->buffer);
SEND_ERR(ret); SEND_ERR(ret);
if (dpd > 0) { if (ws->config->dpd > 0) {
ret = tls_printf(ws->session, "X-DTLS-DPD: %u\r\n", dpd); ret = tls_printf(ws->session, "X-DTLS-DPD: %u\r\n", ws->config->dpd);
SEND_ERR(ret); SEND_ERR(ret);
} }
@@ -1545,7 +1544,7 @@ static int connect_handler(worker_st * ws)
gettime(&tnow); gettime(&tnow);
now = tnow.tv_sec; now = tnow.tv_sec;
if (periodic_check(ws, mtu_overhead, now, dpd) < 0) if (periodic_check(ws, mtu_overhead, now, ws->config->dpd) < 0)
goto exit; goto exit;
if (FD_ISSET(ws->tun_fd, &rfds)) { if (FD_ISSET(ws->tun_fd, &rfds)) {