diff options
Diffstat (limited to 'libs/libcurl/src/socks.c')
-rw-r--r-- | libs/libcurl/src/socks.c | 67 |
1 files changed, 21 insertions, 46 deletions
diff --git a/libs/libcurl/src/socks.c b/libs/libcurl/src/socks.c index c586b158b6..794f4296ff 100644 --- a/libs/libcurl/src/socks.c +++ b/libs/libcurl/src/socks.c @@ -38,10 +38,10 @@ #include "select.h"
#include "cfilters.h"
#include "connect.h"
-#include "timeval.h"
+#include "curlx/timeval.h"
#include "socks.h"
#include "multiif.h" /* for getsock macros */
-#include "inet_pton.h"
+#include "curlx/inet_pton.h"
#include "url.h"
/* The last 3 #include files should be in this order */
@@ -321,16 +321,16 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf, /* DNS resolve only for SOCKS4, not SOCKS4a */
if(!protocol4a) {
- enum resolve_t rc =
- Curl_resolv(data, sx->hostname, sx->remote_port, TRUE, &dns);
+ result = Curl_resolv(data, sx->hostname, sx->remote_port,
+ cf->conn->ip_version, TRUE, &dns);
- if(rc == CURLRESOLV_ERROR)
- return CURLPX_RESOLVE_HOST;
- else if(rc == CURLRESOLV_PENDING) {
+ if(result == CURLE_AGAIN) {
sxstate(sx, data, CONNECT_RESOLVING);
infof(data, "SOCKS4 non-blocking resolve of %s", sx->hostname);
return CURLPX_OK;
}
+ else if(result)
+ return CURLPX_RESOLVE_HOST;
sxstate(sx, data, CONNECT_RESOLVED);
goto CONNECT_RESOLVED;
}
@@ -341,23 +341,11 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf, case CONNECT_RESOLVING:
/* check if we have the name resolved by now */
- dns = Curl_fetch_addr(data, sx->hostname, conn->primary.remote_port);
-
- if(dns) {
-#ifdef USE_CURL_ASYNC
- data->state.async.dns = dns;
- data->state.async.done = TRUE;
-#endif
- infof(data, "Hostname '%s' was found", sx->hostname);
- sxstate(sx, data, CONNECT_RESOLVED);
- }
- else {
- result = Curl_resolv_check(data, &dns);
- if(!dns) {
- if(result)
- return CURLPX_RESOLVE_HOST;
- return CURLPX_OK;
- }
+ result = Curl_resolv_check(data, &dns);
+ if(!dns) {
+ if(result)
+ return CURLPX_RESOLVE_HOST;
+ return CURLPX_OK;
}
FALLTHROUGH();
case CONNECT_RESOLVED:
@@ -794,16 +782,15 @@ CONNECT_AUTH_INIT: case CONNECT_REQ_INIT:
CONNECT_REQ_INIT:
if(socks5_resolve_local) {
- enum resolve_t rc = Curl_resolv(data, sx->hostname, sx->remote_port,
- TRUE, &dns);
+ result = Curl_resolv(data, sx->hostname, sx->remote_port,
+ cf->conn->ip_version, TRUE, &dns);
- if(rc == CURLRESOLV_ERROR)
- return CURLPX_RESOLVE_HOST;
-
- if(rc == CURLRESOLV_PENDING) {
+ if(result == CURLE_AGAIN) {
sxstate(sx, data, CONNECT_RESOLVING);
return CURLPX_OK;
}
+ else if(result)
+ return CURLPX_RESOLVE_HOST;
sxstate(sx, data, CONNECT_RESOLVED);
goto CONNECT_RESOLVED;
}
@@ -811,23 +798,11 @@ CONNECT_REQ_INIT: case CONNECT_RESOLVING:
/* check if we have the name resolved by now */
- dns = Curl_fetch_addr(data, sx->hostname, sx->remote_port);
-
- if(dns) {
-#ifdef USE_CURL_ASYNC
- data->state.async.dns = dns;
- data->state.async.done = TRUE;
-#endif
- infof(data, "SOCKS5: hostname '%s' found", sx->hostname);
- }
-
+ result = Curl_resolv_check(data, &dns);
if(!dns) {
- result = Curl_resolv_check(data, &dns);
- if(!dns) {
- if(result)
- return CURLPX_RESOLVE_HOST;
- return CURLPX_OK;
- }
+ if(result)
+ return CURLPX_RESOLVE_HOST;
+ return CURLPX_OK;
}
FALLTHROUGH();
case CONNECT_RESOLVED:
|