Mercurial > prosody-hg
comparison core/hostmanager.lua @ 4797:e239668aa6d2
Merge 0.9->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 29 Apr 2012 02:10:55 +0100 |
| parents | 1099ff8d9f76 |
| children | 878f75ccc4fb |
comparison
equal
deleted
inserted
replaced
| 4796:04a34287dc12 | 4797:e239668aa6d2 |
|---|---|
| 22 if not _G.prosody.incoming_s2s then | 22 if not _G.prosody.incoming_s2s then |
| 23 require "core.s2smanager"; | 23 require "core.s2smanager"; |
| 24 end | 24 end |
| 25 local incoming_s2s = _G.prosody.incoming_s2s; | 25 local incoming_s2s = _G.prosody.incoming_s2s; |
| 26 | 26 |
| 27 local pairs, setmetatable, select = pairs, setmetatable, select; | 27 local pairs, select = pairs, select; |
| 28 local tostring, type = tostring, type; | 28 local tostring, type = tostring, type; |
| 29 | 29 |
| 30 module "hostmanager" | 30 module "hostmanager" |
| 31 | 31 |
| 32 local hosts_loaded_once; | 32 local hosts_loaded_once; |
| 92 log("warn", "%s: Option '%s' has no effect for virtual hosts - put it in the server-wide section instead", host, option_name); | 92 log("warn", "%s: Option '%s' has no effect for virtual hosts - put it in the server-wide section instead", host, option_name); |
| 93 end | 93 end |
| 94 end | 94 end |
| 95 | 95 |
| 96 log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host); | 96 log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host); |
| 97 prosody_events.fire_event("host-activated", host, host_config); | 97 prosody_events.fire_event("host-activated", host); |
| 98 return true; | 98 return true; |
| 99 end | 99 end |
| 100 | 100 |
| 101 function deactivate(host, reason) | 101 function deactivate(host, reason) |
| 102 local host_session = hosts[host]; | 102 local host_session = hosts[host]; |
| 103 if not host_session then return nil, "The host "..tostring(host).." is not activated"; end | 103 if not host_session then return nil, "The host "..tostring(host).." is not activated"; end |
| 104 log("info", "Deactivating host: %s", host); | 104 log("info", "Deactivating host: %s", host); |
| 105 prosody_events.fire_event("host-deactivating", host, host_session); | 105 prosody_events.fire_event("host-deactivating", { host = host, host_session = host_session, reason = reason }); |
| 106 | 106 |
| 107 if type(reason) ~= "table" then | 107 if type(reason) ~= "table" then |
| 108 reason = { condition = "host-gone", text = tostring(reason or "This server has stopped serving "..host) }; | 108 reason = { condition = "host-gone", text = tostring(reason or "This server has stopped serving "..host) }; |
| 109 end | 109 end |
| 110 | 110 |
| 111 -- Disconnect local users, s2s connections | 111 -- Disconnect local users, s2s connections |
| 112 -- TODO: These should move to mod_c2s and mod_s2s (how do they know they're being unloaded and not reloaded?) | |
| 112 if host_session.sessions then | 113 if host_session.sessions then |
| 113 for username, user in pairs(host_session.sessions) do | 114 for username, user in pairs(host_session.sessions) do |
| 114 for resource, session in pairs(user.sessions) do | 115 for resource, session in pairs(user.sessions) do |
| 115 log("debug", "Closing connection for %s@%s/%s", username, host, resource); | 116 log("debug", "Closing connection for %s@%s/%s", username, host, resource); |
| 116 session:close(reason); | 117 session:close(reason); |
| 131 log("debug", "Closing incoming connection from %s", remote_session.from_host or "<unknown>"); | 132 log("debug", "Closing incoming connection from %s", remote_session.from_host or "<unknown>"); |
| 132 remote_session:close(reason); | 133 remote_session:close(reason); |
| 133 end | 134 end |
| 134 end | 135 end |
| 135 | 136 |
| 137 -- TODO: This should be done in modulemanager | |
| 136 if host_session.modules then | 138 if host_session.modules then |
| 137 for module in pairs(host_session.modules) do | 139 for module in pairs(host_session.modules) do |
| 138 modulemanager.unload(host, module); | 140 modulemanager.unload(host, module); |
| 139 end | 141 end |
| 140 end | 142 end |
