Software / code / prosody
Comparison
core/componentmanager.lua @ 2447:9eb539222f22
componentmanager: Add dialback_secret to components to allow s2s to work (thanks Flo)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 11 Jan 2010 10:13:02 +0000 |
| parent | 2323:b7f683c55a44 |
| child | 2629:fe207a2c5cef |
comparison
equal
deleted
inserted
replaced
| 2446:62aa1b465e05 | 2447:9eb539222f22 |
|---|---|
| 14 local fire_event = require "core.eventmanager".fire_event; | 14 local fire_event = require "core.eventmanager".fire_event; |
| 15 local events_new = require "util.events".new; | 15 local events_new = require "util.events".new; |
| 16 local st = require "util.stanza"; | 16 local st = require "util.stanza"; |
| 17 local prosody, hosts = prosody, prosody.hosts; | 17 local prosody, hosts = prosody, prosody.hosts; |
| 18 local ssl = ssl; | 18 local ssl = ssl; |
| 19 local uuid_gen = require "util.uuid".generate; | |
| 19 | 20 |
| 20 local pairs, setmetatable, type, tostring = pairs, setmetatable, type, tostring; | 21 local pairs, setmetatable, type, tostring = pairs, setmetatable, type, tostring; |
| 21 | 22 |
| 22 local components = {}; | 23 local components = {}; |
| 23 | 24 |
| 89 ssl_ctx = ssl.newcontext(prosody.global_ssl_ctx); | 90 ssl_ctx = ssl.newcontext(prosody.global_ssl_ctx); |
| 90 ssl_ctx_in = ssl.newcontext(setmetatable({ mode = "server" }, { __index = prosody.global_ssl_ctx })); | 91 ssl_ctx_in = ssl.newcontext(setmetatable({ mode = "server" }, { __index = prosody.global_ssl_ctx })); |
| 91 end | 92 end |
| 92 end | 93 end |
| 93 return { type = "component", host = host, connected = true, s2sout = {}, | 94 return { type = "component", host = host, connected = true, s2sout = {}, |
| 94 ssl_ctx = ssl_ctx, ssl_ctx_in = ssl_ctx_in, events = events or events_new() }; | 95 ssl_ctx = ssl_ctx, ssl_ctx_in = ssl_ctx_in, events = events or events_new(), |
| 96 dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen() }; | |
| 95 end | 97 end |
| 96 | 98 |
| 97 function register_component(host, component, session) | 99 function register_component(host, component, session) |
| 98 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then | 100 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then |
| 99 local old_events = hosts[host] and hosts[host].events; | 101 local old_events = hosts[host] and hosts[host].events; |
| 100 | 102 |
| 101 components[host] = component; | 103 components[host] = component; |
| 102 hosts[host] = session or create_component(host, component, old_events); | 104 hosts[host] = session or create_component(host, component, old_events); |
| 103 | 105 |
| 104 -- Add events object if not already one | 106 -- Add events object if not already one |
| 105 if not hosts[host].events then | 107 if not hosts[host].events then |
| 106 hosts[host].events = old_events or events_new(); | 108 hosts[host].events = old_events or events_new(); |
| 107 end | 109 end |
| 108 | 110 |
| 111 if not hosts[host].dialback_secret then | |
| 112 hosts[host].dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(); | |
| 113 end | |
| 114 | |
| 109 -- add to disco_items | 115 -- add to disco_items |
| 110 if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then | 116 if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then |
| 111 disco_items:set(host:sub(host:find(".", 1, true)+1), host, true); | 117 disco_items:set(host:sub(host:find(".", 1, true)+1), host, true); |
| 112 end | 118 end |
| 113 modulemanager.load(host, "dialback"); | 119 modulemanager.load(host, "dialback"); |