socks: use dns filter for resolving#21297
Closed
icing wants to merge 2 commits into
Closed
Conversation
bagder
approved these changes
Apr 13, 2026
There was a problem hiding this comment.
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
addrinfoviaCurl_cf_dns_get_ai(). - Extend
Curl_cf_dns_insert_after()with acomplete_resolveflag 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.
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)
…lete_resolve` flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)