Software / code / prosody
Comparison
main.lua @ 18:ae161e907149
Beginning of new routing logic
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 26 Aug 2008 13:14:43 +0100 |
| parent | 12:90f22275f7ae |
| child | 20:6885fd2cf51f |
comparison
equal
deleted
inserted
replaced
| 14:780bcad913f3 | 18:ae161e907149 |
|---|---|
| 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 |