Software /
code /
prosody
Comparison
prosodyctl @ 5809:be997c6a69be
prosodyctl: check: Support for unicode (IDN) domains (thanks once again albert)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 02 Sep 2013 15:22:41 +0100 |
parent | 5723:24b6eb65480c |
child | 6038:b3ceb7627e27 |
comparison
equal
deleted
inserted
replaced
5808:026367992a0f | 5809:be997c6a69be |
---|---|
836 | 836 |
837 print("Done.\n"); | 837 print("Done.\n"); |
838 end | 838 end |
839 if not what or what == "dns" then | 839 if not what or what == "dns" then |
840 local dns = require "net.dns"; | 840 local dns = require "net.dns"; |
841 local idna = require "util.encodings".idna; | |
841 local ip = require "util.ip"; | 842 local ip = require "util.ip"; |
842 local c2s_ports = set.new(config.get("*", "c2s_ports") or {5222}); | 843 local c2s_ports = set.new(config.get("*", "c2s_ports") or {5222}); |
843 local s2s_ports = set.new(config.get("*", "s2s_ports") or {5269}); | 844 local s2s_ports = set.new(config.get("*", "s2s_ports") or {5269}); |
844 | 845 |
845 local c2s_srv_required, s2s_srv_required; | 846 local c2s_srv_required, s2s_srv_required; |
854 | 855 |
855 local external_addresses, internal_addresses = set.new(), set.new(); | 856 local external_addresses, internal_addresses = set.new(), set.new(); |
856 | 857 |
857 local fqdn = socket.dns.tohostname(socket.dns.gethostname()); | 858 local fqdn = socket.dns.tohostname(socket.dns.gethostname()); |
858 if fqdn then | 859 if fqdn then |
859 local res = dns.lookup(fqdn, "A"); | 860 local res = dns.lookup(idna.to_ascii(fqdn), "A"); |
860 if res then | 861 if res then |
861 for _, record in ipairs(res) do | 862 for _, record in ipairs(res) do |
862 external_addresses:add(record.a); | 863 external_addresses:add(record.a); |
863 end | 864 end |
864 end | 865 end |
865 local res = dns.lookup(fqdn, "AAAA"); | 866 local res = dns.lookup(idna.to_ascii(fqdn), "AAAA"); |
866 if res then | 867 if res then |
867 for _, record in ipairs(res) do | 868 for _, record in ipairs(res) do |
868 external_addresses:add(record.aaaa); | 869 external_addresses:add(record.aaaa); |
869 end | 870 end |
870 end | 871 end |
893 | 894 |
894 local is_component = not not host_options.component_module; | 895 local is_component = not not host_options.component_module; |
895 print("Checking DNS for "..(is_component and "component" or "host").." "..host.."..."); | 896 print("Checking DNS for "..(is_component and "component" or "host").." "..host.."..."); |
896 local target_hosts = set.new(); | 897 local target_hosts = set.new(); |
897 if not is_component then | 898 if not is_component then |
898 local res = dns.lookup("_xmpp-client._tcp."..host..".", "SRV"); | 899 local res = dns.lookup("_xmpp-client._tcp."..idna.to_ascii(host)..".", "SRV"); |
899 if res then | 900 if res then |
900 for _, record in ipairs(res) do | 901 for _, record in ipairs(res) do |
901 target_hosts:add(record.srv.target); | 902 target_hosts:add(record.srv.target); |
902 if not c2s_ports:contains(record.srv.port) then | 903 if not c2s_ports:contains(record.srv.port) then |
903 print(" SRV target "..record.srv.target.." contains unknown client port: "..record.srv.port); | 904 print(" SRV target "..record.srv.target.." contains unknown client port: "..record.srv.port); |
910 else | 911 else |
911 target_hosts:add(host); | 912 target_hosts:add(host); |
912 end | 913 end |
913 end | 914 end |
914 end | 915 end |
915 local res = dns.lookup("_xmpp-server._tcp."..host..".", "SRV"); | 916 local res = dns.lookup("_xmpp-server._tcp."..idna.to_ascii(host)..".", "SRV"); |
916 if res then | 917 if res then |
917 for _, record in ipairs(res) do | 918 for _, record in ipairs(res) do |
918 target_hosts:add(record.srv.target); | 919 target_hosts:add(record.srv.target); |
919 if not s2s_ports:contains(record.srv.port) then | 920 if not s2s_ports:contains(record.srv.port) then |
920 print(" SRV target "..record.srv.target.." contains unknown server port: "..record.srv.port); | 921 print(" SRV target "..record.srv.target.." contains unknown server port: "..record.srv.port); |
941 + set.new(it.to_array(it.values(config.get("*", "modules_enabled")))) | 942 + set.new(it.to_array(it.values(config.get("*", "modules_enabled")))) |
942 + set.new({ config.get(host, "component_module") }); | 943 + set.new({ config.get(host, "component_module") }); |
943 | 944 |
944 if modules:contains("proxy65") then | 945 if modules:contains("proxy65") then |
945 local proxy65_target = config.get(host, "proxy65_address") or host; | 946 local proxy65_target = config.get(host, "proxy65_address") or host; |
946 local A, AAAA = dns.lookup(proxy65_target, "A"), dns.lookup(proxy65_target, "AAAA"); | 947 local A, AAAA = dns.lookup(idna.to_ascii(proxy65_target), "A"), dns.lookup(idna.to_ascii(proxy65_target), "AAAA"); |
947 local prob = {}; | 948 local prob = {}; |
948 if not A then | 949 if not A then |
949 table.insert(prob, "A"); | 950 table.insert(prob, "A"); |
950 end | 951 end |
951 if v6_supported and not AAAA then | 952 if v6_supported and not AAAA then |
956 end | 957 end |
957 end | 958 end |
958 | 959 |
959 for host in target_hosts do | 960 for host in target_hosts do |
960 local host_ok_v4, host_ok_v6; | 961 local host_ok_v4, host_ok_v6; |
961 local res = dns.lookup(host, "A"); | 962 local res = dns.lookup(idna.to_ascii(host), "A"); |
962 if res then | 963 if res then |
963 for _, record in ipairs(res) do | 964 for _, record in ipairs(res) do |
964 if external_addresses:contains(record.a) then | 965 if external_addresses:contains(record.a) then |
965 some_targets_ok = true; | 966 some_targets_ok = true; |
966 host_ok_v4 = true; | 967 host_ok_v4 = true; |
972 print(" "..host.." A record points to unknown address "..record.a); | 973 print(" "..host.." A record points to unknown address "..record.a); |
973 all_targets_ok = false; | 974 all_targets_ok = false; |
974 end | 975 end |
975 end | 976 end |
976 end | 977 end |
977 local res = dns.lookup(host, "AAAA"); | 978 local res = dns.lookup(idna.to_ascii(host), "AAAA"); |
978 if res then | 979 if res then |
979 for _, record in ipairs(res) do | 980 for _, record in ipairs(res) do |
980 if external_addresses:contains(record.aaaa) then | 981 if external_addresses:contains(record.aaaa) then |
981 some_targets_ok = true; | 982 some_targets_ok = true; |
982 host_ok_v6 = true; | 983 host_ok_v6 = true; |