Software /
code /
prosody
Annotate
util/prosodyctl/check.lua @ 12362:0fd58f54d653
Merge config-updates+check-turn from timber
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 04 Mar 2022 16:33:41 +0000 |
parent | 12320:f0be98bab9dd |
parent | 12357:cd11d7c4af8b |
child | 12372:1ba451c10f41 |
rev | line source |
---|---|
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local configmanager = require "core.configmanager"; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 local show_usage = require "util.prosodyctl".show_usage; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local show_warning = require "util.prosodyctl".show_warning; |
11780
98ae95235775
util.prosodyctl.check: Refuse to do ojn test unless prosody is running
Kim Alvefur <zash@zash.se>
parents:
11779
diff
changeset
|
4 local is_prosody_running = require "util.prosodyctl".isrunning; |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 local dependencies = require "util.dependencies"; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 local socket = require "socket"; |
11827
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
7 local socket_url = require "socket.url"; |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 local jid_split = require "util.jid".prepped_split; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 local modulemanager = require "core.modulemanager"; |
11827
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
10 local async = require "util.async"; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
11 local httputil = require "util.http"; |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 |
11826
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
13 local function check_ojn(check_type, target_host) |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
14 local http = require "net.http"; -- .new({}); |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
15 local json = require "util.json"; |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
16 |
11826
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
17 local response, err = async.wait_for(http.request( |
11827
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
18 ("https://observe.jabber.network/api/v1/check/%s"):format(httputil.urlencode(check_type)), |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
19 { |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
20 method="POST", |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
21 headers={["Accept"] = "application/json"; ["Content-Type"] = "application/json"}, |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
22 body=json.encode({target=target_host}), |
11826
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
23 })); |
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
24 |
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
25 if not response then |
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
26 return false, err; |
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
27 end |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
28 |
11826
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
29 if response.code ~= 200 then |
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
30 return false, ("API replied with non-200 code: %d"):format(response.code); |
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
31 end |
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
32 |
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
33 local decoded_body, err = json.decode(response.body); |
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
34 if decoded_body == nil then |
e1c4cc5d0ef8
prosodyctl: Use HTTP client in promise mode for connectivity check
Kim Alvefur <zash@zash.se>
parents:
11807
diff
changeset
|
35 return false, ("Failed to parse API JSON: %s"):format(err) |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
36 end |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
37 |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
38 local success = decoded_body["success"]; |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
39 return success == true, nil; |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
40 end |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
41 |
11827
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
42 local function check_probe(base_url, probe_module, target) |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
43 local http = require "net.http"; -- .new({}); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
44 local params = httputil.formencode({ module = probe_module; target = target }) |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
45 local response, err = async.wait_for(http.request(base_url .. "?" .. params)); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
46 |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
47 if not response then return false, err; end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
48 |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
49 if response.code ~= 200 then return false, ("API replied with non-200 code: %d"):format(response.code); end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
50 |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
51 for line in response.body:gmatch("[^\r\n]+") do |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
52 local probe_success = line:match("^probe_success%s+(%d+)"); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
53 |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
54 if probe_success == "1" then |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
55 return true; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
56 elseif probe_success == "0" then |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
57 return false; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
58 end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
59 end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
60 return false, "Probe endpoint did not return a success status"; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
61 end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
62 |
12357
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
63 local function check_turn_service(turn_service) |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
64 local stun = require "net.stun"; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
65 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
66 -- Create UDP socket for communication with the server |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
67 local sock = assert(require "socket".udp()); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
68 sock:setsockname("*", 0); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
69 sock:setpeername(turn_service.host, turn_service.port); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
70 sock:settimeout(10); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
71 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
72 -- Helper function to receive a packet |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
73 local function receive_packet() |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
74 local raw_packet, err = sock:receive(); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
75 if not raw_packet then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
76 return nil, err; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
77 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
78 return stun.new_packet():deserialize(raw_packet); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
79 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
80 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
81 local result = { warnings = {} }; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
82 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
83 -- Send a "binding" query, i.e. a request for our external IP/port |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
84 local bind_query = stun.new_packet("binding", "request"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
85 bind_query:add_attribute("software", "prosodyctl check turn"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
86 sock:send(bind_query:serialize()); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
87 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
88 local bind_result, err = receive_packet(); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
89 if not bind_result then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
90 result.error = "No STUN response: "..err; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
91 return result; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
92 elseif bind_result:is_err_resp() then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
93 result.error = ("STUN server returned error: %d (%s)"):format(bind_result:get_error()); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
94 return result; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
95 elseif not bind_result:is_success_resp() then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
96 result.error = ("Unexpected STUN response: %d (%s)"):format(bind_result:get_type()); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
97 return result; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
98 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
99 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
100 result.external_ip = bind_result:get_xor_mapped_address(); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
101 if not result.external_ip then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
102 result.error = "STUN server did not return an address"; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
103 return result; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
104 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
105 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
106 -- Send a TURN "allocate" request. Expected to fail due to auth, but |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
107 -- necessary to obtain a valid realm/nonce from the server. |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
108 local pre_request = stun.new_packet("allocate", "request"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
109 sock:send(pre_request:serialize()); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
110 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
111 local pre_result, err = receive_packet(); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
112 if not pre_result then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
113 result.error = "No initial TURN response: "..err; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
114 return result; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
115 elseif pre_result:is_success_resp() then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
116 result.error = "TURN server does not have authentication enabled"; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
117 return result; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
118 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
119 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
120 local realm = pre_result:get_attribute("realm"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
121 local nonce = pre_result:get_attribute("nonce"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
122 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
123 if not realm then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
124 table.insert(result.warnings, "TURN server did not return an authentication realm"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
125 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
126 if not nonce then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
127 table.insert(result.warnings, "TURN server did not return a nonce"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
128 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
129 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
130 -- Use the configured secret to obtain temporary user/pass credentials |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
131 local turn_user, turn_pass = stun.get_user_pass_from_secret(turn_service.secret); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
132 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
133 -- Send a TURN allocate request, will fail if auth is wrong |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
134 local alloc_request = stun.new_packet("allocate", "request"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
135 alloc_request:add_requested_transport("udp"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
136 alloc_request:add_attribute("username", turn_user); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
137 if realm then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
138 alloc_request:add_attribute("realm", realm); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
139 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
140 if nonce then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
141 alloc_request:add_attribute("nonce", nonce); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
142 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
143 local key = stun.get_long_term_auth_key(realm or turn_service.host, turn_user, turn_pass); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
144 alloc_request:add_message_integrity(key); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
145 sock:send(alloc_request:serialize()); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
146 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
147 -- Check the response |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
148 local alloc_response, err = receive_packet(); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
149 if not alloc_response then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
150 result.error = "TURN server did not response to allocation request: "..err; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
151 return; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
152 elseif alloc_response:is_err_resp() then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
153 result.error = ("TURN allocation failed: %d (%s)"):format(alloc_response:get_error()); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
154 return result; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
155 elseif not alloc_response:is_success_resp() then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
156 result.error = ("Unexpected TURN response: %d (%s)"):format(alloc_response:get_type()); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
157 return result; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
158 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
159 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
160 -- No errors? Ok! |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
161 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
162 return result; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
163 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
164 |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
165 local function skip_bare_jid_hosts(host) |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
166 if jid_split(host) then |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
167 -- See issue #779 |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
168 return false; |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
169 end |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
170 return true; |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
171 end |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
172 |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
173 local function check(arg) |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
174 if arg[1] == "--help" then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
175 show_usage([[check]], [[Perform basic checks on your Prosody installation]]); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
176 return 1; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
177 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
178 local what = table.remove(arg, 1); |
11798
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
179 local array = require "util.array"; |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
180 local set = require "util.set"; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
181 local it = require "util.iterators"; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
182 local ok = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
183 local function disabled_hosts(host, conf) return host ~= "*" and conf.enabled ~= false; end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
184 local function enabled_hosts() return it.filter(disabled_hosts, pairs(configmanager.getconfig())); end |
12357
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
185 if not (what == nil or what == "disabled" or what == "config" or what == "dns" or what == "certs" or what == "connectivity" or what == "turn") then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
186 show_warning("Don't know how to check '%s'. Try one of 'config', 'dns', 'certs', 'disabled', 'turn' or 'connectivity'.", what); |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
187 show_warning("Note: The connectivity check will connect to a remote server."); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
188 return 1; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
189 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
190 if not what or what == "disabled" then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
191 local disabled_hosts_set = set.new(); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
192 for host, host_options in it.filter("*", pairs(configmanager.getconfig())) do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
193 if host_options.enabled == false then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
194 disabled_hosts_set:add(host); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
195 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
196 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
197 if not disabled_hosts_set:empty() then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
198 local msg = "Checks will be skipped for these disabled hosts: %s"; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
199 if what then msg = "These hosts are disabled: %s"; end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
200 show_warning(msg, tostring(disabled_hosts_set)); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
201 if what then return 0; end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
202 print"" |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
203 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
204 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
205 if not what or what == "config" then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
206 print("Checking config..."); |
11798
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
207 local obsolete = set.new({ --> remove |
12118
30d55809d9a6
util.prosodyctl.check: Add some more obsolete settings
Kim Alvefur <zash@zash.se>
parents:
12099
diff
changeset
|
208 "archive_cleanup_interval", |
11634
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
209 "cross_domain_bosh", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
210 "cross_domain_websocket", |
12118
30d55809d9a6
util.prosodyctl.check: Add some more obsolete settings
Kim Alvefur <zash@zash.se>
parents:
12099
diff
changeset
|
211 "dns_timeout", |
30d55809d9a6
util.prosodyctl.check: Add some more obsolete settings
Kim Alvefur <zash@zash.se>
parents:
12099
diff
changeset
|
212 "muc_log_cleanup_interval", |
30d55809d9a6
util.prosodyctl.check: Add some more obsolete settings
Kim Alvefur <zash@zash.se>
parents:
12099
diff
changeset
|
213 "s2s_dns_resolvers", |
30d55809d9a6
util.prosodyctl.check: Add some more obsolete settings
Kim Alvefur <zash@zash.se>
parents:
12099
diff
changeset
|
214 "setgid", |
30d55809d9a6
util.prosodyctl.check: Add some more obsolete settings
Kim Alvefur <zash@zash.se>
parents:
12099
diff
changeset
|
215 "setuid", |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
216 }); |
12159
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
217 local function instead_use(kind, name, value) |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
218 if kind == "option" then |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
219 if value then |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
220 return string.format("instead, use '%s = %q'", name, value); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
221 else |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
222 return string.format("instead, use '%s'", name); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
223 end |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
224 elseif kind == "module" then |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
225 return string.format("instead, add %q to '%s'", name, value or "modules_enabled"); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
226 elseif kind == "community" then |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
227 return string.format("instead, add %q from %s", name, value or "prosody-modules"); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
228 end |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
229 return kind |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
230 end |
11798
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
231 local deprecated_replacements = { |
12159
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
232 anonymous_login = instead_use("option", "authentication", "anonymous"); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
233 daemonize = "instead, use the --daemonize/-D or --foreground/-F command line flags"; |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
234 disallow_s2s = instead_use("module", "s2s"); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
235 no_daemonize = "instead, use the --daemonize/-D or --foreground/-F command line flags"; |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
236 require_encryption = "instead, use 'c2s_require_encryption' and 's2s_require_encryption'"; |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
237 vcard_compatibility = instead_use("community", "mod_compat_vcard"); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
238 use_libevent = instead_use("option", "network_backend", "event"); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
239 whitelist_registration_only = instead_use("option", "allowlist_registration_only"); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
240 registration_whitelist = instead_use("option", "registration_allowlist"); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
241 registration_blacklist = instead_use("option", "registration_blocklist"); |
aa299551f8c6
util.prosodyctl.check: Parameterize replacement instructions
Kim Alvefur <zash@zash.se>
parents:
12158
diff
changeset
|
242 blacklist_on_registration_throttle_overload = instead_use("blocklist_on_registration_throttle_overload"); |
11798
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
243 }; |
11800
60018637f5d4
util.prosodyctl.check: Nudge towards plural port options
Kim Alvefur <zash@zash.se>
parents:
11799
diff
changeset
|
244 -- FIXME all the singular _port and _interface options are supposed to be deprecated too |
11798
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
245 local deprecated_ports = { bosh = "http", legacy_ssl = "c2s_direct_tls" }; |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
246 local port_suffixes = set.new({ "port", "ports", "interface", "interfaces", "ssl" }); |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
247 for port, replacement in pairs(deprecated_ports) do |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
248 for suffix in port_suffixes do |
11800
60018637f5d4
util.prosodyctl.check: Nudge towards plural port options
Kim Alvefur <zash@zash.se>
parents:
11799
diff
changeset
|
249 local rsuffix = (suffix == "port" or suffix == "interface") and suffix.."s" or suffix; |
12158
7ff3699c1653
util.prosodyctl.check: Move word to ease future translations
Kim Alvefur <zash@zash.se>
parents:
12157
diff
changeset
|
250 deprecated_replacements[port.."_"..suffix] = "instead, use '"..replacement.."_"..rsuffix.."'" |
11798
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
251 end |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
252 end |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
253 local deprecated = set.new(array.collect(it.keys(deprecated_replacements))); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
254 local known_global_options = set.new({ |
11635
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
255 "access_control_allow_credentials", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
256 "access_control_allow_headers", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
257 "access_control_allow_methods", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
258 "access_control_max_age", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
259 "admin_socket", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
260 "body_size_limit", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
261 "bosh_max_inactivity", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
262 "bosh_max_polling", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
263 "bosh_max_wait", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
264 "buffer_size_limit", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
265 "c2s_close_timeout", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
266 "c2s_stanza_size_limit", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
267 "c2s_tcp_keepalives", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
268 "c2s_timeout", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
269 "component_stanza_size_limit", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
270 "component_tcp_keepalives", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
271 "consider_bosh_secure", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
272 "consider_websocket_secure", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
273 "console_banner", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
274 "console_prettyprint_settings", |
11634
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
275 "daemonize", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
276 "gc", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
277 "http_default_host", |
11635
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
278 "http_errors_always_show", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
279 "http_errors_default_message", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
280 "http_errors_detailed", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
281 "http_errors_messages", |
11833
bd86ab8122d9
util.prosodyctl.check: Add two known globals from mod_http
Kim Alvefur <zash@zash.se>
parents:
11827
diff
changeset
|
282 "http_max_buffer_size", |
bd86ab8122d9
util.prosodyctl.check: Add two known globals from mod_http
Kim Alvefur <zash@zash.se>
parents:
11827
diff
changeset
|
283 "http_max_content_size", |
11634
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
284 "installer_plugin_path", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
285 "limits", |
11635
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
286 "limits_resolution", |
11634
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
287 "log", |
11635
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
288 "multiplex_buffer_size", |
11634
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
289 "network_backend", |
11635
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
290 "network_default_read_size", |
11634
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
291 "network_settings", |
11940
2d82e4245aa3
util.prosodyctl.check: Add mod_http_openmetrics settings to known globals
Kim Alvefur <zash@zash.se>
parents:
11925
diff
changeset
|
292 "openmetrics_allow_cidr", |
2d82e4245aa3
util.prosodyctl.check: Add mod_http_openmetrics settings to known globals
Kim Alvefur <zash@zash.se>
parents:
11925
diff
changeset
|
293 "openmetrics_allow_ips", |
11634
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
294 "pidfile", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
295 "plugin_paths", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
296 "plugin_server", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
297 "prosodyctl_timeout", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
298 "prosody_group", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
299 "prosody_user", |
11635
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
300 "run_as_root", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
301 "s2s_close_timeout", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
302 "s2s_insecure_domains", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
303 "s2s_require_encryption", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
304 "s2s_secure_auth", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
305 "s2s_secure_domains", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
306 "s2s_stanza_size_limit", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
307 "s2s_tcp_keepalives", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
308 "s2s_timeout", |
11634
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
309 "statistics", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
310 "statistics_config", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
311 "statistics_interval", |
11635
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
312 "tcp_keepalives", |
12099
b344edad61d3
core.certmanager: Rename preset option to 'tls_preset'
Kim Alvefur <zash@zash.se>
parents:
11957
diff
changeset
|
313 "tls_profile", |
11635
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
314 "trusted_proxies", |
11634
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
315 "umask", |
11635
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
316 "use_dane", |
11634
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
317 "use_ipv4", |
a6c87b4c0cdf
util.prosodyctl.check: Format, sort option listings into canonical form
Kim Alvefur <zash@zash.se>
parents:
11617
diff
changeset
|
318 "use_ipv6", |
11635
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
319 "websocket_frame_buffer_limit", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
320 "websocket_frame_fragment_limit", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
321 "websocket_get_response_body", |
1b17b967838e
util.prosodyctl.check: Collect options from all global plugins
Kim Alvefur <zash@zash.se>
parents:
11634
diff
changeset
|
322 "websocket_get_response_text", |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
323 }); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
324 local config = configmanager.getconfig(); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
325 -- Check that we have any global options (caused by putting a host at the top) |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
326 if it.count(it.filter("log", pairs(config["*"]))) == 0 then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
327 ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
328 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
329 print(" No global options defined. Perhaps you have put a host definition at the top") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
330 print(" of the config file? They should be at the bottom, see https://prosody.im/doc/configure#overview"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
331 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
332 if it.count(enabled_hosts()) == 0 then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
333 ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
334 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
335 if it.count(it.filter("*", pairs(config))) == 0 then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
336 print(" No hosts are defined, please add at least one VirtualHost section") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
337 elseif config["*"]["enabled"] == false then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
338 print(" No hosts are enabled. Remove enabled = false from the global section or put enabled = true under at least one VirtualHost section") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
339 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
340 print(" All hosts are disabled. Remove enabled = false from at least one VirtualHost section") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
341 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
342 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
343 if not config["*"].modules_enabled then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
344 print(" No global modules_enabled is set?"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
345 local suggested_global_modules; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
346 for host, options in enabled_hosts() do --luacheck: ignore 213/host |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
347 if not options.component_module and options.modules_enabled then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
348 suggested_global_modules = set.intersection(suggested_global_modules or set.new(options.modules_enabled), set.new(options.modules_enabled)); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
349 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
350 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
351 if suggested_global_modules and not suggested_global_modules:empty() then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
352 print(" Consider moving these modules into modules_enabled in the global section:") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
353 print(" "..tostring(suggested_global_modules / function (x) return ("%q"):format(x) end)); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
354 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
355 print(); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
356 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
357 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
358 do -- Check for modules enabled both normally and as components |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
359 local modules = set.new(config["*"]["modules_enabled"]); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
360 for host, options in enabled_hosts() do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
361 local component_module = options.component_module; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
362 if component_module and modules:contains(component_module) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
363 print((" mod_%s is enabled both in modules_enabled and as Component %q %q"):format(component_module, host, component_module)); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
364 print(" This means the service is enabled on all VirtualHosts as well as the Component."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
365 print(" Are you sure this what you want? It may cause unexpected behaviour."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
366 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
367 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
368 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
369 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
370 -- Check for global options under hosts |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
371 local global_options = set.new(it.to_array(it.keys(config["*"]))); |
11798
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
372 local obsolete_global_options = set.intersection(global_options, obsolete); |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
373 if not obsolete_global_options:empty() then |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
374 print(""); |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
375 print(" You have some obsolete options you can remove from the global section:"); |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
376 print(" "..tostring(obsolete_global_options)) |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
377 ok = false; |
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
378 end |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
379 local deprecated_global_options = set.intersection(global_options, deprecated); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
380 if not deprecated_global_options:empty() then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
381 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
382 print(" You have some deprecated options in the global section:"); |
11798
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
383 for option in deprecated_global_options do |
12158
7ff3699c1653
util.prosodyctl.check: Move word to ease future translations
Kim Alvefur <zash@zash.se>
parents:
12157
diff
changeset
|
384 print((" '%s' -- %s"):format(option, deprecated_replacements[option])); |
11798
ba88060fa145
util.prosodyctl.check: Suggest replacements for deprecated options #1684
Kim Alvefur <zash@zash.se>
parents:
11783
diff
changeset
|
385 end |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
386 ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
387 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
388 for host, options in it.filter(function (h) return h ~= "*" end, pairs(configmanager.getconfig())) do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
389 local host_options = set.new(it.to_array(it.keys(options))); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
390 local misplaced_options = set.intersection(host_options, known_global_options); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
391 for name in pairs(options) do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
392 if name:match("^interfaces?") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
393 or name:match("_ports?$") or name:match("_interfaces?$") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
394 or (name:match("_ssl$") and not name:match("^[cs]2s_ssl$")) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
395 misplaced_options:add(name); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
396 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
397 end |
11799
8c9ec2db1d95
util.prosodyctl.check: Fix to not treat some options as misplaced
Kim Alvefur <zash@zash.se>
parents:
11798
diff
changeset
|
398 -- FIXME These _could_ be misplaced, but we would have to check where the corresponding module is loaded to be sure |
8c9ec2db1d95
util.prosodyctl.check: Fix to not treat some options as misplaced
Kim Alvefur <zash@zash.se>
parents:
11798
diff
changeset
|
399 misplaced_options:exclude(set.new({ "external_service_port", "turn_external_port" })); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
400 if not misplaced_options:empty() then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
401 ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
402 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
403 local n = it.count(misplaced_options); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
404 print(" You have "..n.." option"..(n>1 and "s " or " ").."set under "..host.." that should be"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
405 print(" in the global section of the config file, above any VirtualHost or Component definitions,") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
406 print(" see https://prosody.im/doc/configure#overview for more information.") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
407 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
408 print(" You need to move the following option"..(n>1 and "s" or "")..": "..table.concat(it.to_array(misplaced_options), ", ")); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
409 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
410 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
411 for host, options in enabled_hosts() do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
412 local host_options = set.new(it.to_array(it.keys(options))); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
413 local subdomain = host:match("^[^.]+"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
414 if not(host_options:contains("component_module")) and (subdomain == "jabber" or subdomain == "xmpp" |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
415 or subdomain == "chat" or subdomain == "im") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
416 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
417 print(" Suggestion: If "..host.. " is a new host with no real users yet, consider renaming it now to"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
418 print(" "..host:gsub("^[^.]+%.", "")..". You can use SRV records to redirect XMPP clients and servers to "..host.."."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
419 print(" For more information see: https://prosody.im/doc/dns"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
420 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
421 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
422 local all_modules = set.new(config["*"].modules_enabled); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
423 local all_options = set.new(it.to_array(it.keys(config["*"]))); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
424 for host in enabled_hosts() do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
425 all_options:include(set.new(it.to_array(it.keys(config[host])))); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
426 all_modules:include(set.new(config[host].modules_enabled)); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
427 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
428 for mod in all_modules do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
429 if mod:match("^mod_") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
430 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
431 print(" Modules in modules_enabled should not have the 'mod_' prefix included."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
432 print(" Change '"..mod.."' to '"..mod:match("^mod_(.*)").."'."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
433 elseif mod:match("^auth_") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
434 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
435 print(" Authentication modules should not be added to modules_enabled,"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
436 print(" but be specified in the 'authentication' option."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
437 print(" Remove '"..mod.."' from modules_enabled and instead add"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
438 print(" authentication = '"..mod:match("^auth_(.*)").."'"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
439 print(" For more information see https://prosody.im/doc/authentication"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
440 elseif mod:match("^storage_") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
441 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
442 print(" storage modules should not be added to modules_enabled,"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
443 print(" but be specified in the 'storage' option."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
444 print(" Remove '"..mod.."' from modules_enabled and instead add"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
445 print(" storage = '"..mod:match("^storage_(.*)").."'"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
446 print(" For more information see https://prosody.im/doc/storage"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
447 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
448 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
449 if all_modules:contains("vcard") and all_modules:contains("vcard_legacy") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
450 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
451 print(" Both mod_vcard_legacy and mod_vcard are enabled but they conflict"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
452 print(" with each other. Remove one."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
453 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
454 if all_modules:contains("pep") and all_modules:contains("pep_simple") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
455 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
456 print(" Both mod_pep_simple and mod_pep are enabled but they conflict"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
457 print(" with each other. Remove one."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
458 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
459 for host, host_config in pairs(config) do --luacheck: ignore 213/host |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
460 if type(rawget(host_config, "storage")) == "string" and rawget(host_config, "default_storage") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
461 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
462 print(" The 'default_storage' option is not needed if 'storage' is set to a string."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
463 break; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
464 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
465 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
466 local require_encryption = set.intersection(all_options, set.new({ |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
467 "require_encryption", "c2s_require_encryption", "s2s_require_encryption" |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
468 })):empty(); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
469 local ssl = dependencies.softreq"ssl"; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
470 if not ssl then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
471 if not require_encryption then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
472 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
473 print(" You require encryption but LuaSec is not available."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
474 print(" Connections will fail."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
475 ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
476 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
477 elseif not ssl.loadcertificate then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
478 if all_options:contains("s2s_secure_auth") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
479 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
480 print(" You have set s2s_secure_auth but your version of LuaSec does "); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
481 print(" not support certificate validation, so all s2s connections will"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
482 print(" fail."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
483 ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
484 elseif all_options:contains("s2s_secure_domains") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
485 local secure_domains = set.new(); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
486 for host in enabled_hosts() do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
487 if config[host].s2s_secure_auth == true then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
488 secure_domains:add("*"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
489 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
490 secure_domains:include(set.new(config[host].s2s_secure_domains)); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
491 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
492 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
493 if not secure_domains:empty() then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
494 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
495 print(" You have set s2s_secure_domains but your version of LuaSec does "); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
496 print(" not support certificate validation, so s2s connections to/from "); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
497 print(" these domains will fail."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
498 ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
499 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
500 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
501 elseif require_encryption and not all_modules:contains("tls") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
502 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
503 print(" You require encryption but mod_tls is not enabled."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
504 print(" Connections will fail."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
505 ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
506 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
507 |
12317
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
508 do |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
509 local global_modules = set.new(config["*"].modules_enabled); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
510 local registration_enabled_hosts = {}; |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
511 for host in enabled_hosts() do |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
512 local host_modules = set.new(config[host].modules_enabled) + global_modules; |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
513 local allow_registration = config[host].allow_registration; |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
514 local mod_register = host_modules:contains("register"); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
515 local mod_register_ibr = host_modules:contains("register_ibr"); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
516 local mod_invites_register = host_modules:contains("invites_register"); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
517 local registration_invite_only = config[host].registration_invite_only; |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
518 local is_vhost = not config[host].component_module; |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
519 if is_vhost and (mod_register_ibr or (mod_register and allow_registration)) |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
520 and not (mod_invites_register and registration_invite_only) then |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
521 table.insert(registration_enabled_hosts, host); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
522 end |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
523 end |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
524 if #registration_enabled_hosts > 0 then |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
525 table.sort(registration_enabled_hosts); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
526 print(""); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
527 print(" Public registration is enabled on:"); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
528 print(" "..table.concat(registration_enabled_hosts, ", ")); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
529 print(""); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
530 print(" If this is intentional, review our guidelines on running a public server"); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
531 print(" at https://prosody.im/doc/public_servers - otherwise, consider switching to"); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
532 print(" invite-based registration, which is more secure."); |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
533 end |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
534 end |
b4f2027ef917
util.prosodyctl: Warn about enabled public registration in 'check config'
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
535 |
12318
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
536 do |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
537 local orphan_components = {}; |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
538 local referenced_components = set.new(); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
539 local enabled_hosts_set = set.new(); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
540 for host, host_options in it.filter("*", pairs(configmanager.getconfig())) do |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
541 if host_options.enabled ~= false then |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
542 enabled_hosts_set:add(host); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
543 for _, disco_item in ipairs(host_options.disco_items or {}) do |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
544 referenced_components:add(disco_item[1]); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
545 end |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
546 end |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
547 end |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
548 for host, host_config in enabled_hosts() do |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
549 local is_component = not not host_config.component_module; |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
550 if is_component then |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
551 local parent_domain = host:match("^[^.]+%.(.+)$"); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
552 local is_orphan = not (enabled_hosts_set:contains(parent_domain) or referenced_components:contains(host)); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
553 if is_orphan then |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
554 table.insert(orphan_components, host); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
555 end |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
556 end |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
557 end |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
558 if #orphan_components > 0 then |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
559 table.sort(orphan_components); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
560 print(""); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
561 print(" Your configuration contains the following unreferenced components:\n"); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
562 print(" "..table.concat(orphan_components, "\n ")); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
563 print(""); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
564 print(" Clients may not be able to discover these services because they are not linked to"); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
565 print(" any VirtualHost. They are automatically linked if they are direct subdomains of a"); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
566 print(" VirtualHost. Alternatively, you can explicitly link them using the disco_items option."); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
567 print(" For more information see https://prosody.im/doc/modules/mod_disco#items"); |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
568 end |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
569 end |
239ce74aa6a4
util.prosodyctl: check: warn about unreferenced components, suggest disco_items
Matthew Wild <mwild1@gmail.com>
parents:
12317
diff
changeset
|
570 |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
571 print("Done.\n"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
572 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
573 if not what or what == "dns" then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
574 local dns = require "net.dns"; |
10971
3cdb4a7cb406
util.prosodyctl.check: Use net.unbound for DNS if available
Kim Alvefur <zash@zash.se>
parents:
10932
diff
changeset
|
575 pcall(function () |
11645
3be346c5b940
util.prosodyctl.check: Reload unbound to ensure hosts.txt is ignored
Kim Alvefur <zash@zash.se>
parents:
11635
diff
changeset
|
576 local unbound = require"net.unbound"; |
11617
166f8e1d82b0
util.prosodyctl.check: Ensure that libunbound does not check hosts file
Kim Alvefur <zash@zash.se>
parents:
11616
diff
changeset
|
577 local unbound_config = configmanager.get("*", "unbound") or {}; |
166f8e1d82b0
util.prosodyctl.check: Ensure that libunbound does not check hosts file
Kim Alvefur <zash@zash.se>
parents:
11616
diff
changeset
|
578 unbound_config.hoststxt = false; -- don't look at /etc/hosts |
166f8e1d82b0
util.prosodyctl.check: Ensure that libunbound does not check hosts file
Kim Alvefur <zash@zash.se>
parents:
11616
diff
changeset
|
579 configmanager.set("*", "unbound", unbound_config); |
12233
e4530bdbf5f3
util.prosodyctl.check: Fix reset of libunbound before DNS checks
Kim Alvefur <zash@zash.se>
parents:
12231
diff
changeset
|
580 unbound.dns.purge(); -- ensure the above config is used |
11645
3be346c5b940
util.prosodyctl.check: Reload unbound to ensure hosts.txt is ignored
Kim Alvefur <zash@zash.se>
parents:
11635
diff
changeset
|
581 dns = unbound.dns; |
10971
3cdb4a7cb406
util.prosodyctl.check: Use net.unbound for DNS if available
Kim Alvefur <zash@zash.se>
parents:
10932
diff
changeset
|
582 end) |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
583 local idna = require "util.encodings".idna; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
584 local ip = require "util.ip"; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
585 local c2s_ports = set.new(configmanager.get("*", "c2s_ports") or {5222}); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
586 local s2s_ports = set.new(configmanager.get("*", "s2s_ports") or {5269}); |
11778
f254fd16218a
mod_c2s: Rename Direct TLS listener 'c2s_direct_tls' for clarity
Kim Alvefur <zash@zash.se>
parents:
11777
diff
changeset
|
587 local c2s_tls_ports = set.new(configmanager.get("*", "c2s_direct_tls_ports") or {}); |
11776
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
588 local s2s_tls_ports = set.new(configmanager.get("*", "s2s_direct_tls_ports") or {}); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
589 |
12230
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
590 if set.new(configmanager.get("*", "modules_enabled")):contains("net_multiplex") then |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
591 local multiplex_ports = set.new(configmanager.get("*", "ports") or {}); |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
592 local multiplex_tls_ports = set.new(configmanager.get("*", "ssl_ports") or {}); |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
593 if not multiplex_ports:empty() then |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
594 c2s_ports = c2s_ports + multiplex_ports; |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
595 s2s_ports = s2s_ports + multiplex_ports; |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
596 end |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
597 if not multiplex_tls_ports:empty() then |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
598 c2s_tls_ports = c2s_tls_ports + multiplex_tls_ports; |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
599 s2s_tls_ports = s2s_tls_ports + multiplex_tls_ports; |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
600 end |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
601 end |
f590058d8d99
util.prosodyctl.check: Include multiplexed ports in DNS checks #1704
Kim Alvefur <zash@zash.se>
parents:
12218
diff
changeset
|
602 |
11776
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
603 local c2s_srv_required, s2s_srv_required, c2s_tls_srv_required, s2s_tls_srv_required; |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
604 if not c2s_ports:contains(5222) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
605 c2s_srv_required = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
606 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
607 if not s2s_ports:contains(5269) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
608 s2s_srv_required = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
609 end |
11615
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
610 if not c2s_tls_ports:empty() then |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
611 c2s_tls_srv_required = true; |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
612 end |
11776
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
613 if not s2s_tls_ports:empty() then |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
614 s2s_tls_srv_required = true; |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
615 end |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
616 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
617 local problem_hosts = set.new(); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
618 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
619 local external_addresses, internal_addresses = set.new(), set.new(); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
620 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
621 local fqdn = socket.dns.tohostname(socket.dns.gethostname()); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
622 if fqdn then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
623 do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
624 local res = dns.lookup(idna.to_ascii(fqdn), "A"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
625 if res then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
626 for _, record in ipairs(res) do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
627 external_addresses:add(record.a); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
628 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
629 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
630 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
631 do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
632 local res = dns.lookup(idna.to_ascii(fqdn), "AAAA"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
633 if res then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
634 for _, record in ipairs(res) do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
635 external_addresses:add(record.aaaa); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
636 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
637 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
638 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
639 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
640 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
641 local local_addresses = require"util.net".local_addresses() or {}; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
642 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
643 for addr in it.values(local_addresses) do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
644 if not ip.new_ip(addr).private then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
645 external_addresses:add(addr); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
646 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
647 internal_addresses:add(addr); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
648 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
649 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
650 |
12320
f0be98bab9dd
prosodyctl: check dns: Allow admin to specify undiscoverable external IPs in config
Matthew Wild <mwild1@gmail.com>
parents:
12319
diff
changeset
|
651 -- Allow admin to specify additional (e.g. undiscoverable) IP addresses in the config |
f0be98bab9dd
prosodyctl: check dns: Allow admin to specify undiscoverable external IPs in config
Matthew Wild <mwild1@gmail.com>
parents:
12319
diff
changeset
|
652 for _, address in ipairs(configmanager.get("*", "external_addresses") or {}) do |
f0be98bab9dd
prosodyctl: check dns: Allow admin to specify undiscoverable external IPs in config
Matthew Wild <mwild1@gmail.com>
parents:
12319
diff
changeset
|
653 external_addresses:add(address); |
f0be98bab9dd
prosodyctl: check dns: Allow admin to specify undiscoverable external IPs in config
Matthew Wild <mwild1@gmail.com>
parents:
12319
diff
changeset
|
654 end |
f0be98bab9dd
prosodyctl: check dns: Allow admin to specify undiscoverable external IPs in config
Matthew Wild <mwild1@gmail.com>
parents:
12319
diff
changeset
|
655 |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
656 if external_addresses:empty() then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
657 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
658 print(" Failed to determine the external addresses of this server. Checks may be inaccurate."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
659 c2s_srv_required, s2s_srv_required = true, true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
660 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
661 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
662 local v6_supported = not not socket.tcp6; |
11924
53e68227c2c0
util.prosodyctl.check: Respect use_ipv4/v6 in proxy65 check
Kim Alvefur <zash@zash.se>
parents:
11923
diff
changeset
|
663 local use_ipv4 = configmanager.get("*", "use_ipv4") ~= false; |
53e68227c2c0
util.prosodyctl.check: Respect use_ipv4/v6 in proxy65 check
Kim Alvefur <zash@zash.se>
parents:
11923
diff
changeset
|
664 local use_ipv6 = v6_supported and configmanager.get("*", "use_ipv6") ~= false; |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
665 |
11655
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
666 local function trim_dns_name(n) |
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
667 return (n:gsub("%.$", "")); |
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
668 end |
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
669 |
12319
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
670 local unknown_addresses = set.new(); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
671 |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
672 for jid, host_options in enabled_hosts() do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
673 local all_targets_ok, some_targets_ok = true, false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
674 local node, host = jid_split(jid); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
675 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
676 local modules, component_module = modulemanager.get_modules_for_host(host); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
677 if component_module then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
678 modules:add(component_module); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
679 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
680 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
681 local is_component = not not host_options.component_module; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
682 print("Checking DNS for "..(is_component and "component" or "host").." "..jid.."..."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
683 if node then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
684 print("Only the domain part ("..host..") is used in DNS.") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
685 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
686 local target_hosts = set.new(); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
687 if modules:contains("c2s") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
688 local res = dns.lookup("_xmpp-client._tcp."..idna.to_ascii(host)..".", "SRV"); |
11613
c8a9f77d48fd
util.prosodyctl.check: Fix for net.dns vs unbound API difference
Kim Alvefur <zash@zash.se>
parents:
11612
diff
changeset
|
689 if res and #res > 0 then |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
690 for _, record in ipairs(res) do |
10932
ea4a7619058f
util.prosodyctl.check: Fix traceback by handling SRV '.' target to
Kim Alvefur <zash@zash.se>
parents:
10871
diff
changeset
|
691 if record.srv.target == "." then -- TODO is this an error if mod_c2s is enabled? |
ea4a7619058f
util.prosodyctl.check: Fix traceback by handling SRV '.' target to
Kim Alvefur <zash@zash.se>
parents:
10871
diff
changeset
|
692 print(" 'xmpp-client' service disabled by pointing to '.'"); -- FIXME Explain better what this is |
ea4a7619058f
util.prosodyctl.check: Fix traceback by handling SRV '.' target to
Kim Alvefur <zash@zash.se>
parents:
10871
diff
changeset
|
693 break; |
ea4a7619058f
util.prosodyctl.check: Fix traceback by handling SRV '.' target to
Kim Alvefur <zash@zash.se>
parents:
10871
diff
changeset
|
694 end |
11655
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
695 local target = trim_dns_name(record.srv.target); |
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
696 target_hosts:add(target); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
697 if not c2s_ports:contains(record.srv.port) then |
11655
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
698 print(" SRV target "..target.." contains unknown client port: "..record.srv.port); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
699 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
700 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
701 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
702 if c2s_srv_required then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
703 print(" No _xmpp-client SRV record found for "..host..", but it looks like you need one."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
704 all_targets_ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
705 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
706 target_hosts:add(host); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
707 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
708 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
709 end |
11615
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
710 if modules:contains("c2s") and c2s_tls_srv_required then |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
711 local res = dns.lookup("_xmpps-client._tcp."..idna.to_ascii(host)..".", "SRV"); |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
712 if res and #res > 0 then |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
713 for _, record in ipairs(res) do |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
714 if record.srv.target == "." then -- TODO is this an error if mod_c2s is enabled? |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
715 print(" 'xmpps-client' service disabled by pointing to '.'"); -- FIXME Explain better what this is |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
716 break; |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
717 end |
11655
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
718 local target = trim_dns_name(record.srv.target); |
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
719 target_hosts:add(target); |
11615
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
720 if not c2s_tls_ports:contains(record.srv.port) then |
11655
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
721 print(" SRV target "..target.." contains unknown Direct TLS client port: "..record.srv.port); |
11615
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
722 end |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
723 end |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
724 else |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
725 print(" No _xmpps-client SRV record found for "..host..", but it looks like you need one."); |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
726 all_targets_ok = false; |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
727 end |
8e16fd976c57
util.prosodyctl.check: Add support for checking Direct TLS SRV records
Kim Alvefur <zash@zash.se>
parents:
11613
diff
changeset
|
728 end |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
729 if modules:contains("s2s") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
730 local res = dns.lookup("_xmpp-server._tcp."..idna.to_ascii(host)..".", "SRV"); |
11613
c8a9f77d48fd
util.prosodyctl.check: Fix for net.dns vs unbound API difference
Kim Alvefur <zash@zash.se>
parents:
11612
diff
changeset
|
731 if res and #res > 0 then |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
732 for _, record in ipairs(res) do |
10932
ea4a7619058f
util.prosodyctl.check: Fix traceback by handling SRV '.' target to
Kim Alvefur <zash@zash.se>
parents:
10871
diff
changeset
|
733 if record.srv.target == "." then -- TODO Is this an error if mod_s2s is enabled? |
ea4a7619058f
util.prosodyctl.check: Fix traceback by handling SRV '.' target to
Kim Alvefur <zash@zash.se>
parents:
10871
diff
changeset
|
734 print(" 'xmpp-server' service disabled by pointing to '.'"); -- FIXME Explain better what this is |
ea4a7619058f
util.prosodyctl.check: Fix traceback by handling SRV '.' target to
Kim Alvefur <zash@zash.se>
parents:
10871
diff
changeset
|
735 break; |
ea4a7619058f
util.prosodyctl.check: Fix traceback by handling SRV '.' target to
Kim Alvefur <zash@zash.se>
parents:
10871
diff
changeset
|
736 end |
11655
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
737 local target = trim_dns_name(record.srv.target); |
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
738 target_hosts:add(target); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
739 if not s2s_ports:contains(record.srv.port) then |
11655
bbf50525faa5
util.prosodyctl.check: Normalize away trailing dot in some messages too
Kim Alvefur <zash@zash.se>
parents:
11654
diff
changeset
|
740 print(" SRV target "..target.." contains unknown server port: "..record.srv.port); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
741 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
742 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
743 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
744 if s2s_srv_required then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
745 print(" No _xmpp-server SRV record found for "..host..", but it looks like you need one."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
746 all_targets_ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
747 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
748 target_hosts:add(host); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
749 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
750 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
751 end |
11776
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
752 if modules:contains("s2s") and s2s_tls_srv_required then |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
753 local res = dns.lookup("_xmpps-server._tcp."..idna.to_ascii(host)..".", "SRV"); |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
754 if res and #res > 0 then |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
755 for _, record in ipairs(res) do |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
756 if record.srv.target == "." then -- TODO is this an error if mod_s2s is enabled? |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
757 print(" 'xmpps-server' service disabled by pointing to '.'"); -- FIXME Explain better what this is |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
758 break; |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
759 end |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
760 local target = trim_dns_name(record.srv.target); |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
761 target_hosts:add(target); |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
762 if not s2s_tls_ports:contains(record.srv.port) then |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
763 print(" SRV target "..target.." contains unknown Direct TLS server port: "..record.srv.port); |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
764 end |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
765 end |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
766 else |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
767 print(" No _xmpps-server SRV record found for "..host..", but it looks like you need one."); |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
768 all_targets_ok = false; |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
769 end |
1132a1f1ca5a
util.prosodyctl.check: Check for server-to-server Direct TLS records
Kim Alvefur <zash@zash.se>
parents:
11655
diff
changeset
|
770 end |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
771 if target_hosts:empty() then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
772 target_hosts:add(host); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
773 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
774 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
775 if target_hosts:contains("localhost") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
776 print(" Target 'localhost' cannot be accessed from other servers"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
777 target_hosts:remove("localhost"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
778 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
779 |
12217
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
780 local function check_address(target) |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
781 local A, AAAA = dns.lookup(idna.to_ascii(target), "A"), dns.lookup(idna.to_ascii(target), "AAAA"); |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
782 local prob = {}; |
12231
ca8453129ade
util.prosodyctl.check: Fix A/AAAA check for proxy65 and http
Kim Alvefur <zash@zash.se>
parents:
12230
diff
changeset
|
783 if use_ipv4 and not (A and #A > 0) then table.insert(prob, "A"); end |
ca8453129ade
util.prosodyctl.check: Fix A/AAAA check for proxy65 and http
Kim Alvefur <zash@zash.se>
parents:
12230
diff
changeset
|
784 if use_ipv6 and not (AAAA and #AAAA > 0) then table.insert(prob, "AAAA"); end |
12217
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
785 return prob; |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
786 end |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
787 |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
788 if modules:contains("proxy65") then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
789 local proxy65_target = configmanager.get(host, "proxy65_address") or host; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
790 if type(proxy65_target) == "string" then |
12217
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
791 local prob = check_address(proxy65_target); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
792 if #prob > 0 then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
793 print(" File transfer proxy "..proxy65_target.." has no "..table.concat(prob, "/") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
794 .." record. Create one or set 'proxy65_address' to the correct host/IP."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
795 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
796 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
797 print(" proxy65_address for "..host.." should be set to a string, unable to perform DNS check"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
798 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
799 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
800 |
12217
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
801 local known_http_modules = set.new { "bosh"; "http_files"; "http_file_share"; "http_openmetrics"; "websocket" }; |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
802 local function contains_match(hayset, needle) |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
803 for member in hayset do if member:find(needle) then return true end end |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
804 end |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
805 |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
806 if modules:contains("http") or not set.intersection(modules, known_http_modules):empty() |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
807 or contains_match(modules, "^http_") or contains_match(modules, "_web$") then |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
808 |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
809 local http_host = configmanager.get(host, "http_host") or host; |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
810 local http_internal_host = http_host; |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
811 local http_url = configmanager.get(host, "http_external_url"); |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
812 if http_url then |
12218
0795e1ccf3d8
util.prosodyctl.check: Fix use of LuaSocket URL parser
Kim Alvefur <zash@zash.se>
parents:
12217
diff
changeset
|
813 local url_parse = require "socket.url".parse; |
12217
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
814 local external_url_parts = url_parse(http_url); |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
815 if external_url_parts then |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
816 http_host = external_url_parts.host; |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
817 else |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
818 print(" The 'http_external_url' setting is not a valid URL"); |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
819 end |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
820 end |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
821 |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
822 local prob = check_address(http_host); |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
823 if #prob > 1 then |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
824 print(" HTTP service " .. http_host .. " has no " .. table.concat(prob, "/") .. " record. Create one or change " |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
825 .. (http_url and "'http_external_url'" or "'http_host'").." to the correct host."); |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
826 end |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
827 |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
828 if http_host ~= http_internal_host then |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
829 print(" Ensure the reverse proxy sets the HTTP Host header to '" .. http_internal_host .. "'"); |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
830 end |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
831 end |
39043233de04
util.prosodyctl.check: Add HTTP related DNS checks
Kim Alvefur <zash@zash.se>
parents:
12159
diff
changeset
|
832 |
11652
887d7b15e21b
util.prosodyctl.check: Warn if both use_ipv4 and use_ipv6 are set to false
Kim Alvefur <zash@zash.se>
parents:
11651
diff
changeset
|
833 if not use_ipv4 and not use_ipv6 then |
887d7b15e21b
util.prosodyctl.check: Warn if both use_ipv4 and use_ipv6 are set to false
Kim Alvefur <zash@zash.se>
parents:
11651
diff
changeset
|
834 print(" Both IPv6 and IPv4 are disabled, Prosody will not listen on any ports"); |
887d7b15e21b
util.prosodyctl.check: Warn if both use_ipv4 and use_ipv6 are set to false
Kim Alvefur <zash@zash.se>
parents:
11651
diff
changeset
|
835 print(" nor be able to connect to any remote servers."); |
887d7b15e21b
util.prosodyctl.check: Warn if both use_ipv4 and use_ipv6 are set to false
Kim Alvefur <zash@zash.se>
parents:
11651
diff
changeset
|
836 all_targets_ok = false; |
887d7b15e21b
util.prosodyctl.check: Warn if both use_ipv4 and use_ipv6 are set to false
Kim Alvefur <zash@zash.se>
parents:
11651
diff
changeset
|
837 end |
887d7b15e21b
util.prosodyctl.check: Warn if both use_ipv4 and use_ipv6 are set to false
Kim Alvefur <zash@zash.se>
parents:
11651
diff
changeset
|
838 |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
839 for target_host in target_hosts do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
840 local host_ok_v4, host_ok_v6; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
841 do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
842 local res = dns.lookup(idna.to_ascii(target_host), "A"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
843 if res then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
844 for _, record in ipairs(res) do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
845 if external_addresses:contains(record.a) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
846 some_targets_ok = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
847 host_ok_v4 = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
848 elseif internal_addresses:contains(record.a) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
849 host_ok_v4 = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
850 some_targets_ok = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
851 print(" "..target_host.." A record points to internal address, external connections might fail"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
852 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
853 print(" "..target_host.." A record points to unknown address "..record.a); |
12319
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
854 unknown_addresses:add(record.a); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
855 all_targets_ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
856 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
857 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
858 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
859 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
860 do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
861 local res = dns.lookup(idna.to_ascii(target_host), "AAAA"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
862 if res then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
863 for _, record in ipairs(res) do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
864 if external_addresses:contains(record.aaaa) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
865 some_targets_ok = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
866 host_ok_v6 = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
867 elseif internal_addresses:contains(record.aaaa) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
868 host_ok_v6 = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
869 some_targets_ok = true; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
870 print(" "..target_host.." AAAA record points to internal address, external connections might fail"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
871 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
872 print(" "..target_host.." AAAA record points to unknown address "..record.aaaa); |
12319
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
873 unknown_addresses:add(record.aaaa); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
874 all_targets_ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
875 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
876 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
877 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
878 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
879 |
11653
51141309ffc4
util.prosodyctl.check: Point out if A/AAAA exists despite disabled IPvX
Kim Alvefur <zash@zash.se>
parents:
11652
diff
changeset
|
880 if host_ok_v4 and not use_ipv4 then |
51141309ffc4
util.prosodyctl.check: Point out if A/AAAA exists despite disabled IPvX
Kim Alvefur <zash@zash.se>
parents:
11652
diff
changeset
|
881 print(" Host "..target_host.." does seem to resolve to this server but IPv4 has been disabled"); |
51141309ffc4
util.prosodyctl.check: Point out if A/AAAA exists despite disabled IPvX
Kim Alvefur <zash@zash.se>
parents:
11652
diff
changeset
|
882 all_targets_ok = false; |
51141309ffc4
util.prosodyctl.check: Point out if A/AAAA exists despite disabled IPvX
Kim Alvefur <zash@zash.se>
parents:
11652
diff
changeset
|
883 end |
51141309ffc4
util.prosodyctl.check: Point out if A/AAAA exists despite disabled IPvX
Kim Alvefur <zash@zash.se>
parents:
11652
diff
changeset
|
884 |
51141309ffc4
util.prosodyctl.check: Point out if A/AAAA exists despite disabled IPvX
Kim Alvefur <zash@zash.se>
parents:
11652
diff
changeset
|
885 if host_ok_v6 and not use_ipv6 then |
51141309ffc4
util.prosodyctl.check: Point out if A/AAAA exists despite disabled IPvX
Kim Alvefur <zash@zash.se>
parents:
11652
diff
changeset
|
886 print(" Host "..target_host.." does seem to resolve to this server but IPv6 has been disabled"); |
51141309ffc4
util.prosodyctl.check: Point out if A/AAAA exists despite disabled IPvX
Kim Alvefur <zash@zash.se>
parents:
11652
diff
changeset
|
887 all_targets_ok = false; |
51141309ffc4
util.prosodyctl.check: Point out if A/AAAA exists despite disabled IPvX
Kim Alvefur <zash@zash.se>
parents:
11652
diff
changeset
|
888 end |
51141309ffc4
util.prosodyctl.check: Point out if A/AAAA exists despite disabled IPvX
Kim Alvefur <zash@zash.se>
parents:
11652
diff
changeset
|
889 |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
890 local bad_protos = {} |
11651
c9f46d28ed7e
util.prosodyctl.check: Silence IP protocol mismatches when disabled
Kim Alvefur <zash@zash.se>
parents:
11645
diff
changeset
|
891 if use_ipv4 and not host_ok_v4 then |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
892 table.insert(bad_protos, "IPv4"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
893 end |
11651
c9f46d28ed7e
util.prosodyctl.check: Silence IP protocol mismatches when disabled
Kim Alvefur <zash@zash.se>
parents:
11645
diff
changeset
|
894 if use_ipv6 and not host_ok_v6 then |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
895 table.insert(bad_protos, "IPv6"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
896 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
897 if #bad_protos > 0 then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
898 print(" Host "..target_host.." does not seem to resolve to this server ("..table.concat(bad_protos, "/")..")"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
899 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
900 if host_ok_v6 and not v6_supported then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
901 print(" Host "..target_host.." has AAAA records, but your version of LuaSocket does not support IPv6."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
902 print(" Please see https://prosody.im/doc/ipv6 for more information."); |
11925
3e0d03a74285
util.prosodyctl.check: Highlight inconsistency of AAAA records and use_ipv6=false
Kim Alvefur <zash@zash.se>
parents:
11924
diff
changeset
|
903 elseif host_ok_v6 and not use_ipv6 then |
3e0d03a74285
util.prosodyctl.check: Highlight inconsistency of AAAA records and use_ipv6=false
Kim Alvefur <zash@zash.se>
parents:
11924
diff
changeset
|
904 print(" Host "..target_host.." has AAAA records, but IPv6 is disabled."); |
3e0d03a74285
util.prosodyctl.check: Highlight inconsistency of AAAA records and use_ipv6=false
Kim Alvefur <zash@zash.se>
parents:
11924
diff
changeset
|
905 -- TODO Tell them to drop the AAAA records or enable IPv6? |
3e0d03a74285
util.prosodyctl.check: Highlight inconsistency of AAAA records and use_ipv6=false
Kim Alvefur <zash@zash.se>
parents:
11924
diff
changeset
|
906 print(" Please see https://prosody.im/doc/ipv6 for more information."); |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
907 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
908 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
909 if not all_targets_ok then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
910 print(" "..(some_targets_ok and "Only some" or "No").." targets for "..host.." appear to resolve to this server."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
911 if is_component then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
912 print(" DNS records are necessary if you want users on other servers to access this component."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
913 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
914 problem_hosts:add(host); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
915 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
916 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
917 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
918 if not problem_hosts:empty() then |
12319
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
919 if not unknown_addresses:empty() then |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
920 print(""); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
921 print("Some of your DNS records point to unknown IP addresses. This may be expected if your server"); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
922 print("is behind a NAT or proxy. The unrecognized addresses were:"); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
923 print(""); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
924 print(" Unrecognized: "..tostring(unknown_addresses)); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
925 print(""); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
926 print("The addresses we found on this system are:"); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
927 print(""); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
928 print(" Internal: "..tostring(internal_addresses)); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
929 print(" External: "..tostring(external_addresses)); |
8fc3c06f922d
prosodyctl: check dns: List discovered addresses for diagnostic purposes
Matthew Wild <mwild1@gmail.com>
parents:
12318
diff
changeset
|
930 end |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
931 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
932 print("For more information about DNS configuration please see https://prosody.im/doc/dns"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
933 print(""); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
934 ok = false; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
935 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
936 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
937 if not what or what == "certs" then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
938 local cert_ok; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
939 print"Checking certificates..." |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
940 local x509_verify_identity = require"util.x509".verify_identity; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
941 local create_context = require "core.certmanager".create_context; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
942 local ssl = dependencies.softreq"ssl"; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
943 -- local datetime_parse = require"util.datetime".parse_x509; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
944 local load_cert = ssl and ssl.loadcertificate; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
945 -- or ssl.cert_from_pem |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
946 if not ssl then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
947 print("LuaSec not available, can't perform certificate checks") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
948 if what == "certs" then cert_ok = false end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
949 elseif not load_cert then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
950 print("This version of LuaSec (" .. ssl._VERSION .. ") does not support certificate checking"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
951 cert_ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
952 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
953 for host in it.filter(skip_bare_jid_hosts, enabled_hosts()) do |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
954 print("Checking certificate for "..host); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
955 -- First, let's find out what certificate this host uses. |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
956 local host_ssl_config = configmanager.rawget(host, "ssl") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
957 or configmanager.rawget(host:match("%.(.*)"), "ssl"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
958 local global_ssl_config = configmanager.rawget("*", "ssl"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
959 local ok, err, ssl_config = create_context(host, "server", host_ssl_config, global_ssl_config); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
960 if not ok then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
961 print(" Error: "..err); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
962 cert_ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
963 elseif not ssl_config.certificate then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
964 print(" No 'certificate' found for "..host) |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
965 cert_ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
966 elseif not ssl_config.key then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
967 print(" No 'key' found for "..host) |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
968 cert_ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
969 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
970 local key, err = io.open(ssl_config.key); -- Permissions check only |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
971 if not key then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
972 print(" Could not open "..ssl_config.key..": "..err); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
973 cert_ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
974 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
975 key:close(); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
976 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
977 local cert_fh, err = io.open(ssl_config.certificate); -- Load the file. |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
978 if not cert_fh then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
979 print(" Could not open "..ssl_config.certificate..": "..err); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
980 cert_ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
981 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
982 print(" Certificate: "..ssl_config.certificate) |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
983 local cert = load_cert(cert_fh:read"*a"); cert_fh:close(); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
984 if not cert:validat(os.time()) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
985 print(" Certificate has expired.") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
986 cert_ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
987 elseif not cert:validat(os.time() + 86400) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
988 print(" Certificate expires within one day.") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
989 cert_ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
990 elseif not cert:validat(os.time() + 86400*7) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
991 print(" Certificate expires within one week.") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
992 elseif not cert:validat(os.time() + 86400*31) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
993 print(" Certificate expires within one month.") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
994 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
995 if configmanager.get(host, "component_module") == nil |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
996 and not x509_verify_identity(host, "_xmpp-client", cert) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
997 print(" Not valid for client connections to "..host..".") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
998 cert_ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
999 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1000 if (not (configmanager.get(host, "anonymous_login") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1001 or configmanager.get(host, "authentication") == "anonymous")) |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1002 and not x509_verify_identity(host, "_xmpp-server", cert) then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1003 print(" Not valid for server-to-server connections to "..host..".") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1004 cert_ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1005 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1006 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1007 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1008 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1009 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1010 if cert_ok == false then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1011 print("") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1012 print("For more information about certificates please see https://prosody.im/doc/certificates"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1013 ok = false |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1014 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1015 print("") |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1016 end |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1017 -- intentionally not doing this by default |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1018 if what == "connectivity" then |
11782
d93107de52dd
util.prosodyctl.check: Ignore unused "ok" variable [luacheck]
Kim Alvefur <zash@zash.se>
parents:
11780
diff
changeset
|
1019 local _, prosody_is_running = is_prosody_running(); |
11780
98ae95235775
util.prosodyctl.check: Refuse to do ojn test unless prosody is running
Kim Alvefur <zash@zash.se>
parents:
11779
diff
changeset
|
1020 if configmanager.get("*", "pidfile") and not prosody_is_running then |
98ae95235775
util.prosodyctl.check: Refuse to do ojn test unless prosody is running
Kim Alvefur <zash@zash.se>
parents:
11779
diff
changeset
|
1021 print("Prosody does not appear to be running, which is required for this test."); |
98ae95235775
util.prosodyctl.check: Refuse to do ojn test unless prosody is running
Kim Alvefur <zash@zash.se>
parents:
11779
diff
changeset
|
1022 print("Start it and then try again."); |
98ae95235775
util.prosodyctl.check: Refuse to do ojn test unless prosody is running
Kim Alvefur <zash@zash.se>
parents:
11779
diff
changeset
|
1023 return 1; |
98ae95235775
util.prosodyctl.check: Refuse to do ojn test unless prosody is running
Kim Alvefur <zash@zash.se>
parents:
11779
diff
changeset
|
1024 end |
98ae95235775
util.prosodyctl.check: Refuse to do ojn test unless prosody is running
Kim Alvefur <zash@zash.se>
parents:
11779
diff
changeset
|
1025 |
11827
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1026 local checker = "observe.jabber.network"; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1027 local probe_instance; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1028 local probe_modules = { |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1029 ["xmpp-client"] = "c2s_normal_auth"; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1030 ["xmpp-server"] = "s2s_normal"; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1031 ["xmpps-client"] = nil; -- TODO |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1032 ["xmpps-server"] = nil; -- TODO |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1033 }; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1034 local probe_settings = configmanager.get("*", "connectivity_probe"); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1035 if type(probe_settings) == "string" then |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1036 probe_instance = probe_settings; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1037 elseif type(probe_settings) == "table" and type(probe_settings.url) == "string" then |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1038 probe_instance = probe_settings.url; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1039 if type(probe_settings.modules) == "table" then |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1040 probe_modules = probe_settings.modules; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1041 end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1042 elseif probe_settings ~= nil then |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1043 print("The 'connectivity_probe' setting not understood."); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1044 print("Expected an URL or a table with 'url' and 'modules' fields"); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1045 print("See https://prosody.im/doc/prosodyctl#check for more information."); -- FIXME |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1046 return 1; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1047 end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1048 |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1049 local check_api; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1050 if probe_instance then |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1051 local parsed_url = socket_url.parse(probe_instance); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1052 if not parsed_url then |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1053 print(("'connectivity_probe' is not a valid URL: %q"):format(probe_instance)); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1054 print("Set it to the URL of an XMPP Blackbox Exporter instance and try again"); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1055 return 1; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1056 end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1057 checker = parsed_url.host; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1058 |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1059 function check_api(protocol, host) |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1060 local target = socket_url.build({scheme="xmpp",path=host}); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1061 local probe_module = probe_modules[protocol]; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1062 if not probe_module then |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1063 return nil, "Checking protocol '"..protocol.."' is currently unsupported"; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1064 end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1065 return check_probe(probe_instance, probe_module, target); |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1066 end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1067 else |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1068 check_api = check_ojn; |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1069 end |
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1070 |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1071 for host in it.filter(skip_bare_jid_hosts, enabled_hosts()) do |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1072 local modules, component_module = modulemanager.get_modules_for_host(host); |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1073 if component_module then |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1074 modules:add(component_module) |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1075 end |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1076 |
11827
2359519260ec
prosodyctl: Add alternate XMPP Blackbox Exporter connectivity check
Kim Alvefur <zash@zash.se>
parents:
11826
diff
changeset
|
1077 print("Checking external connectivity for "..host.." via "..checker) |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1078 local function check_connectivity(protocol) |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1079 local success, err = check_api(protocol, host); |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1080 if not success and err ~= nil then |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1081 print((" %s: Failed to request check at API: %s"):format(protocol, err)) |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1082 elseif success then |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1083 print((" %s: Works"):format(protocol)) |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1084 else |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1085 print((" %s: Check service failed to establish (secure) connection"):format(protocol)) |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1086 ok = false |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1087 end |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1088 end |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1089 |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1090 if modules:contains("c2s") then |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1091 check_connectivity("xmpp-client") |
11957
3a7ce7df7806
util.prosodyctl.check: Support direct TLS connectivity checks
Kim Alvefur <zash@zash.se>
parents:
11940
diff
changeset
|
1092 if configmanager.get("*", "c2s_direct_tls_ports") then |
3a7ce7df7806
util.prosodyctl.check: Support direct TLS connectivity checks
Kim Alvefur <zash@zash.se>
parents:
11940
diff
changeset
|
1093 check_connectivity("xmpps-client"); |
3a7ce7df7806
util.prosodyctl.check: Support direct TLS connectivity checks
Kim Alvefur <zash@zash.se>
parents:
11940
diff
changeset
|
1094 end |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1095 end |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1096 |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1097 if modules:contains("s2s") then |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1098 check_connectivity("xmpp-server") |
11957
3a7ce7df7806
util.prosodyctl.check: Support direct TLS connectivity checks
Kim Alvefur <zash@zash.se>
parents:
11940
diff
changeset
|
1099 if configmanager.get("*", "s2s_direct_tls_ports") then |
3a7ce7df7806
util.prosodyctl.check: Support direct TLS connectivity checks
Kim Alvefur <zash@zash.se>
parents:
11940
diff
changeset
|
1100 check_connectivity("xmpps-server"); |
3a7ce7df7806
util.prosodyctl.check: Support direct TLS connectivity checks
Kim Alvefur <zash@zash.se>
parents:
11940
diff
changeset
|
1101 end |
11779
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1102 end |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1103 |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1104 print() |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1105 end |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1106 print("Note: The connectivity check only checks the reachability of the domain.") |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1107 print("Note: It does not ensure that the check actually reaches this specific prosody instance.") |
f4f0bdaeabd2
prosodyctl: Add external connectivity check based on observe.jabber.network
Jonas Schäfer <jonas@wielicki.name>
parents:
11778
diff
changeset
|
1108 end |
12357
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1109 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1110 if what == "turn" then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1111 local turn_enabled_hosts = {}; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1112 local turn_services = {}; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1113 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1114 for host in enabled_hosts() do |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1115 local has_external_turn = modulemanager.get_modules_for_host(host):contains("turn_external"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1116 if has_external_turn then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1117 table.insert(turn_enabled_hosts, host); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1118 local turn_host = configmanager.get(host, "turn_external_host") or host; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1119 local turn_port = configmanager.get(host, "turn_external_port") or 3478; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1120 local turn_secret = configmanager.get(host, "turn_external_secret"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1121 if not turn_secret then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1122 print("Error: Your configuration is missing a turn_external_secret for "..host); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1123 print("Error: TURN will not be advertised for this host."); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1124 ok = false; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1125 else |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1126 local turn_id = ("%s:%d"):format(turn_host, turn_port); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1127 if turn_services[turn_id] and turn_services[turn_id].secret ~= turn_secret then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1128 print("Error: Your configuration contains multiple differing secrets"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1129 print(" for the TURN service at "..turn_id.." - we will only test one."); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1130 elseif not turn_services[turn_id] then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1131 turn_services[turn_id] = { |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1132 host = turn_host; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1133 port = turn_port; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1134 secret = turn_secret; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1135 }; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1136 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1137 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1138 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1139 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1140 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1141 if what == "turn" then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1142 local count = it.count(pairs(turn_services)); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1143 if count == 0 then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1144 print("Error: Unable to find any TURN services configured. Enable mod_turn_external!"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1145 else |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1146 print("Identified "..tostring(count).." TURN services."); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1147 print(""); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1148 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1149 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1150 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1151 for turn_id, turn_service in pairs(turn_services) do |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1152 print("Testing "..turn_id.."..."); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1153 |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1154 local result = check_turn_service(turn_service); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1155 if #result.warnings > 0 then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1156 print(("%d warnings:\n\n "):format(#result.warnings)); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1157 print(table.concat(result.warnings, "\n ")); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1158 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1159 if result.error then |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1160 print("Error: "..result.error.."\n"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1161 ok = false; |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1162 else |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1163 print("Success!\n"); |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1164 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1165 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1166 end |
cd11d7c4af8b
util.prosodyctl: check turn: New command to verify STUN/TURN service is operational
Matthew Wild <mwild1@gmail.com>
parents:
12233
diff
changeset
|
1167 |
10871
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1168 if not ok then |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1169 print("Problems found, see above."); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1170 else |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1171 print("All checks passed, congratulations!"); |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1172 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1173 return ok and 0 or 2; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1174 end |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1175 |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1176 return { |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1177 check = check; |
e5dee71d0ebb
prosodyctl+util.prosodyctl.*: Start breaking up the ever-growing prosodyctl
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1178 }; |