Software /
code /
prosody
Comparison
core/stanza_router.lua @ 718:aa78dfb26593
Stringprep!
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 15 Jan 2009 04:36:35 +0500 |
parent | 715:beec1eb7d9c6 |
child | 725:96110075288b |
comparison
equal
deleted
inserted
replaced
717:ab428c579cbc | 718:aa78dfb26593 |
---|---|
45 local t_insert = table.insert; | 45 local t_insert = table.insert; |
46 local tonumber = tonumber; | 46 local tonumber = tonumber; |
47 local s_find = string.find; | 47 local s_find = string.find; |
48 | 48 |
49 local jid_split = require "util.jid".split; | 49 local jid_split = require "util.jid".split; |
50 local jid_prepped_split = require "util.jid".prepped_split; | |
50 local print = print; | 51 local print = print; |
51 local function checked_error_reply(origin, stanza) | 52 local function checked_error_reply(origin, stanza) |
52 if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server" or not stanza.attr.xmlns) and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then | 53 if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then |
53 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? | 54 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error? |
54 end | 55 end |
55 end | 56 end |
56 | 57 |
57 function core_process_stanza(origin, stanza) | 58 function core_process_stanza(origin, stanza) |
76 -- TODO also, stanzas should be returned to their original state before the function ends | 77 -- TODO also, stanzas should be returned to their original state before the function ends |
77 if origin.type == "c2s" then | 78 if origin.type == "c2s" then |
78 stanza.attr.from = origin.full_jid; | 79 stanza.attr.from = origin.full_jid; |
79 end | 80 end |
80 local to, xmlns = stanza.attr.to, stanza.attr.xmlns; | 81 local to, xmlns = stanza.attr.to, stanza.attr.xmlns; |
81 local node, host, resource = jid_split(to); | |
82 local to_bare = node and (node.."@"..host) or host; -- bare JID | |
83 local from = stanza.attr.from; | 82 local from = stanza.attr.from; |
84 local from_node, from_host, from_resource = jid_split(from); | 83 local node, host, resource; |
85 local from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID | 84 local from_node, from_host, from_resource; |
85 local to_bare, from_bare; | |
86 if to then | |
87 node, host, resource = jid_prepped_split(to); | |
88 if not host then | |
89 error("Invalid to JID"); | |
90 end | |
91 to_bare = node and (node.."@"..host) or host; -- bare JID | |
92 if resource then to = to_bare.."/"..resource; else to = to_bare; end | |
93 stanza.attr.to = to; | |
94 end | |
95 if from then | |
96 from_node, from_host, from_resource = jid_prepped_split(from); | |
97 if not from_host then | |
98 error("Invalid from JID"); | |
99 end | |
100 from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID | |
101 if from_resource then from = from_bare.."/"..from_resource; else from = from_bare; end | |
102 stanza.attr.from = from; | |
103 end | |
86 | 104 |
87 --[[if to and not(hosts[to]) and not(hosts[to_bare]) and (hosts[host] and hosts[host].type ~= "local") then -- not for us? | 105 --[[if to and not(hosts[to]) and not(hosts[to_bare]) and (hosts[host] and hosts[host].type ~= "local") then -- not for us? |
88 log("warn", "stanza recieved for a non-local server"); | 106 log("warn", "stanza recieved for a non-local server"); |
89 return; -- FIXME what should we do here? | 107 return; -- FIXME what should we do here? |
90 end]] -- FIXME | 108 end]] -- FIXME |