From 4ff5b53ff8a1d6232e21a3e8f0538dc87ca4920b Mon Sep 17 00:00:00 2001 From: James Yonan Date: Sun, 20 Mar 2011 19:43:06 +0000 Subject: Client will now try to reconnect if no push reply received within handshake-window seconds. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@7066 e7ae566f-a301-0410-adde-c780ea21d3b5 --- common.h | 5 +++++ forward.c | 4 ++-- openvpn.h | 1 + push.c | 13 ++++++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/common.h b/common.h index 5548f7c..0ca7323 100644 --- a/common.h +++ b/common.h @@ -86,6 +86,11 @@ typedef unsigned long ptr_type; */ #define PUSH_BUNDLE_SIZE 1024 +/* + * In how many seconds does client re-send PUSH_REQUEST if we haven't yet received a reply + */ +#define PUSH_REQUEST_INTERVAL 5 + /* * A sort of pseudo-filename for data provided inline within * the configuration file. diff --git a/forward.c b/forward.c index 65b8f0c..7212db4 100644 --- a/forward.c +++ b/forward.c @@ -178,8 +178,8 @@ check_push_request_dowork (struct context *c) { send_push_request (c); - /* if no response to first push_request, retry at 5 second intervals */ - event_timeout_modify_wakeup (&c->c2.push_request_interval, 5); + /* if no response to first push_request, retry at PUSH_REQUEST_INTERVAL second intervals */ + event_timeout_modify_wakeup (&c->c2.push_request_interval, PUSH_REQUEST_INTERVAL); } #endif /* P2MP */ diff --git a/openvpn.h b/openvpn.h index 47c9734..0ee439c 100644 --- a/openvpn.h +++ b/openvpn.h @@ -431,6 +431,7 @@ struct context_2 #endif struct event_timeout push_request_interval; + int n_sent_push_requests; bool did_pre_pull_restore; /* hash of pulled options, so we can compare when options change */ diff --git a/push.c b/push.c index 2e8aa55..ece3121 100644 --- a/push.c +++ b/push.c @@ -189,7 +189,18 @@ incoming_push_message (struct context *c, const struct buffer *buffer) bool send_push_request (struct context *c) { - return send_control_channel_string (c, "PUSH_REQUEST", D_PUSH); + const int max_push_requests = c->options.handshake_window / PUSH_REQUEST_INTERVAL; + if (++c->c2.n_sent_push_requests <= max_push_requests) + { + return send_control_channel_string (c, "PUSH_REQUEST", D_PUSH); + } + else + { + msg (D_STREAM_ERRORS, "No reply from server after sending %d push requests", max_push_requests); + c->sig->signal_received = SIGUSR1; /* SOFT-SIGUSR1 -- server-pushed connection reset */ + c->sig->signal_text = "no-push-reply"; + return false; + } } #if P2MP_SERVER -- cgit v1.2.3