Don't send proxy requests for incoming connections.

This commit is contained in:
Guus Sliepen 2013-02-07 14:22:28 +01:00
parent ee63f2a32b
commit 079dcd0179
4 changed files with 5 additions and 7 deletions

View file

@ -189,14 +189,14 @@ bool receive_meta(connection_t *c) {
break; break;
if(!c->node) { if(!c->node) {
if(proxytype == PROXY_SOCKS4 && c->allow_request == ID) { if(c->outgoing && proxytype == PROXY_SOCKS4 && c->allow_request == ID) {
if(tcpbuffer[0] == 0 && tcpbuffer[1] == 0x5a) { if(tcpbuffer[0] == 0 && tcpbuffer[1] == 0x5a) {
logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Proxy request granted"); logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Proxy request granted");
} else { } else {
logger(DEBUG_CONNECTIONS, LOG_ERR, "Proxy request rejected"); logger(DEBUG_CONNECTIONS, LOG_ERR, "Proxy request rejected");
return false; return false;
} }
} else if(proxytype == PROXY_SOCKS5 && c->allow_request == ID) { } else if(c->outgoing && proxytype == PROXY_SOCKS5 && c->allow_request == ID) {
if(tcpbuffer[0] != 5) { if(tcpbuffer[0] != 5) {
logger(DEBUG_CONNECTIONS, LOG_ERR, "Invalid response from proxy server"); logger(DEBUG_CONNECTIONS, LOG_ERR, "Invalid response from proxy server");
return false; return false;

View file

@ -294,9 +294,6 @@ void retry_outgoing(outgoing_t *outgoing) {
void finish_connecting(connection_t *c) { void finish_connecting(connection_t *c) {
logger(DEBUG_CONNECTIONS, LOG_INFO, "Connected to %s (%s)", c->name, c->hostname); logger(DEBUG_CONNECTIONS, LOG_INFO, "Connected to %s (%s)", c->name, c->hostname);
if(proxytype != PROXY_EXEC)
configure_tcp(c);
c->last_ping_time = time(NULL); c->last_ping_time = time(NULL);
c->status.connecting = false; c->status.connecting = false;
@ -459,6 +456,7 @@ begin:
} }
logger(DEBUG_CONNECTIONS, LOG_INFO, "Using proxy at %s port %s", proxyhost, proxyport); logger(DEBUG_CONNECTIONS, LOG_INFO, "Using proxy at %s port %s", proxyhost, proxyport);
c->socket = socket(proxyai->ai_family, SOCK_STREAM, IPPROTO_TCP); c->socket = socket(proxyai->ai_family, SOCK_STREAM, IPPROTO_TCP);
configure_tcp(c);
} }
if(c->socket == -1) { if(c->socket == -1) {

View file

@ -111,7 +111,7 @@ void forward_request(connection_t *from, const char *request) {
} }
bool receive_request(connection_t *c, const char *request) { bool receive_request(connection_t *c, const char *request) {
if(proxytype == PROXY_HTTP && c->allow_request == ID) { if(c->outgoing && proxytype == PROXY_HTTP && c->allow_request == ID) {
if(!request[0] || request[0] == '\r') if(!request[0] || request[0] == '\r')
return true; return true;
if(!strncasecmp(request, "HTTP/1.1 ", 9)) { if(!strncasecmp(request, "HTTP/1.1 ", 9)) {

View file

@ -139,7 +139,7 @@ bool send_id(connection_t *c) {
minor = myself->connection->protocol_minor; minor = myself->connection->protocol_minor;
} }
if(proxytype) if(proxytype && c->outgoing)
if(!send_proxyrequest(c)) if(!send_proxyrequest(c))
return false; return false;