1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 #include "curl_setup.h"
25 #if !defined(CURL_DISABLE_PROXY)
27 #ifdef HAVE_NETINET_IN_H
28 #include <netinet/in.h>
30 #ifdef HAVE_ARPA_INET_H
31 #include <arpa/inet.h>
41 /* The last #include file should be: */
45 * Helper read-from-socket functions. Does the same as Curl_read() but it
46 * blocks until all bytes amount of buffersize will be read. No more, no less.
48 * This is STUPID BLOCKING behaviour which we frown upon, but right now this
51 int Curl_blockread_all(struct connectdata *conn, /* connection data */
52 curl_socket_t sockfd, /* read from this socket */
53 char *buf, /* store read data here */
54 ssize_t buffersize, /* max amount to read */
55 ssize_t *n) /* amount bytes read */
63 timeleft = Curl_timeleft(conn->data, NULL, TRUE);
65 /* we already got the timeout */
66 result = CURLE_OPERATION_TIMEDOUT;
69 if(SOCKET_READABLE(sockfd, timeleft) <= 0) {
73 result = Curl_read_plain(sockfd, buf, buffersize, &nread);
74 if(CURLE_AGAIN == result)
79 if(buffersize == nread) {
98 * This function logs in to a SOCKS4 proxy and sends the specifics to the final
102 * http://socks.permeo.com/protocol/socks4.protocol
105 * Set protocol4a=true for "SOCKS 4A (Simple Extension to SOCKS 4 Protocol)"
106 * Nonsupport "Identification Protocol (RFC1413)"
108 CURLcode Curl_SOCKS4(const char *proxy_name,
109 const char *hostname,
112 struct connectdata *conn)
114 const bool protocol4a =
115 (conn->socks_proxy.proxytype == CURLPROXY_SOCKS4A) ? TRUE : FALSE;
116 #define SOCKS4REQLEN 262
117 unsigned char socksreq[SOCKS4REQLEN]; /* room for SOCKS4 request incl. user
121 curl_socket_t sock = conn->sock[sockindex];
122 struct Curl_easy *data = conn->data;
124 if(Curl_timeleft(data, NULL, TRUE) < 0) {
125 /* time-out, bail out, go home */
126 failf(data, "Connection time-out");
127 return CURLE_OPERATION_TIMEDOUT;
130 if(conn->bits.httpproxy)
131 infof(conn->data, "SOCKS4%s: connecting to HTTP proxy %s port %d\n",
132 protocol4a ? "a" : "", hostname, remote_port);
134 (void)curlx_nonblock(sock, FALSE);
136 infof(data, "SOCKS4 communication to %s:%d\n", hostname, remote_port);
139 * Compose socks4 request
143 * +----+----+----+----+----+----+----+----+----+----+....+----+
144 * | VN | CD | DSTPORT | DSTIP | USERID |NULL|
145 * +----+----+----+----+----+----+----+----+----+----+....+----+
146 * # of bytes: 1 1 2 4 variable 1
149 socksreq[0] = 4; /* version (SOCKS4) */
150 socksreq[1] = 1; /* connect */
151 socksreq[2] = (unsigned char)((remote_port >> 8) & 0xff); /* PORT MSB */
152 socksreq[3] = (unsigned char)(remote_port & 0xff); /* PORT LSB */
154 /* DNS resolve only for SOCKS4, not SOCKS4a */
156 struct Curl_dns_entry *dns;
157 Curl_addrinfo *hp=NULL;
160 rc = Curl_resolv(conn, hostname, remote_port, &dns);
162 if(rc == CURLRESOLV_ERROR)
163 return CURLE_COULDNT_RESOLVE_PROXY;
165 if(rc == CURLRESOLV_PENDING)
166 /* ignores the return code, but 'dns' remains NULL on failure */
167 (void)Curl_resolver_wait_resolv(conn, &dns);
170 * We cannot use 'hostent' as a struct that Curl_resolv() returns. It
171 * returns a Curl_addrinfo pointer that may not always look the same.
177 Curl_printable_address(hp, buf, sizeof(buf));
179 if(hp->ai_family == AF_INET) {
180 struct sockaddr_in *saddr_in;
182 saddr_in = (struct sockaddr_in *)(void *)hp->ai_addr;
183 socksreq[4] = ((unsigned char *)&saddr_in->sin_addr.s_addr)[0];
184 socksreq[5] = ((unsigned char *)&saddr_in->sin_addr.s_addr)[1];
185 socksreq[6] = ((unsigned char *)&saddr_in->sin_addr.s_addr)[2];
186 socksreq[7] = ((unsigned char *)&saddr_in->sin_addr.s_addr)[3];
188 infof(data, "SOCKS4 connect to IPv4 %s (locally resolved)\n", buf);
191 hp = NULL; /* fail! */
193 failf(data, "SOCKS4 connection to %s not supported\n", buf);
196 Curl_resolv_unlock(data, dns); /* not used anymore from now on */
199 failf(data, "Failed to resolve \"%s\" for SOCKS4 connect.",
201 return CURLE_COULDNT_RESOLVE_HOST;
206 * This is currently not supporting "Identification Protocol (RFC1413)".
208 socksreq[8] = 0; /* ensure empty userid is NUL-terminated */
210 size_t plen = strlen(proxy_name);
211 if(plen >= sizeof(socksreq) - 8) {
212 failf(data, "Too long SOCKS proxy name, can't use!\n");
213 return CURLE_COULDNT_CONNECT;
215 /* copy the proxy name WITH trailing zero */
216 memcpy(socksreq + 8, proxy_name, plen+1);
225 ssize_t hostnamelen = 0;
227 (int)strlen((char *)socksreq + 8); /* size including NUL */
229 /* If SOCKS4a, set special invalid IP address 0.0.0.x */
235 /* If still enough room in buffer, also append hostname */
236 hostnamelen = (ssize_t)strlen(hostname) + 1; /* length including NUL */
237 if(packetsize + hostnamelen <= SOCKS4REQLEN)
238 strcpy((char *)socksreq + packetsize, hostname);
240 hostnamelen = 0; /* Flag: hostname did not fit in buffer */
244 code = Curl_write_plain(conn, sock, (char *)socksreq,
245 packetsize + hostnamelen,
247 if(code || (written != packetsize + hostnamelen)) {
248 failf(data, "Failed to send SOCKS4 connect request.");
249 return CURLE_COULDNT_CONNECT;
251 if(protocol4a && hostnamelen == 0) {
252 /* SOCKS4a with very long hostname - send that name separately */
253 hostnamelen = (ssize_t)strlen(hostname) + 1;
254 code = Curl_write_plain(conn, sock, (char *)hostname, hostnamelen,
256 if(code || (written != hostnamelen)) {
257 failf(data, "Failed to send SOCKS4 connect request.");
258 return CURLE_COULDNT_CONNECT;
262 packetsize = 8; /* receive data size */
264 /* Receive response */
265 result = Curl_blockread_all(conn, sock, (char *)socksreq, packetsize,
267 if(result || (actualread != packetsize)) {
268 failf(data, "Failed to receive SOCKS4 connect request ack.");
269 return CURLE_COULDNT_CONNECT;
275 * +----+----+----+----+----+----+----+----+
276 * | VN | CD | DSTPORT | DSTIP |
277 * +----+----+----+----+----+----+----+----+
278 * # of bytes: 1 1 2 4
280 * VN is the version of the reply code and should be 0. CD is the result
281 * code with one of the following values:
283 * 90: request granted
284 * 91: request rejected or failed
285 * 92: request rejected because SOCKS server cannot connect to
286 * identd on the client
287 * 93: request rejected because the client program and identd
288 * report different user-ids
291 /* wrong version ? */
292 if(socksreq[0] != 0) {
294 "SOCKS4 reply has wrong version, version should be 4.");
295 return CURLE_COULDNT_CONNECT;
299 switch(socksreq[1]) {
301 infof(data, "SOCKS4%s request granted.\n", protocol4a?"a":"");
305 "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
306 ", request rejected or failed.",
307 (unsigned char)socksreq[4], (unsigned char)socksreq[5],
308 (unsigned char)socksreq[6], (unsigned char)socksreq[7],
309 (((unsigned char)socksreq[8] << 8) | (unsigned char)socksreq[9]),
310 (unsigned char)socksreq[1]);
311 return CURLE_COULDNT_CONNECT;
314 "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
315 ", request rejected because SOCKS server cannot connect to "
316 "identd on the client.",
317 (unsigned char)socksreq[4], (unsigned char)socksreq[5],
318 (unsigned char)socksreq[6], (unsigned char)socksreq[7],
319 (((unsigned char)socksreq[8] << 8) | (unsigned char)socksreq[9]),
320 (unsigned char)socksreq[1]);
321 return CURLE_COULDNT_CONNECT;
324 "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
325 ", request rejected because the client program and identd "
326 "report different user-ids.",
327 (unsigned char)socksreq[4], (unsigned char)socksreq[5],
328 (unsigned char)socksreq[6], (unsigned char)socksreq[7],
329 (((unsigned char)socksreq[8] << 8) | (unsigned char)socksreq[9]),
330 (unsigned char)socksreq[1]);
331 return CURLE_COULDNT_CONNECT;
334 "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
336 (unsigned char)socksreq[4], (unsigned char)socksreq[5],
337 (unsigned char)socksreq[6], (unsigned char)socksreq[7],
338 (((unsigned char)socksreq[8] << 8) | (unsigned char)socksreq[9]),
339 (unsigned char)socksreq[1]);
340 return CURLE_COULDNT_CONNECT;
344 (void)curlx_nonblock(sock, TRUE);
346 return CURLE_OK; /* Proxy was successful! */
350 * This function logs in to a SOCKS5 proxy and sends the specifics to the final
351 * destination server.
353 CURLcode Curl_SOCKS5(const char *proxy_name,
354 const char *proxy_password,
355 const char *hostname,
358 struct connectdata *conn)
361 According to the RFC1928, section "6. Replies". This is what a SOCK5
364 +----+-----+-------+------+----------+----------+
365 |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |
366 +----+-----+-------+------+----------+----------+
367 | 1 | 1 | X'00' | 1 | Variable | 2 |
368 +----+-----+-------+------+----------+----------+
372 o VER protocol version: X'05'
377 unsigned char socksreq[600]; /* room for large user/pw (255 max each) */
382 curl_socket_t sock = conn->sock[sockindex];
383 struct Curl_easy *data = conn->data;
385 bool socks5_resolve_local =
386 (conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE;
387 const size_t hostname_len = strlen(hostname);
390 if(conn->bits.httpproxy)
391 infof(conn->data, "SOCKS5: connecting to HTTP proxy %s port %d\n",
392 hostname, remote_port);
394 /* RFC1928 chapter 5 specifies max 255 chars for domain name in packet */
395 if(!socks5_resolve_local && hostname_len > 255) {
396 infof(conn->data, "SOCKS5: server resolving disabled for hostnames of "
397 "length > 255 [actual len=%zu]\n", hostname_len);
398 socks5_resolve_local = TRUE;
402 timeout = Curl_timeleft(data, NULL, TRUE);
405 /* time-out, bail out, go home */
406 failf(data, "Connection time-out");
407 return CURLE_OPERATION_TIMEDOUT;
410 (void)curlx_nonblock(sock, TRUE);
412 /* wait until socket gets connected */
413 result = SOCKET_WRITABLE(sock, timeout);
416 failf(conn->data, "SOCKS5: no connection here");
417 return CURLE_COULDNT_CONNECT;
419 else if(0 == result) {
420 failf(conn->data, "SOCKS5: connection timeout");
421 return CURLE_OPERATION_TIMEDOUT;
424 if(result & CURL_CSELECT_ERR) {
425 failf(conn->data, "SOCKS5: error occurred during connection");
426 return CURLE_COULDNT_CONNECT;
429 socksreq[0] = 5; /* version */
430 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
431 socksreq[1] = (char)(proxy_name ? 3 : 2); /* number of methods (below) */
432 socksreq[2] = 0; /* no authentication */
433 socksreq[3] = 1; /* GSS-API */
434 socksreq[4] = 2; /* username/password */
436 socksreq[1] = (char)(proxy_name ? 2 : 1); /* number of methods (below) */
437 socksreq[2] = 0; /* no authentication */
438 socksreq[3] = 2; /* username/password */
441 (void)curlx_nonblock(sock, FALSE);
443 infof(data, "SOCKS5 communication to %s:%d\n", hostname, remote_port);
445 code = Curl_write_plain(conn, sock, (char *)socksreq, (2 + (int)socksreq[1]),
447 if(code || (written != (2 + (int)socksreq[1]))) {
448 failf(data, "Unable to send initial SOCKS5 request.");
449 return CURLE_COULDNT_CONNECT;
452 (void)curlx_nonblock(sock, TRUE);
454 result = SOCKET_READABLE(sock, timeout);
457 failf(conn->data, "SOCKS5 nothing to read");
458 return CURLE_COULDNT_CONNECT;
460 else if(0 == result) {
461 failf(conn->data, "SOCKS5 read timeout");
462 return CURLE_OPERATION_TIMEDOUT;
465 if(result & CURL_CSELECT_ERR) {
466 failf(conn->data, "SOCKS5 read error occurred");
467 return CURLE_RECV_ERROR;
470 (void)curlx_nonblock(sock, FALSE);
472 result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
473 if(result || (actualread != 2)) {
474 failf(data, "Unable to receive initial SOCKS5 response.");
475 return CURLE_COULDNT_CONNECT;
478 if(socksreq[0] != 5) {
479 failf(data, "Received invalid version in initial SOCKS5 response.");
480 return CURLE_COULDNT_CONNECT;
482 if(socksreq[1] == 0) {
483 /* Nothing to do, no authentication needed */
486 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
487 else if(socksreq[1] == 1) {
488 code = Curl_SOCKS5_gssapi_negotiate(sockindex, conn);
490 failf(data, "Unable to negotiate SOCKS5 GSS-API context.");
491 return CURLE_COULDNT_CONNECT;
495 else if(socksreq[1] == 2) {
496 /* Needs user name and password */
497 size_t proxy_name_len, proxy_password_len;
498 if(proxy_name && proxy_password) {
499 proxy_name_len = strlen(proxy_name);
500 proxy_password_len = strlen(proxy_password);
504 proxy_password_len = 0;
507 /* username/password request looks like
508 * +----+------+----------+------+----------+
509 * |VER | ULEN | UNAME | PLEN | PASSWD |
510 * +----+------+----------+------+----------+
511 * | 1 | 1 | 1 to 255 | 1 | 1 to 255 |
512 * +----+------+----------+------+----------+
515 socksreq[len++] = 1; /* username/pw subnegotiation version */
516 socksreq[len++] = (unsigned char) proxy_name_len;
517 if(proxy_name && proxy_name_len)
518 memcpy(socksreq + len, proxy_name, proxy_name_len);
519 len += proxy_name_len;
520 socksreq[len++] = (unsigned char) proxy_password_len;
521 if(proxy_password && proxy_password_len)
522 memcpy(socksreq + len, proxy_password, proxy_password_len);
523 len += proxy_password_len;
525 code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written);
526 if(code || (len != written)) {
527 failf(data, "Failed to send SOCKS5 sub-negotiation request.");
528 return CURLE_COULDNT_CONNECT;
531 result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
532 if(result || (actualread != 2)) {
533 failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
534 return CURLE_COULDNT_CONNECT;
537 /* ignore the first (VER) byte */
538 if(socksreq[1] != 0) { /* status */
539 failf(data, "User was rejected by the SOCKS5 server (%d %d).",
540 socksreq[0], socksreq[1]);
541 return CURLE_COULDNT_CONNECT;
544 /* Everything is good so far, user was authenticated! */
548 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
549 if(socksreq[1] == 255) {
551 if(socksreq[1] == 1) {
553 "SOCKS5 GSSAPI per-message authentication is not supported.");
554 return CURLE_COULDNT_CONNECT;
556 else if(socksreq[1] == 255) {
558 if(!proxy_name || !*proxy_name) {
560 "No authentication method was acceptable. (It is quite likely"
561 " that the SOCKS5 server wanted a username/password, since none"
562 " was supplied to the server on this connection.)");
565 failf(data, "No authentication method was acceptable.");
567 return CURLE_COULDNT_CONNECT;
571 "Undocumented SOCKS5 mode attempted to be used by server.");
572 return CURLE_COULDNT_CONNECT;
576 /* Authentication is complete, now specify destination to the proxy */
578 socksreq[len++] = 5; /* version (SOCKS5) */
579 socksreq[len++] = 1; /* connect */
580 socksreq[len++] = 0; /* must be zero */
582 if(!socks5_resolve_local) {
583 socksreq[len++] = 3; /* ATYP: domain name = 3 */
584 socksreq[len++] = (char) hostname_len; /* address length */
585 memcpy(&socksreq[len], hostname, hostname_len); /* address str w/o NULL */
589 struct Curl_dns_entry *dns;
590 Curl_addrinfo *hp = NULL;
591 int rc = Curl_resolv(conn, hostname, remote_port, &dns);
593 if(rc == CURLRESOLV_ERROR)
594 return CURLE_COULDNT_RESOLVE_HOST;
596 if(rc == CURLRESOLV_PENDING) {
597 /* this requires that we're in "wait for resolve" state */
598 code = Curl_resolver_wait_resolv(conn, &dns);
604 * We cannot use 'hostent' as a struct that Curl_resolv() returns. It
605 * returns a Curl_addrinfo pointer that may not always look the same.
612 Curl_printable_address(hp, buf, sizeof(buf));
614 if(hp->ai_family == AF_INET) {
615 struct sockaddr_in *saddr_in;
616 socksreq[len++] = 1; /* ATYP: IPv4 = 1 */
618 saddr_in = (struct sockaddr_in *)(void *)hp->ai_addr;
619 for(i = 0; i < 4; i++) {
620 socksreq[len++] = ((unsigned char *)&saddr_in->sin_addr.s_addr)[i];
623 infof(data, "SOCKS5 connect to IPv4 %s (locally resolved)\n", buf);
626 else if(hp->ai_family == AF_INET6) {
627 struct sockaddr_in6 *saddr_in6;
628 socksreq[len++] = 4; /* ATYP: IPv6 = 4 */
630 saddr_in6 = (struct sockaddr_in6 *)(void *)hp->ai_addr;
631 for(i = 0; i < 16; i++) {
633 ((unsigned char *)&saddr_in6->sin6_addr.s6_addr)[i];
636 infof(data, "SOCKS5 connect to IPv6 %s (locally resolved)\n", buf);
640 hp = NULL; /* fail! */
642 failf(data, "SOCKS5 connection to %s not supported\n", buf);
645 Curl_resolv_unlock(data, dns); /* not used anymore from now on */
648 failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.",
650 return CURLE_COULDNT_RESOLVE_HOST;
654 socksreq[len++] = (unsigned char)((remote_port >> 8) & 0xff); /* PORT MSB */
655 socksreq[len++] = (unsigned char)(remote_port & 0xff); /* PORT LSB */
657 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
658 if(conn->socks5_gssapi_enctype) {
659 failf(data, "SOCKS5 GSS-API protection not yet implemented.");
663 code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written);
665 if(code || (len != written)) {
666 failf(data, "Failed to send SOCKS5 connect request.");
667 return CURLE_COULDNT_CONNECT;
670 len = 10; /* minimum packet size is 10 */
672 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
673 if(conn->socks5_gssapi_enctype) {
674 failf(data, "SOCKS5 GSS-API protection not yet implemented.");
678 result = Curl_blockread_all(conn, sock, (char *)socksreq,
681 if(result || (len != actualread)) {
682 failf(data, "Failed to receive SOCKS5 connect request ack.");
683 return CURLE_COULDNT_CONNECT;
686 if(socksreq[0] != 5) { /* version */
688 "SOCKS5 reply has wrong version, version should be 5.");
689 return CURLE_COULDNT_CONNECT;
692 /* Fix: in general, returned BND.ADDR is variable length parameter by RFC
693 1928, so the reply packet should be read until the end to avoid errors at
694 subsequent protocol level.
696 +----+-----+-------+------+----------+----------+
697 |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |
698 +----+-----+-------+------+----------+----------+
699 | 1 | 1 | X'00' | 1 | Variable | 2 |
700 +----+-----+-------+------+----------+----------+
703 o IP v4 address: X'01', BND.ADDR = 4 byte
704 o domain name: X'03', BND.ADDR = [ 1 byte length, string ]
705 o IP v6 address: X'04', BND.ADDR = 16 byte
708 /* Calculate real packet size */
709 if(socksreq[3] == 3) {
711 int addrlen = (int) socksreq[4];
712 len = 5 + addrlen + 2;
714 else if(socksreq[3] == 4) {
719 /* At this point we already read first 10 bytes */
720 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
721 if(!conn->socks5_gssapi_enctype) {
722 /* decrypt_gssapi_blockread already read the whole packet */
725 result = Curl_blockread_all(conn, sock, (char *)&socksreq[10],
726 len - 10, &actualread);
727 if(result || ((len - 10) != actualread)) {
728 failf(data, "Failed to receive SOCKS5 connect request ack.");
729 return CURLE_COULDNT_CONNECT;
732 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
736 if(socksreq[1] != 0) { /* Anything besides 0 is an error */
737 if(socksreq[3] == 1) {
739 "Can't complete SOCKS5 connection to %d.%d.%d.%d:%d. (%d)",
740 (unsigned char)socksreq[4], (unsigned char)socksreq[5],
741 (unsigned char)socksreq[6], (unsigned char)socksreq[7],
742 (((unsigned char)socksreq[8] << 8) |
743 (unsigned char)socksreq[9]),
744 (unsigned char)socksreq[1]);
746 else if(socksreq[3] == 3) {
747 unsigned char port_upper = (unsigned char)socksreq[len - 2];
748 socksreq[len - 2] = 0;
750 "Can't complete SOCKS5 connection to %s:%d. (%d)",
751 (char *)&socksreq[5],
753 (unsigned char)socksreq[len - 1]),
754 (unsigned char)socksreq[1]);
755 socksreq[len - 2] = port_upper;
757 else if(socksreq[3] == 4) {
759 "Can't complete SOCKS5 connection to %02x%02x:%02x%02x:"
760 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%d. (%d)",
761 (unsigned char)socksreq[4], (unsigned char)socksreq[5],
762 (unsigned char)socksreq[6], (unsigned char)socksreq[7],
763 (unsigned char)socksreq[8], (unsigned char)socksreq[9],
764 (unsigned char)socksreq[10], (unsigned char)socksreq[11],
765 (unsigned char)socksreq[12], (unsigned char)socksreq[13],
766 (unsigned char)socksreq[14], (unsigned char)socksreq[15],
767 (unsigned char)socksreq[16], (unsigned char)socksreq[17],
768 (unsigned char)socksreq[18], (unsigned char)socksreq[19],
769 (((unsigned char)socksreq[20] << 8) |
770 (unsigned char)socksreq[21]),
771 (unsigned char)socksreq[1]);
773 return CURLE_COULDNT_CONNECT;
776 infof(data, "SOCKS5 request granted.\n");
779 (void)curlx_nonblock(sock, TRUE);
780 return CURLE_OK; /* Proxy was successful! */
783 #endif /* CURL_DISABLE_PROXY */