Software /
code /
prosody
Comparison
core/stanza_router.lua @ 1370:3a467e6885f0
stanza_router: Skip prepping 'to' in many common cases - #optimization
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 20 Jun 2009 18:18:38 +0500 |
parent | 1369:633e032a3b4b |
child | 1406:83c6fb3d9e73 |
comparison
equal
deleted
inserted
replaced
1369:633e032a3b4b | 1370:3a467e6885f0 |
---|---|
64 local from = stanza.attr.from; | 64 local from = stanza.attr.from; |
65 local node, host, resource; | 65 local node, host, resource; |
66 local from_node, from_host, from_resource; | 66 local from_node, from_host, from_resource; |
67 local to_bare, from_bare; | 67 local to_bare, from_bare; |
68 if to then | 68 if to then |
69 node, host, resource = jid_prepped_split(to); | 69 if full_sessions[to] or bare_sessions[to] or hosts[to] then |
70 if not host then | 70 node, host = jid_split(to); -- TODO only the host is needed, optimize |
71 log("warn", "Received stanza with invalid destination JID: %s", to); | 71 else |
72 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then | 72 node, host, resource = jid_prepped_split(to); |
73 origin.send(st.error_reply(stanza, "modify", "jid-malformed", "The destination address is invalid: "..to)); | 73 if not host then |
74 end | 74 log("warn", "Received stanza with invalid destination JID: %s", to); |
75 return; | 75 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then |
76 end | 76 origin.send(st.error_reply(stanza, "modify", "jid-malformed", "The destination address is invalid: "..to)); |
77 to_bare = node and (node.."@"..host) or host; -- bare JID | 77 end |
78 if resource then to = to_bare.."/"..resource; else to = to_bare; end | 78 return; |
79 stanza.attr.to = to; | 79 end |
80 to_bare = node and (node.."@"..host) or host; -- bare JID | |
81 if resource then to = to_bare.."/"..resource; else to = to_bare; end | |
82 stanza.attr.to = to; | |
83 end | |
80 end | 84 end |
81 if from and not origin.full_jid then | 85 if from and not origin.full_jid then |
82 -- We only stamp the 'from' on c2s stanzas, so we still need to check validity | 86 -- We only stamp the 'from' on c2s stanzas, so we still need to check validity |
83 from_node, from_host, from_resource = jid_prepped_split(from); | 87 from_node, from_host, from_resource = jid_prepped_split(from); |
84 if not from_host then | 88 if not from_host then |