From: Guus Sliepen Date: Fri, 14 Oct 2016 12:44:06 +0000 (+0200) Subject: Delay sending the real ID request until after a proxy request is granted. X-Git-Tag: release-1.0.30~7 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=3c37fe38019ec9c08be6158a4f64128fc83ed605;p=tinc Delay sending the real ID request until after a proxy request is granted. --- diff --git a/src/connection.h b/src/connection.h index 877601fe..d3e9224d 100644 --- a/src/connection.h +++ b/src/connection.h @@ -41,7 +41,8 @@ typedef struct connection_status_t { unsigned int encryptout:1; /* 1 if we can encrypt outgoing traffic */ unsigned int decryptin:1; /* 1 if we have to decrypt incoming traffic */ unsigned int mst:1; /* 1 if this connection is part of a minimum spanning tree */ - unsigned int unused:23; + unsigned int proxy_passed:1; /* 1 if we are connecting via a proxy and we have finished talking with it */ + unsigned int unused:22; } connection_status_t; #include "edge.h" diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 13dae1d3..46b38eb8 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -41,9 +41,8 @@ #include "xalloc.h" bool send_id(connection_t *c) { - if(proxytype && c->outgoing) - if(!send_proxyrequest(c)) - return false; + if(proxytype && c->outgoing && !c->status.proxy_passed) + return send_proxyrequest(c); return send_request(c, "%d %s %d", ID, myself->connection->name, myself->connection->protocol_version); diff --git a/src/proxy.c b/src/proxy.c index 227be4a5..32cb7973 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -194,6 +194,8 @@ int receive_proxy_meta(connection_t *c, int start, int lenin) { ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Proxy request granted"); c->allow_request = ID; + c->status.proxy_passed = true; + send_id(c); return 8; } else { logger(LOG_ERR, "Proxy request rejected"); @@ -249,6 +251,8 @@ int receive_proxy_meta(connection_t *c, int start, int lenin) { } else { ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Proxy request granted"); c->allow_request = ID; + c->status.proxy_passed = true; + send_id(c); return replen; } @@ -275,6 +279,8 @@ int receive_proxy_meta(connection_t *c, int start, int lenin) { logger(LOG_DEBUG, "Proxy request granted"); replen = p + 1 - c->buffer; c->allow_request = ID; + c->status.proxy_passed = true; + send_id(c); return replen; } else { p = memchr(c->buffer, '\n', c->buflen);