[Git][NTPsec/ntpsec][master] Reimplement -4 and -6 in ntpq.
Eric S. Raymond
gitlab at mg.gitlab.com
Tue Nov 8 13:26:11 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
5307ddae by Eric S. Raymond at 2016-11-08T08:25:42-05:00
Reimplement -4 and -6 in ntpq.
- - - - -
2 changed files:
- ntpq/ntpq
- pylib/util.py
Changes:
=====================================
ntpq/ntpq
=====================================
--- a/ntpq/ntpq
+++ b/ntpq/ntpq
@@ -515,7 +515,7 @@ usage: timeout [ msec ]
value = queried[name]
if fmt in (NTP_ADD, NTP_ADP):
if self.showhostnames:
- value = canonicalize_dns(value)
+ value = canonicalize_dns(value, family=self.ai_family)
self.say("%s %s\n" % (legend, value))
elif fmt == NTP_STR:
if value:
=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -29,7 +29,7 @@ def portsplit(hostname):
hostname = hostname[1:-1] # Strip brackets
return (hostname, portsuffix)
-def canonicalize_dns(hostname):
+def canonicalize_dns(hostname, family=socket.AF_UNSPEC):
"Canonicalize a hostname or numeric IP address."
# Catch garbaged hostnames in corrupted Mode 6 responses
m = re.match("([:.[\]]|\w)*", hostname)
@@ -37,7 +37,7 @@ def canonicalize_dns(hostname):
raise TypeError
(hostname, portsuffix) = portsplit(hostname)
try:
- ai = socket.getaddrinfo(hostname, None, 0, 0, 0, socket.AI_CANONNAME)
+ ai = socket.getaddrinfo(hostname, None, family, 0, 0, socket.AI_CANONNAME)
except socket.gaierror as (s, _e):
print('getaddrinfo failed: %s' % s, file=sys.stderr)
raise SystemExit(1)
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/5307ddaea6f8d791943dceef7ceceae3e897000c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161108/fade6d4b/attachment.html>
More information about the vc
mailing list