summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_peer_discovery_dns.erl21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/rabbit_peer_discovery_dns.erl b/src/rabbit_peer_discovery_dns.erl
index 5bc85d340d..f048a40c89 100644
--- a/src/rabbit_peer_discovery_dns.erl
+++ b/src/rabbit_peer_discovery_dns.erl
@@ -75,14 +75,25 @@ discover_nodes(SeedHostname, LongNamesUsed) ->
H <- discover_hostnames(SeedHostname, LongNamesUsed)].
discover_hostnames(SeedHostname, LongNamesUsed) ->
- %% TODO: IPv6 support
- IPs = inet_res:lookup(SeedHostname, in, a),
- rabbit_log:info("Addresses discovered via A records of ~s: ~s",
- [SeedHostname, string:join([inet_parse:ntoa(IP) || IP <- IPs], ", ")]),
+ lookup(SeedHostname, LongNamesUsed, ipv4) ++
+ lookup(SeedHostname, LongNamesUsed, ipv6).
+
+decode_record(ipv4) ->
+ a;
+decode_record(ipv6) ->
+ aaaa.
+
+lookup(SeedHostname, LongNamesUsed, IPv) ->
+ IPs = inet_res:lookup(SeedHostname, in, decode_record(IPv)),
+ rabbit_log:info("Addresses discovered via ~s records of ~s: ~s",
+ [string:to_upper(atom_to_list(decode_record(IPv))),
+ SeedHostname,
+ string:join([inet_parse:ntoa(IP) || IP <- IPs], ", ")]),
Hosts = [extract_host(inet:gethostbyaddr(A), LongNamesUsed, A) ||
- A <- IPs],
+ A <- IPs],
lists:filter(fun(E) -> E =/= error end, Hosts).
+
%% long node names are used
extract_host({ok, {hostent, FQDN, _, _, _, _}}, true, _Address) ->
FQDN;