Software /
code /
prosody
Annotate
core/hostmanager.lua @ 3715:d7574530572c
hostmanager: activate() now gets the host config from configmanager when a config isn't given.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 09 Dec 2010 21:11:12 +0500 |
parent | 3601:829e23b374cc |
child | 3716:ebb2c6209e24 |
rev | line source |
---|---|
1522
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1467
diff
changeset
|
1 -- Prosody IM |
2923
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
2877
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
2877
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
1522
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1467
diff
changeset
|
4 -- |
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1467
diff
changeset
|
5 -- This project is MIT/X11 licensed. Please see the |
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1467
diff
changeset
|
6 -- COPYING file in the source package for more information. |
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1467
diff
changeset
|
7 -- |
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1467
diff
changeset
|
8 |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 local configmanager = require "core.configmanager"; |
1975
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
10 local modulemanager = require "core.modulemanager"; |
1188 | 11 local events_new = require "util.events".new; |
3599
adc0b4df6fdd
hostmanager: Added function get_children(host) which copies componentmanager.get_children(host).
Waqas Hussain <waqas20@gmail.com>
parents:
3597
diff
changeset
|
12 local disco_items = require "util.multitable".new(); |
adc0b4df6fdd
hostmanager: Added function get_children(host) which copies componentmanager.get_children(host).
Waqas Hussain <waqas20@gmail.com>
parents:
3597
diff
changeset
|
13 local NULL = {}; |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 |
2420
6ccd36a95a81
s2smanager, hostmanager: Make dialback secrets per-host
Matthew Wild <mwild1@gmail.com>
parents:
2321
diff
changeset
|
15 local uuid_gen = require "util.uuid".generate; |
6ccd36a95a81
s2smanager, hostmanager: Make dialback secrets per-host
Matthew Wild <mwild1@gmail.com>
parents:
2321
diff
changeset
|
16 |
3434
428f13c098d5
hostmanager: Remove dependency on eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
2984
diff
changeset
|
17 local log = require "util.logger".init("hostmanager"); |
428f13c098d5
hostmanager: Remove dependency on eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
2984
diff
changeset
|
18 |
428f13c098d5
hostmanager: Remove dependency on eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
2984
diff
changeset
|
19 local hosts = hosts; |
428f13c098d5
hostmanager: Remove dependency on eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
2984
diff
changeset
|
20 local prosody_events = prosody.events; |
1975
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
21 if not _G.prosody.incoming_s2s then |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
22 require "core.s2smanager"; |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
23 end |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
24 local incoming_s2s = _G.prosody.incoming_s2s; |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
25 |
1893
2d202336c9b6
hostmanager: Create ssl context for each host (fixes #30 for outgoing s2s connections)
Matthew Wild <mwild1@gmail.com>
parents:
1848
diff
changeset
|
26 local pairs, setmetatable = pairs, setmetatable; |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 module "hostmanager" |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 |
1095
cad4205f4925
hostmanager: Reduce log output at startup to 'debug'
Matthew Wild <mwild1@gmail.com>
parents:
749
diff
changeset
|
30 local hosts_loaded_once; |
cad4205f4925
hostmanager: Reduce log output at startup to 'debug'
Matthew Wild <mwild1@gmail.com>
parents:
749
diff
changeset
|
31 |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 local function load_enabled_hosts(config) |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 local defined_hosts = config or configmanager.getconfig(); |
2855
66a1aa0bedc0
hostmanager: Log an error if no hosts are defined
Matthew Wild <mwild1@gmail.com>
parents:
1980
diff
changeset
|
34 local activated_any_host; |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 for host, host_config in pairs(defined_hosts) do |
3597
8090880f0e18
hostmanager, componentmanager: hostmanager now handles component initialization at server start, not componentmanager.
Waqas Hussain <waqas20@gmail.com>
parents:
3594
diff
changeset
|
37 if host ~= "*" and host_config.core.enabled ~= false then |
8090880f0e18
hostmanager, componentmanager: hostmanager now handles component initialization at server start, not componentmanager.
Waqas Hussain <waqas20@gmail.com>
parents:
3594
diff
changeset
|
38 if not host_config.core.component_module then |
8090880f0e18
hostmanager, componentmanager: hostmanager now handles component initialization at server start, not componentmanager.
Waqas Hussain <waqas20@gmail.com>
parents:
3594
diff
changeset
|
39 activated_any_host = true; |
8090880f0e18
hostmanager, componentmanager: hostmanager now handles component initialization at server start, not componentmanager.
Waqas Hussain <waqas20@gmail.com>
parents:
3594
diff
changeset
|
40 end |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 activate(host, host_config); |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 end |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 end |
2855
66a1aa0bedc0
hostmanager: Log an error if no hosts are defined
Matthew Wild <mwild1@gmail.com>
parents:
1980
diff
changeset
|
44 |
66a1aa0bedc0
hostmanager: Log an error if no hosts are defined
Matthew Wild <mwild1@gmail.com>
parents:
1980
diff
changeset
|
45 if not activated_any_host then |
2981
15a7afea7f59
hostmanager: Re-word log messages in line with config changes
Matthew Wild <mwild1@gmail.com>
parents:
2923
diff
changeset
|
46 log("error", "No active VirtualHost entries in the config file. This may cause unexpected behaviour as no modules will be loaded."); |
2855
66a1aa0bedc0
hostmanager: Log an error if no hosts are defined
Matthew Wild <mwild1@gmail.com>
parents:
1980
diff
changeset
|
47 end |
66a1aa0bedc0
hostmanager: Log an error if no hosts are defined
Matthew Wild <mwild1@gmail.com>
parents:
1980
diff
changeset
|
48 |
3434
428f13c098d5
hostmanager: Remove dependency on eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
2984
diff
changeset
|
49 prosody_events.fire_event("hosts-activated", defined_hosts); |
1095
cad4205f4925
hostmanager: Reduce log output at startup to 'debug'
Matthew Wild <mwild1@gmail.com>
parents:
749
diff
changeset
|
50 hosts_loaded_once = true; |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 end |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 |
3434
428f13c098d5
hostmanager: Remove dependency on eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
2984
diff
changeset
|
53 prosody_events.add_handler("server-starting", load_enabled_hosts); |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 function activate(host, host_config) |
3597
8090880f0e18
hostmanager, componentmanager: hostmanager now handles component initialization at server start, not componentmanager.
Waqas Hussain <waqas20@gmail.com>
parents:
3594
diff
changeset
|
56 if hosts[host] then return nil, "host-already-exists"; end |
3715
d7574530572c
hostmanager: activate() now gets the host config from configmanager when a config isn't given.
Waqas Hussain <waqas20@gmail.com>
parents:
3601
diff
changeset
|
57 host_config = host_config or configmanager.getconfig()[host]; |
3594
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
58 local host_session = { |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
59 host = host; |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
60 s2sout = {}; |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
61 events = events_new(); |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
62 dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(); |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
63 disallow_s2s = configmanager.get(host, "core", "disallow_s2s"); |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
64 }; |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
65 if not host_config.core.component_module then -- host |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
66 host_session.type = "local"; |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
67 host_session.sessions = {}; |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
68 if configmanager.get(host, "core", "anonymous_login") then |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
69 host_session.disallow_s2s = (configmanager.get(host, "core", "disallow_s2s") ~= false); |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
70 end |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
71 else -- component |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
72 host_session.type = "component"; |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
73 end |
d3b57562cd87
hostmanager: Added support for components to hostmanager.activate().
Waqas Hussain <waqas20@gmail.com>
parents:
3587
diff
changeset
|
74 hosts[host] = host_session; |
3601
829e23b374cc
hostmanager: Don't include hosts with '@' or '/' in the name in the get_children(host) result.
Waqas Hussain <waqas20@gmail.com>
parents:
3599
diff
changeset
|
75 if not host:match("[@/]") then |
829e23b374cc
hostmanager: Don't include hosts with '@' or '/' in the name in the get_children(host) result.
Waqas Hussain <waqas20@gmail.com>
parents:
3599
diff
changeset
|
76 disco_items:set(host:match("%.(.*)") or "*", host, true); |
829e23b374cc
hostmanager: Don't include hosts with '@' or '/' in the name in the get_children(host) result.
Waqas Hussain <waqas20@gmail.com>
parents:
3599
diff
changeset
|
77 end |
1614
951ed38ad64f
hostmanager: Warn when user puts port configuration under vhost section
Matthew Wild <mwild1@gmail.com>
parents:
1522
diff
changeset
|
78 for option_name in pairs(host_config.core) do |
2981
15a7afea7f59
hostmanager: Re-word log messages in line with config changes
Matthew Wild <mwild1@gmail.com>
parents:
2923
diff
changeset
|
79 if option_name:match("_ports$") or option_name:match("_interface$") then |
15a7afea7f59
hostmanager: Re-word log messages in line with config changes
Matthew Wild <mwild1@gmail.com>
parents:
2923
diff
changeset
|
80 log("warn", "%s: Option '%s' has no effect for virtual hosts - put it in the server-wide section instead", host, option_name); |
1614
951ed38ad64f
hostmanager: Warn when user puts port configuration under vhost section
Matthew Wild <mwild1@gmail.com>
parents:
1522
diff
changeset
|
81 end |
951ed38ad64f
hostmanager: Warn when user puts port configuration under vhost section
Matthew Wild <mwild1@gmail.com>
parents:
1522
diff
changeset
|
82 end |
1893
2d202336c9b6
hostmanager: Create ssl context for each host (fixes #30 for outgoing s2s connections)
Matthew Wild <mwild1@gmail.com>
parents:
1848
diff
changeset
|
83 |
1095
cad4205f4925
hostmanager: Reduce log output at startup to 'debug'
Matthew Wild <mwild1@gmail.com>
parents:
749
diff
changeset
|
84 log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host); |
3434
428f13c098d5
hostmanager: Remove dependency on eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
2984
diff
changeset
|
85 prosody_events.fire_event("host-activated", host, host_config); |
3597
8090880f0e18
hostmanager, componentmanager: hostmanager now handles component initialization at server start, not componentmanager.
Waqas Hussain <waqas20@gmail.com>
parents:
3594
diff
changeset
|
86 return true; |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 end |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 |
1975
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
89 function deactivate(host, reason) |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 local host_session = hosts[host]; |
575
428c951d0a33
Log in hostmanager when a vhost is activated/deactivated
Matthew Wild <mwild1@gmail.com>
parents:
569
diff
changeset
|
91 log("info", "Deactivating host: %s", host); |
3434
428f13c098d5
hostmanager: Remove dependency on eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
2984
diff
changeset
|
92 prosody_events.fire_event("host-deactivating", host, host_session); |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 |
1975
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
94 reason = reason or { condition = "host-gone", text = "This server has stopped serving "..host }; |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
95 |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 -- Disconnect local users, s2s connections |
1975
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
97 if host_session.sessions then |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
98 for username, user in pairs(host_session.sessions) do |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
99 for resource, session in pairs(user.sessions) do |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
100 log("debug", "Closing connection for %s@%s/%s", username, host, resource); |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
101 session:close(reason); |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
102 end |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 end |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 end |
1975
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
105 if host_session.s2sout then |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
106 for remotehost, session in pairs(host_session.s2sout) do |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
107 if session.close then |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
108 log("debug", "Closing outgoing connection to %s", remotehost); |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
109 if session.srv_hosts then session.srv_hosts = nil; end |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
110 session:close(reason); |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
111 end |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
112 end |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
113 end |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
114 for remote_session in pairs(incoming_s2s) do |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
115 if remote_session.to_host == host then |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
116 log("debug", "Closing incoming connection from %s", remote_session.from_host or "<unknown>"); |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
117 remote_session:close(reason); |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
118 end |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
119 end |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
120 |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
121 if host_session.modules then |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
122 for module in pairs(host_session.modules) do |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
123 modulemanager.unload(host, module); |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
124 end |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
125 end |
a9998fac292c
hostmanager: deactivate() now accepts a reason, closes s2s connections as well as disconnecting users, and unloads modules for the host
Matthew Wild <mwild1@gmail.com>
parents:
1974
diff
changeset
|
126 |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 hosts[host] = nil; |
3601
829e23b374cc
hostmanager: Don't include hosts with '@' or '/' in the name in the get_children(host) result.
Waqas Hussain <waqas20@gmail.com>
parents:
3599
diff
changeset
|
128 if not host:match("[@/]") then |
829e23b374cc
hostmanager: Don't include hosts with '@' or '/' in the name in the get_children(host) result.
Waqas Hussain <waqas20@gmail.com>
parents:
3599
diff
changeset
|
129 disco_items:remove(host:match("%.(.*)") or "*", host); |
829e23b374cc
hostmanager: Don't include hosts with '@' or '/' in the name in the get_children(host) result.
Waqas Hussain <waqas20@gmail.com>
parents:
3599
diff
changeset
|
130 end |
3434
428f13c098d5
hostmanager: Remove dependency on eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
2984
diff
changeset
|
131 prosody_events.fire_event("host-deactivated", host); |
575
428c951d0a33
Log in hostmanager when a vhost is activated/deactivated
Matthew Wild <mwild1@gmail.com>
parents:
569
diff
changeset
|
132 log("info", "Deactivated host: %s", host); |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 end |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 |
3599
adc0b4df6fdd
hostmanager: Added function get_children(host) which copies componentmanager.get_children(host).
Waqas Hussain <waqas20@gmail.com>
parents:
3597
diff
changeset
|
135 function get_children(host) |
adc0b4df6fdd
hostmanager: Added function get_children(host) which copies componentmanager.get_children(host).
Waqas Hussain <waqas20@gmail.com>
parents:
3597
diff
changeset
|
136 return disco_items:get(host) or NULL; |
569
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 end |
5216efe6088b
Add hostmanager, and eventmanager
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 |
1974
cfac07d8428e
hostmanager: Add return _M;
Matthew Wild <mwild1@gmail.com>
parents:
1925
diff
changeset
|
139 return _M; |