comparison mod_manifesto/mod_manifesto.lua @ 1308:9ddfff2acddc

mod_manifest: Close unencrypted connections when entering manifesto mode
author Florian Zeitz <florob@babelmonkeys.de>
date Mon, 17 Feb 2014 21:07:01 +0100
parents 71dd991c94e7
children 853a382c9bd6
comparison
equal deleted inserted replaced
1307:71dd991c94e7 1308:9ddfff2acddc
5 local st = require "util.stanza"; 5 local st = require "util.stanza";
6 local dm = require "util.datamanager"; 6 local dm = require "util.datamanager";
7 local dataforms_new = require "util.dataforms".new; 7 local dataforms_new = require "util.dataforms".new;
8 local adhoc_initial = require "util.adhoc".new_initial_data_form; 8 local adhoc_initial = require "util.adhoc".new_initial_data_form;
9 local mm_reload = require "modulemanager".reload; 9 local mm_reload = require "modulemanager".reload;
10 local s2s_destroy_session = require "core.s2smanager".destroy_session;
10 local config = require "core.configmanager"; 11 local config = require "core.configmanager";
11 local config_get = config.get; 12 local config_get = config.get;
12 local config_set = config.set; 13 local config_set = config.set;
13 local t_concat = table.concat; 14 local t_concat = table.concat;
14 local adhoc_new = module:require "adhoc".new; 15 local adhoc_new = module:require "adhoc".new;
16 17
17 local hosts = prosody.hosts; 18 local hosts = prosody.hosts;
18 local host = module.host; 19 local host = module.host;
19 local host_session = hosts[host]; 20 local host_session = hosts[host];
20 local incoming_s2s = prosody.incoming_s2s; 21 local incoming_s2s = prosody.incoming_s2s;
22 local s2s_sessions = module:shared"/*/s2s/sessions";
21 23
22 local default_tpl = [[ 24 local default_tpl = [[
23 Hello there. 25 Hello there.
24 26
25 This is a brief system message to let you know about some upcoming changes to the $HOST service. 27 This is a brief system message to let you know about some upcoming changes to the $HOST service.
153 155
154 local info; 156 local info;
155 if fields.state == "enabled" then 157 if fields.state == "enabled" then
156 config_set(host, "c2s_require_encryption", true); 158 config_set(host, "c2s_require_encryption", true);
157 config_set(host, "s2s_require_encryption", true); 159 config_set(host, "s2s_require_encryption", true);
160
161 for _, session in pairs(s2s_sessions) do
162 if not session.secure then
163 (session.close or s2s_destroy_session)(session);
164 end
165 end
166
158 info = "Manifesto mode enabled"; 167 info = "Manifesto mode enabled";
159 else 168 else
160 local ok, err = prosody.reload_config(); 169 local ok, err = prosody.reload_config();
161 if not ok then 170 if not ok then
162 return { status = "completed", error = { message = "Failed to reload config: " .. tostring(err) } }; 171 return { status = "completed", error = { message = "Failed to reload config: " .. tostring(err) } };