cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re[2]: dns via socks5 failed?

From: Maxim Perenesenko <_under_at_mail.ru>
Date: Tue, 18 Dec 2007 14:38:17 +0200

Hello Daniel,

Monday, December 17, 2007, 1:37:35 PM, you wrote:

> On Mon, 17 Dec 2007, jinglexy_mail-stock_at_yahoo.com.cn wrote:

>> here is my simple demo, the http proxy works well,
>> but socks5 can't.

> [...]

>> it's seem to get hostname via local dns?

> Yes, you're using SOCKS5, how is that supposed to use the DNS if not locally?

>> do libcurl support dns via proxy?

> How would that work?

SOCKS5 supports resolving DNS names. SOCKS5 connection packet from client
(f.e. libcurl) could include IP or string name for SOCKS5 server to resolve
and connect to. However, as I see from sources 7.17.1 libcurl does not
support this. Name resolution is performed in libcurl itself, before
sending SOCKS5 connect ask.

ref: lib/socks.c lines #525 #530

By the way, it is not so hard to add this functionality into libcurl.

+ one bool option, like CURLOPT_SOCKS5_USE_REMOTE_DNS or smth like this.

and send SOCKS5 request like the following if this option is set:

lib/socks.c:525
-- socksreq[3] = 1; /* IPv4 = 1 */
++ socksreq[3] = 3; /* DNS name = 3 */
++ socksreq[4] = strlen(hostname);
++ Curl_write(...,(char*) socksreq, 5,...); // SOCKS5 packet header
++ Curl_write(...,(char*) hostname, strlen(hostname),...); // hostname to connect to (check len <= 255, SOCKS5 limit)
++ Curl_write(...,(char*) &socksreq[8], 2,...); // IP PORT to connect to

-- 
Best regards,
 Maxim
Received on 2007-12-18