-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 $
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))
{
{
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);
}
}
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);