Skip to content

socks: use dns filter for resolving#21297

Closed
icing wants to merge 2 commits into
curl:masterfrom
icing:socks-dns-filter
Closed

socks: use dns filter for resolving#21297
icing wants to merge 2 commits into
curl:masterfrom
icing:socks-dns-filter

Conversation

@icing
Copy link
Copy Markdown
Contributor

@icing icing commented Apr 13, 2026

Use a dns connection filter to resolve hostnames where their addresses are locally resolved and forwarded to the SOCKS proxy.

This makes all improvements, like in #21295 for example, also apply to socks connections. Curl_resolv() is now only called from a DNS filter.

(ftp still calls Curl_resolv_blocking() in two places, one of which
may be replaceable with a DNS filter as well to remove the block, tbd)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR routes SOCKS4/SOCKS5 “local resolve then forward IP to proxy” through the cf-dns connection filter, so SOCKS connections benefit from recent resolver improvements (e.g., #21295) and centralize calls to Curl_resolv() inside the DNS filter.

Changes:

  • Update SOCKS4/SOCKS5 local resolving to insert and drive a DNS connection filter, then fetch resolved addrinfo via Curl_cf_dns_get_ai().
  • Extend Curl_cf_dns_insert_after() with a complete_resolve flag and thread it through cf-dns context/creation.
  • Adjust cf-dns connect logic to support the new “resolve completion” behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/socks.c Switch SOCKS4/SOCKS5 local hostname resolution to use a DNS filter and Curl_cf_dns_get_ai() instead of direct Curl_resolv() usage.
lib/cf-dns.h Extend Curl_cf_dns_insert_after() API with a complete_resolve parameter.
lib/cf-dns.c Track complete_resolve in the DNS filter context and alter connect behavior accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/socks.c Outdated
Comment thread lib/socks.c
Comment thread lib/cf-dns.c Outdated
icing added 2 commits April 14, 2026 09:47
Use a dns connection filter to resolve hostnames where their addresses
are locally resolved and forwarded to the SOCKS proxy.

This makes all improvements, like in curl#21295 for example, also apply
to socks connections. Curl_resolv() is now only called from a DNS
filter.

(ftp still calls Curl_resolv_blocking() in two places, one of which
 may be replaceable with a DNS filter as well to remove the block, tbd)
@icing icing force-pushed the socks-dns-filter branch from ddf2801 to c9f9b8d Compare April 14, 2026 07:56
@bagder bagder closed this in bcd94e2 Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants