-const char gateway_rcs[] = "$Id: gateway.c,v 1.79 2011/10/16 12:37:12 fabiankeil Exp $";
+const char gateway_rcs[] = "$Id: gateway.c,v 1.86 2012/03/09 17:55:50 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/gateway.c,v $
c->vn = 4;
c->cd = 1;
- c->dstport[0] = (unsigned char)((target_port >> 8 ) & 0xff);
- c->dstport[1] = (unsigned char)((target_port ) & 0xff);
- c->dstip[0] = (unsigned char)((web_server_addr >> 24 ) & 0xff);
- c->dstip[1] = (unsigned char)((web_server_addr >> 16 ) & 0xff);
- c->dstip[2] = (unsigned char)((web_server_addr >> 8 ) & 0xff);
- c->dstip[3] = (unsigned char)((web_server_addr ) & 0xff);
+ c->dstport[0] = (unsigned char)((target_port >> 8 ) & 0xff);
+ c->dstport[1] = (unsigned char)((target_port ) & 0xff);
+ c->dstip[0] = (unsigned char)((web_server_addr >> 24) & 0xff);
+ c->dstip[1] = (unsigned char)((web_server_addr >> 16) & 0xff);
+ c->dstip[2] = (unsigned char)((web_server_addr >> 8) & 0xff);
+ c->dstip[3] = (unsigned char)((web_server_addr ) & 0xff);
/* pass the request to the socks server */
sfd = connect_to(fwd->gateway_host, fwd->gateway_port, csp);
/* The error an its reason have already been logged by connect_to() */
return(JB_INVALID_SOCKET);
}
+ else if (write_socket(sfd, (char *)c, csiz))
+ {
+ errstr = "SOCKS4 negotiation write failed.";
+ log_error(LOG_LEVEL_CONNECT, "socks4_connect: %s", errstr);
+ err = 1;
+ close_socket(sfd);
+ }
else if (!data_is_available(sfd, csp->config->socket_timeout))
{
if (socket_is_still_alive(sfd))
err = 1;
close_socket(sfd);
}
- else if (write_socket(sfd, (char *)c, csiz))
- {
- errstr = "SOCKS4 negotiation write failed.";
- log_error(LOG_LEVEL_CONNECT, "socks4_connect: %s", errstr);
- err = 1;
- close_socket(sfd);
- }
else if (read_socket(sfd, buf, sizeof(buf)) != sizeof(*s))
{
errstr = "SOCKS4 negotiation read failed.";
if (server_size != sizeof(sbuf))
{
errstr = "SOCKS5 negotiation read failed";
- err = 1;
}
-
- if (!err)
+ else
{
if (sbuf[0] != '\x05')
{