diff options
author | Matthew Wild <mwild1@gmail.com> | 2013-05-17 14:56:36 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2013-05-17 14:56:36 +0100 |
commit | 03e766726b8a51cf6c52a6766a96f385256d9115 (patch) | |
tree | 6e31f0a8aabf962f48cd82e30f0bbec2f61ccb3e /prosodyctl | |
parent | cd0e27c29d94cd3f6993224bd5133638e277f713 (diff) | |
download | prosody-03e766726b8a51cf6c52a6766a96f385256d9115.tar.gz prosody-03e766726b8a51cf6c52a6766a96f385256d9115.zip |
prosodyctl: check dns: Use socket.local_addresses() if available
Diffstat (limited to 'prosodyctl')
-rwxr-xr-x | prosodyctl | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -822,6 +822,7 @@ function commands.check(arg) end if not what or what == "dns" then local dns = require "net.dns"; + local ip = require "util.ip"; local c2s_ports = set.new(config.get("*", "c2s_ports") or {5222}); local s2s_ports = set.new(config.get("*", "s2s_ports") or {5269}); @@ -835,7 +836,7 @@ function commands.check(arg) local problem_hosts = set.new(); - local external_addresses = set.new(); + local external_addresses, internal_addresses = set.new(), set.new(); local fqdn = socket.dns.tohostname(socket.dns.gethostname()); if fqdn then @@ -853,6 +854,16 @@ function commands.check(arg) end end + local local_addresses = socket.local_addresses and socket.local_addresses() or {}; + + for addr in it.values(local_addresses) do + if not ip.new_ip(addr).private then + external_addresses:add(addr); + else + internal_addresses:add(addr); + end + end + if external_addresses:empty() then print(""); print(" Failed to determine the external addresses of this server. Checks may be inaccurate."); @@ -918,6 +929,10 @@ function commands.check(arg) if external_addresses:contains(record.a) then some_targets_ok = true; host_ok_v4 = true; + elseif internal_addresses:contains(record.a) then + host_ok_v4 = true; + some_targets_ok = true; + print(" "..host.." A record points to internal address, external connections might fail"); else print(" "..host.." A record points to unknown address "..record.a); all_targets_ok = false; @@ -930,6 +945,10 @@ function commands.check(arg) if external_addresses:contains(record.aaaa) then some_targets_ok = true; host_ok_v6 = true; + elseif internal_addresses:contains(record.aaaa) then + host_ok_v6 = true; + some_targets_ok = true; + print(" "..host.." AAAA record points to internal address, external connections might fail"); else print(" "..host.." AAAA record points to unknown address "..record.aaaa); all_targets_ok = false; |