X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=gateway.c;h=bd5f2888176d3a30fefeb1408ff45ec1fa3594e5;hb=55084ab600988333a56a957debf2facde59beaab;hp=c6b6db0eeb53249542f0f818bc60365a865ee36c;hpb=87c40a0c37a9e9b067e94d0685901adde683b026;p=privoxy.git diff --git a/gateway.c b/gateway.c index c6b6db0e..bd5f2888 100644 --- a/gateway.c +++ b/gateway.c @@ -1,4 +1,4 @@ -const char gateway_rcs[] = "$Id: gateway.c,v 1.70 2011/02/19 13:55:57 fabiankeil Exp $"; +const char gateway_rcs[] = "$Id: gateway.c,v 1.74 2011/07/17 13:31:35 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/gateway.c,v $ @@ -809,12 +809,8 @@ static jb_socket socks4_connect(const struct forward_spec * fwd, if (sfd == JB_INVALID_SOCKET) { - /* - * XXX: connect_to should fill in the exact reason. - * Most likely resolving the IP of the forwarder failed. - */ - errstr = "connect_to failed: see logfile for details"; - err = 1; + /* The error an its reason have already been logged by connect_to() */ + return(JB_INVALID_SOCKET); } else if (!data_is_available(sfd, csp->config->socket_timeout)) { @@ -1007,6 +1003,8 @@ static jb_socket socks5_connect(const struct forward_spec *fwd, { errstr = "socks5 server unreachable"; log_error(LOG_LEVEL_CONNECT, "socks5_connect: %s", errstr); + /* Free the generic error message provided by connect_to() */ + freez(csp->error_message); csp->error_message = strdup(errstr); return(JB_INVALID_SOCKET); } @@ -1103,31 +1101,30 @@ static jb_socket socks5_connect(const struct forward_spec *fwd, } else if (server_size > 20) { - /* This is somewhat unexpected but doesn't realy matter. */ + /* This is somewhat unexpected but doesn't really matter. */ log_error(LOG_LEVEL_CONNECT, "socks5_connect: read %d bytes " "from socks server. Would have accepted up to %d.", server_size, sizeof(sbuf)); } - if (!err && (sbuf[0] != '\x05')) - { - errstr = "SOCKS5 negotiation protocol version error"; - err = 1; - } - - if (!err && (sbuf[2] != '\x00')) - { - errstr = "SOCKS5 negotiation protocol error"; - err = 1; - } - if (!err) { - if (sbuf[1] == SOCKS5_REQUEST_GRANTED) + if (sbuf[0] != '\x05') + { + errstr = "SOCKS5 negotiation protocol version error"; + } + else if (sbuf[2] != '\x00') + { + errstr = "SOCKS5 negotiation protocol error"; + } + else if (sbuf[1] != SOCKS5_REQUEST_GRANTED) + { + errstr = translate_socks5_error(sbuf[1]); + } + else { return(sfd); } - errstr = translate_socks5_error(sbuf[1]); } assert(errstr != NULL);