X-Git-Url: https://git.librecmc.org/?p=oweals%2Ftinc.git;a=blobdiff_plain;f=src%2Fproxy.c;h=f7c2560d6d519426cc49d28f8d1e3928bcf24ed1;hp=2b8f87c13e36dcc5d32e47968ae8f33b2c14ae3c;hb=87438e342ce96b4321343c69b77ed84b16853785;hpb=30cc8541cca61368dc2c5de7452a8dd5456308d7 diff --git a/src/proxy.c b/src/proxy.c index 2b8f87c..f7c2560 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 @@ -174,6 +174,8 @@ bool send_proxyrequest(connection_t *c) { } case PROXY_EXEC: + c->status.proxy_passed = true; + send_id(c); return true; default: @@ -194,6 +196,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 +253,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 +263,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 +281,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; }