Don't send proxy requests for incoming connections.
authorGuus Sliepen <guus@tinc-vpn.org>
Thu, 7 Feb 2013 13:23:31 +0000 (14:23 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Thu, 7 Feb 2013 13:23:31 +0000 (14:23 +0100)
src/meta.c
src/net_socket.c
src/protocol.c
src/protocol_auth.c

index e60c127a82ad6123542d73f636dde6099a08ce83..27baf8fea48018dcfa57f42958ac13ba2153641b 100644 (file)
@@ -178,14 +178,14 @@ bool receive_meta(connection_t *c) {
                if(c->tcplen) {
                        if(c->tcplen <= c->buflen) {
                                if(!c->node) {
                if(c->tcplen) {
                        if(c->tcplen <= c->buflen) {
                                if(!c->node) {
-                                       if(proxytype == PROXY_SOCKS4 && c->allow_request == ID) {
+                                       if(c->outgoing && proxytype == PROXY_SOCKS4 && c->allow_request == ID) {
                                                if(c->buffer[0] == 0 && c->buffer[1] == 0x5a) {
                                                        logger(LOG_DEBUG, "Proxy request granted");
                                                } else {
                                                        logger(LOG_ERR, "Proxy request rejected");
                                                        return false;
                                                }
                                                if(c->buffer[0] == 0 && c->buffer[1] == 0x5a) {
                                                        logger(LOG_DEBUG, "Proxy request granted");
                                                } else {
                                                        logger(LOG_ERR, "Proxy request rejected");
                                                        return false;
                                                }
-                                       } else if(proxytype == PROXY_SOCKS5 && c->allow_request == ID) {
+                                       } else if(c->outgoing && proxytype == PROXY_SOCKS5 && c->allow_request == ID) {
                                                if(c->buffer[0] != 5) {
                                                        logger(LOG_ERR, "Invalid response from proxy server");
                                                        return false;
                                                if(c->buffer[0] != 5) {
                                                        logger(LOG_ERR, "Invalid response from proxy server");
                                                        return false;
index 2d1ecc50e83f40ed5d03590e49a8a7a6e6e13182..e7634996e356712937157fc26a50c8a2d02564fa 100644 (file)
@@ -294,9 +294,6 @@ void retry_outgoing(outgoing_t *outgoing) {
 void finish_connecting(connection_t *c) {
        ifdebug(CONNECTIONS) logger(LOG_INFO, "Connected to %s (%s)", c->name, c->hostname);
 
 void finish_connecting(connection_t *c) {
        ifdebug(CONNECTIONS) logger(LOG_INFO, "Connected to %s (%s)", c->name, c->hostname);
 
-       if(proxytype != PROXY_EXEC)
-               configure_tcp(c);
-
        c->last_ping_time = now;
 
        send_id(c);
        c->last_ping_time = now;
 
        send_id(c);
@@ -419,6 +416,7 @@ begin:
                        goto begin;
                ifdebug(CONNECTIONS) logger(LOG_INFO, "Using proxy at %s port %s", proxyhost, proxyport);
                c->socket = socket(proxyai->ai_family, SOCK_STREAM, IPPROTO_TCP);
                        goto begin;
                ifdebug(CONNECTIONS) logger(LOG_INFO, "Using proxy at %s port %s", proxyhost, proxyport);
                c->socket = socket(proxyai->ai_family, SOCK_STREAM, IPPROTO_TCP);
+               configure_tcp(c);
        }
 
        if(c->socket == -1) {
        }
 
        if(c->socket == -1) {
index f36538e382899ca4f4d3a27ff4267899fb64f185..9ef90825c75ac535d3aad463f5742dde49c28137 100644 (file)
@@ -125,7 +125,7 @@ void forward_request(connection_t *from) {
 bool receive_request(connection_t *c) {
        int request;
 
 bool receive_request(connection_t *c) {
        int request;
 
-       if(proxytype == PROXY_HTTP && c->allow_request == ID) {
+       if(c->outgoing && proxytype == PROXY_HTTP && c->allow_request == ID) {
                if(!c->buffer[0] || c->buffer[0] == '\r')
                        return true;
                if(!strncasecmp(c->buffer, "HTTP/1.1 ", 9)) {
                if(!c->buffer[0] || c->buffer[0] == '\r')
                        return true;
                if(!strncasecmp(c->buffer, "HTTP/1.1 ", 9)) {
index 3bd34a01b5743bcf3ee5d354bf4cfdde7bc5c90a..5ae99e821cc4f024d651569d009c5d46fba858ae 100644 (file)
@@ -126,7 +126,7 @@ static bool send_proxyrequest(connection_t *c) {
 }
 
 bool send_id(connection_t *c) {
 }
 
 bool send_id(connection_t *c) {
-       if(proxytype)
+       if(proxytype && c->outgoing)
                if(!send_proxyrequest(c))
                        return false;
 
                if(!send_proxyrequest(c))
                        return false;