Message ID | 20250325195750.7899-1-gert@greenie.muc.de |
---|---|
State | Accepted |
Headers | show |
Series | [Openvpn-devel,v4] Mention address if not unspecific on DNS failure | expand |
Stared at it, and tested, and it's indeed quite useful (v3 had a stray "%s" which is fixed in v4). Without the patch, trying with "--local <v6 address>" + "--remote <v4only>" RESOLVE: Cannot resolve host address: v4only.v6.de:51194 (No address associated with hostname) with the patch: RESOLVE: Cannot resolve host address: v4only.v6.de:51194[AF_INET6] (No address associated with hostname) so when trying to diagnose user reports, this immediately points to "mmmh, something is forcing v6 here, why?". With no --local and no --proto udp4, nothing is forced, and thus: RESOLVE: Cannot resolve host address: nix.v6.de:51194 (Name or service not known) Your patch has been applied to the master branch. commit d16781531898b4c5a76cfe6cba02fccce9afb8ad Author: Arne Schwabe Date: Tue Mar 25 20:57:43 2025 +0100 Mention address if not unspecific on DNS failure Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20250325195750.7899-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31237.html Signed-off-by: Gert Doering <gert@greenie.muc.de> -- kind regards, Gert Doering
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 6b32e30..09de1b0 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -445,6 +445,22 @@ throw_signal_soft(SIGHUP, "Preresolving failed"); } +/** + * Small helper function for openvpn_getaddrinfo to print the address + * family when resolving fails + */ +static const char * +getaddrinfo_addr_family_name(int af) +{ + switch (af) + { + case AF_INET: return "[AF_INET]"; + + case AF_INET6: return "[AF_INET6]"; + } + return ""; +} + /* * Translate IPv4/IPv6 addr or hostname into struct addrinfo * If resolve error, try again for resolve_retry_seconds seconds. @@ -545,11 +561,11 @@ print_hostname = "undefined"; } - fmt = "RESOLVE: Cannot resolve host address: %s:%s (%s)"; + fmt = "RESOLVE: Cannot resolve host address: %s:%s%s (%s)"; if ((flags & GETADDR_MENTION_RESOLVE_RETRY) && !resolve_retry_seconds) { - fmt = "RESOLVE: Cannot resolve host address: %s:%s (%s) " + fmt = "RESOLVE: Cannot resolve host address: %s:%s%s (%s)" "(I would have retried this name query if you had " "specified the --resolv-retry option.)"; } @@ -639,6 +655,7 @@ fmt, print_hostname, print_servname, + getaddrinfo_addr_family_name(ai_family), gai_strerror(status)); if (--resolve_retries <= 0)