68 end |
68 end |
69 end |
69 end |
70 |
70 |
71 function create_component(host, component, events) |
71 function create_component(host, component, events) |
72 -- TODO check for host well-formedness |
72 -- TODO check for host well-formedness |
73 return { type = "component", host = host, connected = true, s2sout = {}, events = events or events_new() }; |
73 local ssl_ctx; |
|
74 if host then |
|
75 -- We need to find SSL context to use... |
|
76 -- Discussion in prosody@ concluded that |
|
77 -- 1 level back is usually enough by default |
|
78 local base_host = host:gsub("^[^%.]+", ""); |
|
79 if hosts[base_host] then |
|
80 ssl_ctx = hosts[base_host].ssl_ctx; |
|
81 end |
|
82 end |
|
83 return { type = "component", host = host, connected = true, s2sout = {}, |
|
84 ssl_ctx = ssl_ctx, events = events or events_new() }; |
74 end |
85 end |
75 |
86 |
76 function register_component(host, component, session) |
87 function register_component(host, component, session) |
77 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then |
88 if not hosts[host] or (hosts[host].type == 'component' and not hosts[host].connected) then |
78 local old_events = hosts[host] and hosts[host].events; |
89 local old_events = hosts[host] and hosts[host].events; |