Delay sending the real ID request until after a proxy request is granted.
authorGuus Sliepen <guus@tinc-vpn.org>
Fri, 14 Oct 2016 12:44:06 +0000 (14:44 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 14 Oct 2016 12:44:06 +0000 (14:44 +0200)
src/connection.h
src/protocol_auth.c
src/proxy.c

index 877601fe3ad7b426405de9fed225efb7e22fd56f..d3e9224d002fdde945e966eb4ca6333ae74ff2e3 100644 (file)
@@ -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"
index 13dae1d34d495558ee6e7ed6f8e6fe06d8631cfb..46b38eb8185924bdb0636e05d7fcd6c57c9d71f1 100644 (file)
@@ -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);
index 227be4a5e1cc6882021272f26785730a2842ba8a..32cb7973ffcb51e9a928b7f20d62e5d9c44722cb 100644 (file)
@@ -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);