Software /
code /
prosody
Comparison
core/hostmanager.lua @ 5776:bd0ff8ae98a8
Remove all trailing whitespace
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 09 Aug 2013 17:48:21 +0200 |
parent | 5377:898454038524 |
child | 6299:a1da78658a82 |
comparison
equal
deleted
inserted
replaced
5775:a6c2b8933507 | 5776:bd0ff8ae98a8 |
---|---|
1 -- Prosody IM | 1 -- Prosody IM |
2 -- Copyright (C) 2008-2010 Matthew Wild | 2 -- Copyright (C) 2008-2010 Matthew Wild |
3 -- Copyright (C) 2008-2010 Waqas Hussain | 3 -- Copyright (C) 2008-2010 Waqas Hussain |
4 -- | 4 -- |
5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 local configmanager = require "core.configmanager"; | 9 local configmanager = require "core.configmanager"; |
33 local hosts_loaded_once; | 33 local hosts_loaded_once; |
34 | 34 |
35 local function load_enabled_hosts(config) | 35 local function load_enabled_hosts(config) |
36 local defined_hosts = config or configmanager.getconfig(); | 36 local defined_hosts = config or configmanager.getconfig(); |
37 local activated_any_host; | 37 local activated_any_host; |
38 | 38 |
39 for host, host_config in pairs(defined_hosts) do | 39 for host, host_config in pairs(defined_hosts) do |
40 if host ~= "*" and host_config.enabled ~= false then | 40 if host ~= "*" and host_config.enabled ~= false then |
41 if not host_config.component_module then | 41 if not host_config.component_module then |
42 activated_any_host = true; | 42 activated_any_host = true; |
43 end | 43 end |
44 activate(host, host_config); | 44 activate(host, host_config); |
45 end | 45 end |
46 end | 46 end |
47 | 47 |
48 if not activated_any_host then | 48 if not activated_any_host then |
49 log("error", "No active VirtualHost entries in the config file. This may cause unexpected behaviour as no modules will be loaded."); | 49 log("error", "No active VirtualHost entries in the config file. This may cause unexpected behaviour as no modules will be loaded."); |
50 end | 50 end |
51 | 51 |
52 prosody_events.fire_event("hosts-activated", defined_hosts); | 52 prosody_events.fire_event("hosts-activated", defined_hosts); |
53 hosts_loaded_once = true; | 53 hosts_loaded_once = true; |
54 end | 54 end |
55 | 55 |
56 prosody_events.add_handler("server-starting", load_enabled_hosts); | 56 prosody_events.add_handler("server-starting", load_enabled_hosts); |
91 for option_name in pairs(host_config) do | 91 for option_name in pairs(host_config) do |
92 if option_name:match("_ports$") or option_name:match("_interface$") then | 92 if option_name:match("_ports$") or option_name:match("_interface$") then |
93 log("warn", "%s: Option '%s' has no effect for virtual hosts - put it in the server-wide section instead", host, option_name); | 93 log("warn", "%s: Option '%s' has no effect for virtual hosts - put it in the server-wide section instead", host, option_name); |
94 end | 94 end |
95 end | 95 end |
96 | 96 |
97 log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host); | 97 log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host); |
98 prosody_events.fire_event("host-activated", host); | 98 prosody_events.fire_event("host-activated", host); |
99 return true; | 99 return true; |
100 end | 100 end |
101 | 101 |
102 function deactivate(host, reason) | 102 function deactivate(host, reason) |
103 local host_session = hosts[host]; | 103 local host_session = hosts[host]; |
104 if not host_session then return nil, "The host "..tostring(host).." is not activated"; end | 104 if not host_session then return nil, "The host "..tostring(host).." is not activated"; end |
105 log("info", "Deactivating host: %s", host); | 105 log("info", "Deactivating host: %s", host); |
106 prosody_events.fire_event("host-deactivating", { host = host, host_session = host_session, reason = reason }); | 106 prosody_events.fire_event("host-deactivating", { host = host, host_session = host_session, reason = reason }); |
107 | 107 |
108 if type(reason) ~= "table" then | 108 if type(reason) ~= "table" then |
109 reason = { condition = "host-gone", text = tostring(reason or "This server has stopped serving "..host) }; | 109 reason = { condition = "host-gone", text = tostring(reason or "This server has stopped serving "..host) }; |
110 end | 110 end |
111 | 111 |
112 -- Disconnect local users, s2s connections | 112 -- Disconnect local users, s2s connections |
113 -- TODO: These should move to mod_c2s and mod_s2s (how do they know they're being unloaded and not reloaded?) | 113 -- TODO: These should move to mod_c2s and mod_s2s (how do they know they're being unloaded and not reloaded?) |
114 if host_session.sessions then | 114 if host_session.sessions then |
115 for username, user in pairs(host_session.sessions) do | 115 for username, user in pairs(host_session.sessions) do |
116 for resource, session in pairs(user.sessions) do | 116 for resource, session in pairs(user.sessions) do |