6 require "lxp" |
6 require "lxp" |
7 |
7 |
8 function log(type, area, message) |
8 function log(type, area, message) |
9 print(type, area, message); |
9 print(type, area, message); |
10 end |
10 end |
11 |
11 |
12 require "core.stanza_dispatch" |
12 require "core.stanza_dispatch" |
13 local init_xmlhandlers = require "core.xmlhandlers" |
13 local init_xmlhandlers = require "core.xmlhandlers" |
14 require "core.rostermanager" |
14 require "core.rostermanager" |
15 require "core.offlinemessage" |
15 require "core.offlinemessage" |
16 require "core.usermanager" |
16 require "core.usermanager" |
17 require "util.stanza" |
17 require "util.stanza" |
18 require "util.jid" |
18 require "util.jid" |
19 |
19 |
20 -- Locals for faster access -- |
20 -- Locals for faster access -- |
21 local t_insert = table.insert; |
21 local t_insert = table.insert; |
22 local t_concat = table.concat; |
22 local t_concat = table.concat; |
23 local t_concatall = function (t, sep) local tt = {}; for _, s in ipairs(t) do t_insert(tt, tostring(s)); end return t_concat(tt, sep); end |
23 local t_concatall = function (t, sep) local tt = {}; for _, s in ipairs(t) do t_insert(tt, tostring(s)); end return t_concat(tt, sep); end |
24 local m_random = math.random; |
24 local m_random = math.random; |
46 certificate = "/home/matthew/ssl_cert/server.crt", capath = "/etc/ssl/certs", verify = "none", } |
46 certificate = "/home/matthew/ssl_cert/server.crt", capath = "/etc/ssl/certs", verify = "none", } |
47 |
47 |
48 |
48 |
49 function connect_host(host) |
49 function connect_host(host) |
50 hosts[host] = { type = "remote", sendbuffer = {} }; |
50 hosts[host] = { type = "remote", sendbuffer = {} }; |
|
51 end |
|
52 |
|
53 local function route_stanza(stanza) |
|
54 if not stanza.attr.to then |
|
55 -- Has no 'to' attribute, handle internally |
|
56 end |
|
57 local node, host, resource = jid.split(stanza.attr.to); |
|
58 if host and hosts[host] and hosts[host].type == "local" then |
|
59 -- Is a local host, handle internally |
|
60 |
|
61 else |
|
62 -- Is not for us or a local user, route accordingly |
|
63 end |
51 end |
64 end |
52 |
65 |
53 local function send_to(session, to, stanza) |
66 local function send_to(session, to, stanza) |
54 local node, host, resource = jid.split(to); |
67 local node, host, resource = jid.split(to); |
55 if not hosts[host] then |
68 if not hosts[host] then |