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 877601f..d3e9224 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 13dae1d..46b38eb 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 227be4a..32cb797 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);