X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fproxy.c;h=52682721072cc64a561e556d02c163aa2d965a5d;hp=2b8f87c13e36dcc5d32e47968ae8f33b2c14ae3c;hb=19c0337c4cac78dc302d5a1f637dcad45785a6e3;hpb=30cc8541cca61368dc2c5de7452a8dd5456308d7 diff --git a/src/proxy.c b/src/proxy.c index 2b8f87c1..52682721 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1,6 +1,6 @@ /* proxy.c -- Proxy handling functions. - Copyright (C) 2015 Guus Sliepen + Copyright (C) 2015-2016 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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; } @@ -257,8 +261,8 @@ int receive_proxy_meta(connection_t *c, int start, int lenin) { if(!p || p - c->buffer >= c->buflen) return 0; - while(p = memchr(p + 1, '\n', c->buflen - (p + 1 - c->buffer))) { - if(p[-1] == '\n') + while((p = memchr(p + 1, '\n', c->buflen - (p + 1 - c->buffer)))) { + if(p > c->buffer + 3 && !memcmp(p - 3, "\r\n\r\n", 4)) break; } @@ -275,8 +279,12 @@ 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); + p[-1] = 0; logger(LOG_ERR, "Proxy request rejected: %s", c->buffer + 9); return false; }