diff options
author | ATHARVA S MARATHE <atharvamarathe8@gmail.com> | 2023-04-04 03:49:13 +0000 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2023-04-04 03:49:13 +0000 |
commit | b133511328c6a66e8c8b83e50caabee066753308 (patch) | |
tree | 7ea61be6b6091eda398acc103f2532489c4f2e6d /src | |
parent | 0138bcb40b04df6b191d8e0caf80e00ff160ee10 (diff) | |
download | gnutls-b133511328c6a66e8c8b83e50caabee066753308.tar.gz |
gnutls-serv: add configurable timeout
This adds --timeout option to gnutls-serv to control the inactivity
interval, which would be useful for testing.
Fixes: #1471
Signed-off-by: maratheatharva <atharvamarathe8@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gnutls-serv-options.json | 5 | ||||
-rw-r--r-- | src/serv.c | 15 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/gnutls-serv-options.json b/src/gnutls-serv-options.json index 015a70d3c2..d98f061240 100644 --- a/src/gnutls-serv-options.json +++ b/src/gnutls-serv-options.json @@ -306,6 +306,11 @@ "description": "The data used as HTTP response", "file-exists": true, "argument-type": "file" + }, + { + "long-option": "timeout", + "description": "The timeout period for server", + "argument-type": "number" } ] } diff --git a/src/serv.c b/src/serv.c index 5adf143f27..5f59e36f57 100644 --- a/src/serv.c +++ b/src/serv.c @@ -98,7 +98,7 @@ gnutls_datum_t session_ticket_key; gnutls_anti_replay_t anti_replay; int record_max_size; const char *http_data_file = NULL; -static void tcp_server(const char *name, int port); +static void tcp_server(const char *name, int port, int timeout); /* end of globals */ @@ -1174,7 +1174,7 @@ static void tls_audit_log_func(gnutls_session_t session, const char *str) int main(int argc, char **argv) { - int ret, mtu, port; + int ret, mtu, port, timeout; char name[256]; int cert_set = 0; unsigned use_static_dh_params = 0; @@ -1465,10 +1465,15 @@ int main(int argc, char **argv) else port = 5556; + if (HAVE_OPT(TIMEOUT)) + timeout = OPT_VALUE_TIMEOUT; + else + timeout = 30; + if (HAVE_OPT(UDP)) udp_server(name, port, mtu); else - tcp_server(name, port); + tcp_server(name, port, timeout); return 0; } @@ -1540,7 +1545,7 @@ static void try_rehandshake(listener_item * j) } } -static void tcp_server(const char *name, int port) +static void tcp_server(const char *name, int port, int timeout) { int n, s; char topbuf[512]; @@ -1584,7 +1589,7 @@ static void tcp_server(const char *name, int port) exit(1); } #endif - if (j->start != 0 && now - j->start > 30) { + if (j->start != 0 && now - j->start > timeout) { if (verbose != 0) { fprintf(stderr, "Scheduling inactive connection for close\n"); |