2006-09-23 21:09:39 +02:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2012-12-14 17:38:18 +01:00
|
|
|
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2006-09-23 21:09:39 +02:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
|
|
|
* are also available at http://curl.haxx.se/docs/copyright.html.
|
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2012-12-28 12:40:20 +01:00
|
|
|
#include "curl_setup.h"
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2012-09-06 20:51:30 +02:00
|
|
|
#if !defined(CURL_DISABLE_PROXY)
|
2006-09-25 01:55:53 +02:00
|
|
|
|
2007-02-21 19:05:38 +01:00
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#endif
|
2007-02-20 18:31:20 +01:00
|
|
|
#ifdef HAVE_ARPA_INET_H
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#endif
|
2006-09-25 01:55:53 +02:00
|
|
|
|
2012-12-28 12:40:20 +01:00
|
|
|
#include "curl_urldata.h"
|
|
|
|
#include "curl_sendf.h"
|
|
|
|
#include "curl_strequal.h"
|
|
|
|
#include "curl_select.h"
|
|
|
|
#include "curl_connect.h"
|
|
|
|
#include "curl_timeval.h"
|
|
|
|
#include "curl_socks.h"
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
/* The last #include file should be: */
|
2012-12-28 12:40:20 +01:00
|
|
|
#include "curl_memdebug.h"
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Helper read-from-socket functions. Does the same as Curl_read() but it
|
|
|
|
* blocks until all bytes amount of buffersize will be read. No more, no less.
|
|
|
|
*
|
|
|
|
* This is STUPID BLOCKING behaviour which we frown upon, but right now this
|
|
|
|
* is what we have...
|
|
|
|
*/
|
2009-01-28 22:33:58 +01:00
|
|
|
int Curl_blockread_all(struct connectdata *conn, /* connection data */
|
|
|
|
curl_socket_t sockfd, /* read from this socket */
|
|
|
|
char *buf, /* store read data here */
|
|
|
|
ssize_t buffersize, /* max amount to read */
|
2011-08-08 11:10:17 +02:00
|
|
|
ssize_t *n) /* amount bytes read */
|
2006-09-23 21:07:20 +02:00
|
|
|
{
|
|
|
|
ssize_t nread;
|
|
|
|
ssize_t allread = 0;
|
|
|
|
int result;
|
2011-08-08 11:10:17 +02:00
|
|
|
long timeleft;
|
2006-09-23 21:07:20 +02:00
|
|
|
*n = 0;
|
2010-02-02 17:25:07 +01:00
|
|
|
for(;;) {
|
2011-08-08 11:10:17 +02:00
|
|
|
timeleft = Curl_timeleft(conn->data, NULL, TRUE);
|
|
|
|
if(timeleft < 0) {
|
2006-09-23 21:07:20 +02:00
|
|
|
/* we already got the timeout */
|
2010-05-07 15:05:34 +02:00
|
|
|
result = CURLE_OPERATION_TIMEDOUT;
|
2006-10-27 04:18:29 +02:00
|
|
|
break;
|
2006-09-23 21:07:20 +02:00
|
|
|
}
|
2011-08-08 11:10:17 +02:00
|
|
|
if(Curl_socket_ready(sockfd, CURL_SOCKET_BAD, timeleft) <= 0) {
|
2006-10-27 04:18:29 +02:00
|
|
|
result = ~CURLE_OK;
|
|
|
|
break;
|
2006-09-23 21:07:20 +02:00
|
|
|
}
|
2008-09-23 01:12:00 +02:00
|
|
|
result = Curl_read_plain(sockfd, buf, buffersize, &nread);
|
2010-05-07 15:05:34 +02:00
|
|
|
if(CURLE_AGAIN == result)
|
|
|
|
continue;
|
|
|
|
else if(result)
|
2006-10-27 04:18:29 +02:00
|
|
|
break;
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
if(buffersize == nread) {
|
|
|
|
allread += nread;
|
|
|
|
*n = allread;
|
2006-10-27 04:18:29 +02:00
|
|
|
result = CURLE_OK;
|
|
|
|
break;
|
2006-09-23 21:07:20 +02:00
|
|
|
}
|
2007-06-05 15:42:23 +02:00
|
|
|
if(!nread) {
|
|
|
|
result = ~CURLE_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-09-23 21:07:20 +02:00
|
|
|
buffersize -= nread;
|
|
|
|
buf += nread;
|
|
|
|
allread += nread;
|
2010-02-02 17:25:07 +01:00
|
|
|
}
|
2006-10-27 04:18:29 +02:00
|
|
|
return result;
|
2006-09-23 21:07:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function logs in to a SOCKS4 proxy and sends the specifics to the final
|
|
|
|
* destination server.
|
|
|
|
*
|
|
|
|
* Reference :
|
|
|
|
* http://socks.permeo.com/protocol/socks4.protocol
|
|
|
|
*
|
|
|
|
* Note :
|
2008-01-02 22:40:11 +01:00
|
|
|
* Set protocol4a=true for "SOCKS 4A (Simple Extension to SOCKS 4 Protocol)"
|
2006-09-23 21:07:20 +02:00
|
|
|
* Nonsupport "Identification Protocol (RFC1413)"
|
|
|
|
*/
|
|
|
|
CURLcode Curl_SOCKS4(const char *proxy_name,
|
2007-08-27 08:31:28 +02:00
|
|
|
const char *hostname,
|
2007-02-19 12:53:54 +01:00
|
|
|
int remote_port,
|
|
|
|
int sockindex,
|
2008-01-02 22:40:11 +01:00
|
|
|
struct connectdata *conn,
|
|
|
|
bool protocol4a)
|
2006-09-23 21:07:20 +02:00
|
|
|
{
|
2008-01-02 22:40:11 +01:00
|
|
|
#define SOCKS4REQLEN 262
|
|
|
|
unsigned char socksreq[SOCKS4REQLEN]; /* room for SOCKS4 request incl. user
|
|
|
|
id */
|
2006-09-23 21:07:20 +02:00
|
|
|
int result;
|
|
|
|
CURLcode code;
|
2007-02-19 12:53:54 +01:00
|
|
|
curl_socket_t sock = conn->sock[sockindex];
|
2006-09-23 21:07:20 +02:00
|
|
|
struct SessionHandle *data = conn->data;
|
|
|
|
|
2011-08-08 11:10:17 +02:00
|
|
|
if(Curl_timeleft(data, NULL, TRUE) < 0) {
|
2008-02-11 23:03:31 +01:00
|
|
|
/* time-out, bail out, go home */
|
|
|
|
failf(data, "Connection time-out");
|
|
|
|
return CURLE_OPERATION_TIMEDOUT;
|
|
|
|
}
|
|
|
|
|
2009-07-09 23:47:24 +02:00
|
|
|
curlx_nonblock(sock, FALSE);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Compose socks4 request
|
|
|
|
*
|
|
|
|
* Request format
|
|
|
|
*
|
|
|
|
* +----+----+----+----+----+----+----+----+----+----+....+----+
|
|
|
|
* | VN | CD | DSTPORT | DSTIP | USERID |NULL|
|
|
|
|
* +----+----+----+----+----+----+----+----+----+----+....+----+
|
|
|
|
* # of bytes: 1 1 2 4 variable 1
|
|
|
|
*/
|
|
|
|
|
|
|
|
socksreq[0] = 4; /* version (SOCKS4) */
|
|
|
|
socksreq[1] = 1; /* connect */
|
2011-05-26 14:53:13 +02:00
|
|
|
socksreq[2] = (unsigned char)((remote_port >> 8) & 0xff); /* PORT MSB */
|
|
|
|
socksreq[3] = (unsigned char)(remote_port & 0xff); /* PORT LSB */
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2008-01-02 22:40:11 +01:00
|
|
|
/* DNS resolve only for SOCKS4, not SOCKS4a */
|
2011-04-20 15:17:42 +02:00
|
|
|
if(!protocol4a) {
|
2006-09-23 21:07:20 +02:00
|
|
|
struct Curl_dns_entry *dns;
|
|
|
|
Curl_addrinfo *hp=NULL;
|
|
|
|
int rc;
|
|
|
|
|
2007-02-19 12:53:54 +01:00
|
|
|
rc = Curl_resolv(conn, hostname, remote_port, &dns);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
if(rc == CURLRESOLV_ERROR)
|
|
|
|
return CURLE_COULDNT_RESOLVE_PROXY;
|
|
|
|
|
|
|
|
if(rc == CURLRESOLV_PENDING)
|
2010-04-16 23:03:55 +02:00
|
|
|
/* ignores the return code, but 'dns' remains NULL on failure */
|
2011-01-31 00:10:35 +01:00
|
|
|
(void)Curl_resolver_wait_resolv(conn, &dns);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We cannot use 'hostent' as a struct that Curl_resolv() returns. It
|
|
|
|
* returns a Curl_addrinfo pointer that may not always look the same.
|
|
|
|
*/
|
|
|
|
if(dns)
|
|
|
|
hp=dns->addr;
|
2007-11-05 10:45:09 +01:00
|
|
|
if(hp) {
|
2006-09-23 21:07:20 +02:00
|
|
|
char buf[64];
|
|
|
|
unsigned short ip[4];
|
|
|
|
Curl_printable_address(hp, buf, sizeof(buf));
|
|
|
|
|
|
|
|
if(4 == sscanf( buf, "%hu.%hu.%hu.%hu",
|
|
|
|
&ip[0], &ip[1], &ip[2], &ip[3])) {
|
|
|
|
/* Set DSTIP */
|
|
|
|
socksreq[4] = (unsigned char)ip[0];
|
|
|
|
socksreq[5] = (unsigned char)ip[1];
|
|
|
|
socksreq[6] = (unsigned char)ip[2];
|
|
|
|
socksreq[7] = (unsigned char)ip[3];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hp = NULL; /* fail! */
|
|
|
|
|
|
|
|
Curl_resolv_unlock(data, dns); /* not used anymore from now on */
|
|
|
|
|
|
|
|
}
|
|
|
|
if(!hp) {
|
|
|
|
failf(data, "Failed to resolve \"%s\" for SOCKS4 connect.",
|
2007-02-19 12:53:54 +01:00
|
|
|
hostname);
|
2006-09-23 21:07:20 +02:00
|
|
|
return CURLE_COULDNT_RESOLVE_HOST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is currently not supporting "Identification Protocol (RFC1413)".
|
|
|
|
*/
|
|
|
|
socksreq[8] = 0; /* ensure empty userid is NUL-terminated */
|
2007-11-05 10:45:09 +01:00
|
|
|
if(proxy_name)
|
2006-09-23 21:07:20 +02:00
|
|
|
strlcat((char*)socksreq + 8, proxy_name, sizeof(socksreq) - 8);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make connection
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
ssize_t actualread;
|
|
|
|
ssize_t written;
|
2008-01-02 22:40:11 +01:00
|
|
|
ssize_t hostnamelen = 0;
|
2006-09-23 21:07:20 +02:00
|
|
|
int packetsize = 9 +
|
|
|
|
(int)strlen((char*)socksreq + 8); /* size including NUL */
|
|
|
|
|
2008-01-02 22:40:11 +01:00
|
|
|
/* If SOCKS4a, set special invalid IP address 0.0.0.x */
|
2011-04-20 15:17:42 +02:00
|
|
|
if(protocol4a) {
|
2008-01-02 22:40:11 +01:00
|
|
|
socksreq[4] = 0;
|
|
|
|
socksreq[5] = 0;
|
|
|
|
socksreq[6] = 0;
|
|
|
|
socksreq[7] = 1;
|
|
|
|
/* If still enough room in buffer, also append hostname */
|
2008-01-09 20:11:56 +01:00
|
|
|
hostnamelen = (ssize_t)strlen(hostname) + 1; /* length including NUL */
|
2011-04-20 15:17:42 +02:00
|
|
|
if(packetsize + hostnamelen <= SOCKS4REQLEN)
|
2008-01-02 22:40:11 +01:00
|
|
|
strcpy((char*)socksreq + packetsize, hostname);
|
|
|
|
else
|
|
|
|
hostnamelen = 0; /* Flag: hostname did not fit in buffer */
|
|
|
|
}
|
|
|
|
|
2006-09-23 21:07:20 +02:00
|
|
|
/* Send request */
|
2008-06-20 12:43:32 +02:00
|
|
|
code = Curl_write_plain(conn, sock, (char *)socksreq,
|
|
|
|
packetsize + hostnamelen,
|
|
|
|
&written);
|
2008-01-02 22:40:11 +01:00
|
|
|
if((code != CURLE_OK) || (written != packetsize + hostnamelen)) {
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data, "Failed to send SOCKS4 connect request.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
2011-04-20 15:17:42 +02:00
|
|
|
if(protocol4a && hostnamelen == 0) {
|
2008-01-02 22:40:11 +01:00
|
|
|
/* SOCKS4a with very long hostname - send that name separately */
|
2008-01-09 20:11:56 +01:00
|
|
|
hostnamelen = (ssize_t)strlen(hostname) + 1;
|
2008-06-20 12:43:32 +02:00
|
|
|
code = Curl_write_plain(conn, sock, (char *)hostname, hostnamelen,
|
|
|
|
&written);
|
2008-01-02 22:40:11 +01:00
|
|
|
if((code != CURLE_OK) || (written != hostnamelen)) {
|
|
|
|
failf(data, "Failed to send SOCKS4 connect request.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
}
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
packetsize = 8; /* receive data size */
|
|
|
|
|
|
|
|
/* Receive response */
|
2009-01-28 22:33:58 +01:00
|
|
|
result = Curl_blockread_all(conn, sock, (char *)socksreq, packetsize,
|
2011-08-08 11:10:17 +02:00
|
|
|
&actualread);
|
2007-11-05 10:45:09 +01:00
|
|
|
if((result != CURLE_OK) || (actualread != packetsize)) {
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data, "Failed to receive SOCKS4 connect request ack.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Response format
|
|
|
|
*
|
|
|
|
* +----+----+----+----+----+----+----+----+
|
|
|
|
* | VN | CD | DSTPORT | DSTIP |
|
|
|
|
* +----+----+----+----+----+----+----+----+
|
|
|
|
* # of bytes: 1 1 2 4
|
|
|
|
*
|
|
|
|
* VN is the version of the reply code and should be 0. CD is the result
|
|
|
|
* code with one of the following values:
|
|
|
|
*
|
|
|
|
* 90: request granted
|
|
|
|
* 91: request rejected or failed
|
|
|
|
* 92: request rejected because SOCKS server cannot connect to
|
|
|
|
* identd on the client
|
|
|
|
* 93: request rejected because the client program and identd
|
|
|
|
* report different user-ids
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* wrong version ? */
|
2007-11-05 10:45:09 +01:00
|
|
|
if(socksreq[0] != 0) {
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data,
|
|
|
|
"SOCKS4 reply has wrong version, version should be 4.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Result */
|
2011-04-20 15:17:42 +02:00
|
|
|
switch(socksreq[1]) {
|
2006-09-23 21:07:20 +02:00
|
|
|
case 90:
|
2011-08-18 23:28:50 +02:00
|
|
|
infof(data, "SOCKS4%s request granted.\n", protocol4a?"a":"");
|
2006-09-23 21:07:20 +02:00
|
|
|
break;
|
|
|
|
case 91:
|
|
|
|
failf(data,
|
|
|
|
"Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
|
|
|
|
", request rejected or failed.",
|
|
|
|
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
|
|
|
|
(unsigned char)socksreq[6], (unsigned char)socksreq[7],
|
2011-05-26 14:53:13 +02:00
|
|
|
((socksreq[8] << 8) | socksreq[9]),
|
2006-09-23 21:07:20 +02:00
|
|
|
socksreq[1]);
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
case 92:
|
|
|
|
failf(data,
|
|
|
|
"Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
|
|
|
|
", request rejected because SOCKS server cannot connect to "
|
|
|
|
"identd on the client.",
|
|
|
|
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
|
|
|
|
(unsigned char)socksreq[6], (unsigned char)socksreq[7],
|
2011-05-26 14:53:13 +02:00
|
|
|
((socksreq[8] << 8) | socksreq[9]),
|
2006-09-23 21:07:20 +02:00
|
|
|
socksreq[1]);
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
case 93:
|
|
|
|
failf(data,
|
|
|
|
"Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
|
|
|
|
", request rejected because the client program and identd "
|
|
|
|
"report different user-ids.",
|
|
|
|
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
|
|
|
|
(unsigned char)socksreq[6], (unsigned char)socksreq[7],
|
2011-05-26 14:53:13 +02:00
|
|
|
((socksreq[8] << 8) | socksreq[9]),
|
2006-09-23 21:07:20 +02:00
|
|
|
socksreq[1]);
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
default:
|
|
|
|
failf(data,
|
|
|
|
"Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
|
|
|
|
", Unknown.",
|
|
|
|
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
|
|
|
|
(unsigned char)socksreq[6], (unsigned char)socksreq[7],
|
2011-05-26 14:53:13 +02:00
|
|
|
((socksreq[8] << 8) | socksreq[9]),
|
2006-09-23 21:07:20 +02:00
|
|
|
socksreq[1]);
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-09 23:47:24 +02:00
|
|
|
curlx_nonblock(sock, TRUE);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
return CURLE_OK; /* Proxy was successful! */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function logs in to a SOCKS5 proxy and sends the specifics to the final
|
|
|
|
* destination server.
|
|
|
|
*/
|
|
|
|
CURLcode Curl_SOCKS5(const char *proxy_name,
|
|
|
|
const char *proxy_password,
|
2007-08-27 08:31:28 +02:00
|
|
|
const char *hostname,
|
2007-02-19 12:53:54 +01:00
|
|
|
int remote_port,
|
|
|
|
int sockindex,
|
2006-09-23 21:07:20 +02:00
|
|
|
struct connectdata *conn)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
According to the RFC1928, section "6. Replies". This is what a SOCK5
|
|
|
|
replies:
|
|
|
|
|
|
|
|
+----+-----+-------+------+----------+----------+
|
|
|
|
|VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |
|
|
|
|
+----+-----+-------+------+----------+----------+
|
|
|
|
| 1 | 1 | X'00' | 1 | Variable | 2 |
|
|
|
|
+----+-----+-------+------+----------+----------+
|
|
|
|
|
|
|
|
Where:
|
|
|
|
|
|
|
|
o VER protocol version: X'05'
|
|
|
|
o REP Reply field:
|
|
|
|
o X'00' succeeded
|
|
|
|
*/
|
|
|
|
|
|
|
|
unsigned char socksreq[600]; /* room for large user/pw (255 max each) */
|
|
|
|
ssize_t actualread;
|
|
|
|
ssize_t written;
|
|
|
|
int result;
|
|
|
|
CURLcode code;
|
2007-02-19 12:53:54 +01:00
|
|
|
curl_socket_t sock = conn->sock[sockindex];
|
2006-09-23 21:07:20 +02:00
|
|
|
struct SessionHandle *data = conn->data;
|
|
|
|
long timeout;
|
2011-09-05 20:46:09 +02:00
|
|
|
bool socks5_resolve_local = (conn->proxytype == CURLPROXY_SOCKS5)?TRUE:FALSE;
|
2008-01-05 00:01:00 +01:00
|
|
|
const size_t hostname_len = strlen(hostname);
|
2012-10-04 21:27:46 +02:00
|
|
|
ssize_t len = 0;
|
2008-01-05 00:01:00 +01:00
|
|
|
|
|
|
|
/* RFC1928 chapter 5 specifies max 255 chars for domain name in packet */
|
2011-04-20 15:17:42 +02:00
|
|
|
if(!socks5_resolve_local && hostname_len > 255) {
|
2008-01-05 00:01:00 +01:00
|
|
|
infof(conn->data,"SOCKS5: server resolving disabled for hostnames of "
|
2010-02-04 20:44:31 +01:00
|
|
|
"length > 255 [actual len=%zu]\n", hostname_len);
|
2008-01-05 00:01:00 +01:00
|
|
|
socks5_resolve_local = TRUE;
|
|
|
|
}
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
/* get timeout */
|
2011-01-04 23:07:58 +01:00
|
|
|
timeout = Curl_timeleft(data, NULL, TRUE);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2008-02-11 23:03:31 +01:00
|
|
|
if(timeout < 0) {
|
|
|
|
/* time-out, bail out, go home */
|
|
|
|
failf(data, "Connection time-out");
|
|
|
|
return CURLE_OPERATION_TIMEDOUT;
|
|
|
|
}
|
|
|
|
|
2009-07-09 23:47:24 +02:00
|
|
|
curlx_nonblock(sock, TRUE);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
/* wait until socket gets connected */
|
2011-06-04 21:19:14 +02:00
|
|
|
result = Curl_socket_ready(CURL_SOCKET_BAD, sock, timeout);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
if(-1 == result) {
|
|
|
|
failf(conn->data, "SOCKS5: no connection here");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
else if(0 == result) {
|
|
|
|
failf(conn->data, "SOCKS5: connection timeout");
|
|
|
|
return CURLE_OPERATION_TIMEDOUT;
|
|
|
|
}
|
|
|
|
|
2007-04-16 18:34:08 +02:00
|
|
|
if(result & CURL_CSELECT_ERR) {
|
2011-04-19 15:54:13 +02:00
|
|
|
failf(conn->data, "SOCKS5: error occurred during connection");
|
2006-09-23 21:07:20 +02:00
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
socksreq[0] = 5; /* version */
|
2009-01-28 22:33:58 +01:00
|
|
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
|
|
|
socksreq[1] = (char)(proxy_name ? 3 : 2); /* number of methods (below) */
|
|
|
|
socksreq[2] = 0; /* no authentication */
|
|
|
|
socksreq[3] = 1; /* gssapi */
|
|
|
|
socksreq[4] = 2; /* username/password */
|
|
|
|
#else
|
2006-09-23 21:07:20 +02:00
|
|
|
socksreq[1] = (char)(proxy_name ? 2 : 1); /* number of methods (below) */
|
|
|
|
socksreq[2] = 0; /* no authentication */
|
|
|
|
socksreq[3] = 2; /* username/password */
|
2009-01-28 22:33:58 +01:00
|
|
|
#endif
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2009-07-09 23:47:24 +02:00
|
|
|
curlx_nonblock(sock, FALSE);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2008-06-20 12:43:32 +02:00
|
|
|
code = Curl_write_plain(conn, sock, (char *)socksreq, (2 + (int)socksreq[1]),
|
|
|
|
&written);
|
2007-11-05 10:45:09 +01:00
|
|
|
if((code != CURLE_OK) || (written != (2 + (int)socksreq[1]))) {
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data, "Unable to send initial SOCKS5 request.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
|
2009-07-09 23:47:24 +02:00
|
|
|
curlx_nonblock(sock, TRUE);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2011-06-04 21:19:14 +02:00
|
|
|
result = Curl_socket_ready(sock, CURL_SOCKET_BAD, timeout);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
if(-1 == result) {
|
|
|
|
failf(conn->data, "SOCKS5 nothing to read");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
else if(0 == result) {
|
|
|
|
failf(conn->data, "SOCKS5 read timeout");
|
|
|
|
return CURLE_OPERATION_TIMEDOUT;
|
|
|
|
}
|
|
|
|
|
2007-04-16 18:34:08 +02:00
|
|
|
if(result & CURL_CSELECT_ERR) {
|
2011-04-19 15:54:13 +02:00
|
|
|
failf(conn->data, "SOCKS5 read error occurred");
|
2006-09-23 21:07:20 +02:00
|
|
|
return CURLE_RECV_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-07-09 23:47:24 +02:00
|
|
|
curlx_nonblock(sock, FALSE);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2011-08-08 11:10:17 +02:00
|
|
|
result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
|
2007-11-05 10:45:09 +01:00
|
|
|
if((result != CURLE_OK) || (actualread != 2)) {
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data, "Unable to receive initial SOCKS5 response.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
|
2007-11-05 10:45:09 +01:00
|
|
|
if(socksreq[0] != 5) {
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data, "Received invalid version in initial SOCKS5 response.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
2007-11-05 10:45:09 +01:00
|
|
|
if(socksreq[1] == 0) {
|
2006-09-23 21:07:20 +02:00
|
|
|
/* Nothing to do, no authentication needed */
|
|
|
|
;
|
|
|
|
}
|
2009-01-28 22:33:58 +01:00
|
|
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
|
|
|
else if(socksreq[1] == 1) {
|
|
|
|
code = Curl_SOCKS5_gssapi_negotiate(sockindex, conn);
|
|
|
|
if(code != CURLE_OK) {
|
|
|
|
failf(data, "Unable to negotiate SOCKS5 gssapi context.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2007-11-05 10:45:09 +01:00
|
|
|
else if(socksreq[1] == 2) {
|
2006-09-23 21:07:20 +02:00
|
|
|
/* Needs user name and password */
|
2012-10-04 20:17:49 +02:00
|
|
|
size_t proxy_name_len, proxy_password_len;
|
2006-09-23 21:07:20 +02:00
|
|
|
if(proxy_name && proxy_password) {
|
2012-10-04 20:17:49 +02:00
|
|
|
proxy_name_len = strlen(proxy_name);
|
|
|
|
proxy_password_len = strlen(proxy_password);
|
2006-09-23 21:07:20 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-10-04 20:17:49 +02:00
|
|
|
proxy_name_len = 0;
|
|
|
|
proxy_password_len = 0;
|
2006-09-23 21:07:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* username/password request looks like
|
|
|
|
* +----+------+----------+------+----------+
|
|
|
|
* |VER | ULEN | UNAME | PLEN | PASSWD |
|
|
|
|
* +----+------+----------+------+----------+
|
|
|
|
* | 1 | 1 | 1 to 255 | 1 | 1 to 255 |
|
|
|
|
* +----+------+----------+------+----------+
|
|
|
|
*/
|
|
|
|
len = 0;
|
|
|
|
socksreq[len++] = 1; /* username/pw subnegotiation version */
|
2012-10-04 20:17:49 +02:00
|
|
|
socksreq[len++] = (unsigned char) proxy_name_len;
|
|
|
|
if(proxy_name && proxy_name_len)
|
|
|
|
memcpy(socksreq + len, proxy_name, proxy_name_len);
|
|
|
|
len += proxy_name_len;
|
|
|
|
socksreq[len++] = (unsigned char) proxy_password_len;
|
|
|
|
if(proxy_password && proxy_password_len)
|
|
|
|
memcpy(socksreq + len, proxy_password, proxy_password_len);
|
|
|
|
len += proxy_password_len;
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2008-06-20 12:43:32 +02:00
|
|
|
code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written);
|
2007-11-05 10:45:09 +01:00
|
|
|
if((code != CURLE_OK) || (len != written)) {
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data, "Failed to send SOCKS5 sub-negotiation request.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
|
2011-08-08 11:10:17 +02:00
|
|
|
result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
|
2007-11-05 10:45:09 +01:00
|
|
|
if((result != CURLE_OK) || (actualread != 2)) {
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ignore the first (VER) byte */
|
2007-11-05 10:45:09 +01:00
|
|
|
if(socksreq[1] != 0) { /* status */
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data, "User was rejected by the SOCKS5 server (%d %d).",
|
|
|
|
socksreq[0], socksreq[1]);
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Everything is good so far, user was authenticated! */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* error */
|
2009-01-28 22:33:58 +01:00
|
|
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
|
|
|
if(socksreq[1] == 255) {
|
|
|
|
#else
|
2007-11-05 10:45:09 +01:00
|
|
|
if(socksreq[1] == 1) {
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data,
|
|
|
|
"SOCKS5 GSSAPI per-message authentication is not supported.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
2007-11-05 10:45:09 +01:00
|
|
|
else if(socksreq[1] == 255) {
|
2009-01-28 22:33:58 +01:00
|
|
|
#endif
|
2007-11-05 10:45:09 +01:00
|
|
|
if(!proxy_name || !*proxy_name) {
|
2006-09-23 21:07:20 +02:00
|
|
|
failf(data,
|
|
|
|
"No authentication method was acceptable. (It is quite likely"
|
|
|
|
" that the SOCKS5 server wanted a username/password, since none"
|
|
|
|
" was supplied to the server on this connection.)");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
failf(data, "No authentication method was acceptable.");
|
|
|
|
}
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
failf(data,
|
|
|
|
"Undocumented SOCKS5 mode attempted to be used by server.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Authentication is complete, now specify destination to the proxy */
|
2012-09-10 12:44:37 +02:00
|
|
|
len = 0;
|
|
|
|
socksreq[len++] = 5; /* version (SOCKS5) */
|
|
|
|
socksreq[len++] = 1; /* connect */
|
|
|
|
socksreq[len++] = 0; /* must be zero */
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2008-01-05 00:01:00 +01:00
|
|
|
if(!socks5_resolve_local) {
|
2012-09-10 12:44:37 +02:00
|
|
|
socksreq[len++] = 3; /* ATYP: domain name = 3 */
|
|
|
|
socksreq[len++] = (char) hostname_len; /* address length */
|
2012-09-14 00:44:16 +02:00
|
|
|
memcpy(&socksreq[len], hostname, hostname_len); /* address str w/o NULL */
|
2012-10-04 20:17:49 +02:00
|
|
|
len += hostname_len;
|
2008-01-05 00:01:00 +01:00
|
|
|
}
|
|
|
|
else {
|
2006-09-23 21:07:20 +02:00
|
|
|
struct Curl_dns_entry *dns;
|
2012-09-10 12:44:37 +02:00
|
|
|
Curl_addrinfo *hp = NULL;
|
2007-02-19 12:53:54 +01:00
|
|
|
int rc = Curl_resolv(conn, hostname, remote_port, &dns);
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
if(rc == CURLRESOLV_ERROR)
|
|
|
|
return CURLE_COULDNT_RESOLVE_HOST;
|
|
|
|
|
2010-04-16 22:58:04 +02:00
|
|
|
if(rc == CURLRESOLV_PENDING) {
|
2006-09-23 21:07:20 +02:00
|
|
|
/* this requires that we're in "wait for resolve" state */
|
2011-01-31 00:10:35 +01:00
|
|
|
code = Curl_resolver_wait_resolv(conn, &dns);
|
2010-05-31 16:36:05 +02:00
|
|
|
if(code != CURLE_OK)
|
|
|
|
return code;
|
2010-04-16 22:58:04 +02:00
|
|
|
}
|
2006-09-23 21:07:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We cannot use 'hostent' as a struct that Curl_resolv() returns. It
|
|
|
|
* returns a Curl_addrinfo pointer that may not always look the same.
|
|
|
|
*/
|
|
|
|
if(dns)
|
|
|
|
hp=dns->addr;
|
2007-11-05 10:45:09 +01:00
|
|
|
if(hp) {
|
2012-09-10 12:44:37 +02:00
|
|
|
struct sockaddr_in *saddr_in;
|
2012-09-14 08:12:07 +02:00
|
|
|
#ifdef ENABLE_IPV6
|
2012-09-10 12:44:37 +02:00
|
|
|
struct sockaddr_in6 *saddr_in6;
|
2012-09-14 08:12:07 +02:00
|
|
|
#endif
|
2012-09-10 12:44:37 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if(hp->ai_family == AF_INET) {
|
2012-09-14 00:44:16 +02:00
|
|
|
socksreq[len++] = 1; /* ATYP: IPv4 = 1 */
|
2012-09-10 12:44:37 +02:00
|
|
|
|
|
|
|
saddr_in = (struct sockaddr_in*)hp->ai_addr;
|
|
|
|
for(i = 0; i < 4; i++) {
|
|
|
|
socksreq[len++] = ((unsigned char*)&saddr_in->sin_addr.s_addr)[i];
|
|
|
|
infof(data, "%d\n", socksreq[len-1]);
|
|
|
|
}
|
|
|
|
}
|
2012-09-14 08:12:07 +02:00
|
|
|
#ifdef ENABLE_IPV6
|
2012-09-10 12:44:37 +02:00
|
|
|
else if(hp->ai_family == AF_INET6) {
|
2012-09-14 00:44:16 +02:00
|
|
|
socksreq[len++] = 4; /* ATYP: IPv6 = 4 */
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2012-09-10 12:44:37 +02:00
|
|
|
saddr_in6 = (struct sockaddr_in6*)hp->ai_addr;
|
|
|
|
for(i = 0; i < 16; i++) {
|
|
|
|
socksreq[len++] = ((unsigned char*)&saddr_in6->sin6_addr.s6_addr)[i];
|
|
|
|
}
|
2006-09-23 21:07:20 +02:00
|
|
|
}
|
2012-09-14 08:12:07 +02:00
|
|
|
#endif
|
2006-09-23 21:07:20 +02:00
|
|
|
else
|
|
|
|
hp = NULL; /* fail! */
|
|
|
|
|
|
|
|
Curl_resolv_unlock(data, dns); /* not used anymore from now on */
|
|
|
|
}
|
|
|
|
if(!hp) {
|
|
|
|
failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.",
|
2007-02-19 12:53:54 +01:00
|
|
|
hostname);
|
2006-09-23 21:07:20 +02:00
|
|
|
return CURLE_COULDNT_RESOLVE_HOST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-10 12:44:37 +02:00
|
|
|
socksreq[len++] = (unsigned char)((remote_port >> 8) & 0xff); /* PORT MSB */
|
|
|
|
socksreq[len++] = (unsigned char)(remote_port & 0xff); /* PORT LSB */
|
|
|
|
|
2009-01-28 22:33:58 +01:00
|
|
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
|
|
|
if(conn->socks5_gssapi_enctype) {
|
|
|
|
failf(data, "SOCKS5 gssapi protection not yet implemented.");
|
2011-04-20 15:17:42 +02:00
|
|
|
}
|
|
|
|
else
|
2009-01-28 22:33:58 +01:00
|
|
|
#endif
|
2012-10-04 21:27:46 +02:00
|
|
|
code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written);
|
|
|
|
|
|
|
|
if((code != CURLE_OK) || (len != written)) {
|
2008-01-05 00:01:00 +01:00
|
|
|
failf(data, "Failed to send SOCKS5 connect request.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2012-10-04 21:27:46 +02:00
|
|
|
len = 10; /* minimum packet size is 10 */
|
2008-01-05 00:01:00 +01:00
|
|
|
|
2009-01-28 22:33:58 +01:00
|
|
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
|
|
|
if(conn->socks5_gssapi_enctype) {
|
|
|
|
failf(data, "SOCKS5 gssapi protection not yet implemented.");
|
2011-04-20 15:17:42 +02:00
|
|
|
}
|
|
|
|
else
|
2009-01-28 22:33:58 +01:00
|
|
|
#endif
|
2012-10-04 21:27:46 +02:00
|
|
|
result = Curl_blockread_all(conn, sock, (char *)socksreq,
|
|
|
|
len, &actualread);
|
|
|
|
|
|
|
|
if((result != CURLE_OK) || (len != actualread)) {
|
2008-01-05 00:01:00 +01:00
|
|
|
failf(data, "Failed to receive SOCKS5 connect request ack.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2008-01-05 00:01:00 +01:00
|
|
|
if(socksreq[0] != 5) { /* version */
|
|
|
|
failf(data,
|
|
|
|
"SOCKS5 reply has wrong version, version should be 5.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
|
|
|
if(socksreq[1] != 0) { /* Anything besides 0 is an error */
|
2012-09-10 12:46:25 +02:00
|
|
|
if(socksreq[3] == 1) {
|
2008-01-05 00:01:00 +01:00
|
|
|
failf(data,
|
|
|
|
"Can't complete SOCKS5 connection to %d.%d.%d.%d:%d. (%d)",
|
|
|
|
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
|
|
|
|
(unsigned char)socksreq[6], (unsigned char)socksreq[7],
|
2011-05-26 14:53:13 +02:00
|
|
|
((socksreq[8] << 8) | socksreq[9]),
|
2008-01-05 00:01:00 +01:00
|
|
|
socksreq[1]);
|
2012-09-10 12:46:25 +02:00
|
|
|
}
|
|
|
|
else if(socksreq[3] == 3) {
|
|
|
|
failf(data,
|
|
|
|
"Can't complete SOCKS5 connection to %s:%d. (%d)",
|
|
|
|
hostname,
|
|
|
|
((socksreq[8] << 8) | socksreq[9]),
|
|
|
|
socksreq[1]);
|
|
|
|
}
|
|
|
|
else if(socksreq[3] == 4) {
|
|
|
|
failf(data,
|
|
|
|
"Can't complete SOCKS5 connection to %02x%02x:%02x%02x:"
|
|
|
|
"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%d. (%d)",
|
|
|
|
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
|
|
|
|
(unsigned char)socksreq[6], (unsigned char)socksreq[7],
|
|
|
|
(unsigned char)socksreq[8], (unsigned char)socksreq[9],
|
|
|
|
(unsigned char)socksreq[10], (unsigned char)socksreq[11],
|
|
|
|
(unsigned char)socksreq[12], (unsigned char)socksreq[13],
|
|
|
|
(unsigned char)socksreq[14], (unsigned char)socksreq[15],
|
|
|
|
(unsigned char)socksreq[16], (unsigned char)socksreq[17],
|
|
|
|
(unsigned char)socksreq[18], (unsigned char)socksreq[19],
|
|
|
|
((socksreq[8] << 8) | socksreq[9]),
|
|
|
|
socksreq[1]);
|
|
|
|
}
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
2008-01-05 00:01:00 +01:00
|
|
|
}
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2008-01-05 00:01:00 +01:00
|
|
|
/* Fix: in general, returned BND.ADDR is variable length parameter by RFC
|
|
|
|
1928, so the reply packet should be read until the end to avoid errors at
|
|
|
|
subsequent protocol level.
|
|
|
|
|
|
|
|
+----+-----+-------+------+----------+----------+
|
|
|
|
|VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |
|
|
|
|
+----+-----+-------+------+----------+----------+
|
|
|
|
| 1 | 1 | X'00' | 1 | Variable | 2 |
|
|
|
|
+----+-----+-------+------+----------+----------+
|
|
|
|
|
|
|
|
ATYP:
|
|
|
|
o IP v4 address: X'01', BND.ADDR = 4 byte
|
|
|
|
o domain name: X'03', BND.ADDR = [ 1 byte length, string ]
|
|
|
|
o IP v6 address: X'04', BND.ADDR = 16 byte
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Calculate real packet size */
|
|
|
|
if(socksreq[3] == 3) {
|
|
|
|
/* domain name */
|
|
|
|
int addrlen = (int) socksreq[4];
|
2012-10-04 21:27:46 +02:00
|
|
|
len = 5 + addrlen + 2;
|
2008-01-05 00:01:00 +01:00
|
|
|
}
|
|
|
|
else if(socksreq[3] == 4) {
|
|
|
|
/* IPv6 */
|
2012-10-04 21:27:46 +02:00
|
|
|
len = 4 + 16 + 2;
|
2008-01-05 00:01:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* At this point we already read first 10 bytes */
|
2009-01-28 22:33:58 +01:00
|
|
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
|
|
|
if(!conn->socks5_gssapi_enctype) {
|
|
|
|
/* decrypt_gssapi_blockread already read the whole packet */
|
|
|
|
#endif
|
2012-10-04 21:27:46 +02:00
|
|
|
if(len > 10) {
|
|
|
|
len -= 10;
|
2009-01-28 22:33:58 +01:00
|
|
|
result = Curl_blockread_all(conn, sock, (char *)&socksreq[10],
|
2012-10-04 21:27:46 +02:00
|
|
|
len, &actualread);
|
|
|
|
if((result != CURLE_OK) || (len != actualread)) {
|
2009-01-28 22:33:58 +01:00
|
|
|
failf(data, "Failed to receive SOCKS5 connect request ack.");
|
|
|
|
return CURLE_COULDNT_CONNECT;
|
|
|
|
}
|
2006-09-23 21:07:20 +02:00
|
|
|
}
|
2009-01-28 22:33:58 +01:00
|
|
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
2006-09-23 21:07:20 +02:00
|
|
|
}
|
2009-01-28 22:33:58 +01:00
|
|
|
#endif
|
2006-09-23 21:07:20 +02:00
|
|
|
|
2009-07-09 23:47:24 +02:00
|
|
|
curlx_nonblock(sock, TRUE);
|
2006-09-23 21:07:20 +02:00
|
|
|
return CURLE_OK; /* Proxy was successful! */
|
|
|
|
}
|
2008-09-29 23:46:04 +02:00
|
|
|
|
|
|
|
#endif /* CURL_DISABLE_PROXY */
|
|
|
|
|