Skip to content
Snippets Groups Projects
Commit ef5b7f1a authored by Torbjörn Lönnemark's avatar Torbjörn Lönnemark
Browse files

resolve_ipnets(): Canonicalize resolved addresses

The version of JRuby included with puppetserver (as of 7.9.5) does not
canonicalize IPv6 addresses returned by Socket.getaddrinfo, and thus
returns them without compressing runs of zeros. For example, running
resolve_ipnets under puppetserver would return 2001:0db8:0:0:0:0:0:1
if running server-less returned 2001:0db8::1.

Work around the issue by converting resolved addresses to IPAddr
objects, then back to strings.
parent 3481ef83
No related branches found
No related tags found
1 merge request!2resolve_ipnets(): Canonicalize resolved addresses
......@@ -103,7 +103,11 @@ module Puppet::Parser::Functions
ips[info[4]] = []
found_families << info[4]
end
ips.fetch(info[4]) << info[3]
# Canonicalize address using IPAddr so the same representation
# is returned regardless of interpreter.
# JRuby's Socket.getaddrinfo returns IPv6 addresses without
# compressed zeros, while CRuby's does compress zeros.
ips.fetch(info[4]) << IPAddr.new(info[3]).to_s
end
end
ipaddrs = [ ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment