Repository navigation
Make getaddrinfo() address family configurable at build time - #644
Yildirim-Tolga wants to merge 1 commit into
Conversation
Tinyproxy currently uses AF_UNSPEC when resolving upstream destinations through getaddrinfo(). Some deployments require deterministic IPv4-only or IPv6-only operation due to network policy, protocol availability, troubleshooting, or embedded system constraints. This change introduces an optional configure-time setting that allows AF_INET or AF_INET6 to be selected while preserving the existing AF_UNSPEC behavior as the default.
|
i actually have this very line patched in my own checkout to prefer IPv4 always. but this should be a runtime option, not compile-time. |
Thanks for the feedback. Just to make sure I understand correctly: would you prefer this to be implemented as a tinyproxy.conf option rather than a configure-time option? I'd be happy to rework the patch in that direction if that would be more useful. |
right, we just have to bikeshed about how to call it, and whether/how we allow a fallback to the other AF if the selected one has no results. |
AddressFamily sounds straightforward to me: I'd suggest keeping ipv4 and ipv6 strict, without fallback. unspec already provides the existing system-selected behavior and would remain the default, so existing configurations would behave exactly as they do today. If an address family is explicitly configured, I think Tinyproxy should respect that choice rather than silently falling back to the other family. |
|
AddressFamily isn't specific enough, it could mean anything. let's call it "ConnectAddressFamily", with allowed values of "ipv4", "ipv6", "unspec" (default). like ConnectPort, it can be used more than once (which would establish a prefered order), or just once in which case it disallows non-matching address families. would use AF_UNSPEC for the getaddrinfo call, and then iterate twice (if needed, i.e. no AF_INET entries exist) over the returned list. more than two values make no sense, so the conf parser would warn if it's used more often. we can use an sounds good? |
Make getaddrinfo() address family configurable at build time
Summary
Tinyproxy currently uses
AF_UNSPECwhen callinggetaddrinfo()for upstream destination resolution.This change adds an optional build-time configuration allowing users to explicitly select:
AF_UNSPEC(default)AF_INETAF_INET6The default behavior remains unchanged.
Motivation
While using
AF_UNSPECis generally appropriate, some deployments require deterministic address-family selection.Examples include:
Currently these deployments cannot enforce a specific address family without modifying the source code.
Implementation
A new configure-time option has been added to allow selecting the address family used by
getaddrinfo().Examples:
If the option is not specified, Tinyproxy continues to use:
AF_UNSPECensuring full backward compatibility.
Backward Compatibility
Testing
Tested with:
and verified successful upstream hostname resolution in each mode.
Rationale
This feature is entirely optional and does not modify the default Tinyproxy behavior. It only provides additional deployment flexibility for environments requiring IPv4-only or IPv6-only operation.