Software /
code /
prosody
Comparison
core/stanza_router.lua @ 2842:298d0ed3f40d
stanza_router: Added third parameter to core_post_stanza, to control pre-events.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 29 Jan 2010 21:04:36 +0500 |
parent | 2833:a82bd02d5918 |
child | 2875:2c538d4bde13 |
comparison
equal
deleted
inserted
replaced
2841:7929882435c0 | 2842:298d0ed3f40d |
---|---|
96 if not host_status or not host_status.authed then -- remote server trying to impersonate some other server? | 96 if not host_status or not host_status.authed then -- remote server trying to impersonate some other server? |
97 log("warn", "Received a stanza claiming to be from %s, over a stream authed for %s!", from_host, origin.from_host); | 97 log("warn", "Received a stanza claiming to be from %s, over a stream authed for %s!", from_host, origin.from_host); |
98 return; -- FIXME what should we do here? does this work with subdomains? | 98 return; -- FIXME what should we do here? does this work with subdomains? |
99 end | 99 end |
100 end | 100 end |
101 core_post_stanza(origin, stanza); | 101 core_post_stanza(origin, stanza, origin.full_jid); |
102 else | 102 else |
103 local h = hosts[stanza.attr.to or origin.host or origin.to_host]; | 103 local h = hosts[stanza.attr.to or origin.host or origin.to_host]; |
104 if h then | 104 if h then |
105 local event; | 105 local event; |
106 if stanza.attr.xmlns == "jabber:client" then | 106 if stanza.attr.xmlns == "jabber:client" then |
117 if host and not hosts[host] then host = nil; end -- COMPAT: workaround for a Pidgin bug which sets 'to' to the SRV result | 117 if host and not hosts[host] then host = nil; end -- COMPAT: workaround for a Pidgin bug which sets 'to' to the SRV result |
118 modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza); | 118 modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza); |
119 end | 119 end |
120 end | 120 end |
121 | 121 |
122 function core_post_stanza(origin, stanza) | 122 function core_post_stanza(origin, stanza, preevents) |
123 local to = stanza.attr.to; | 123 local to = stanza.attr.to; |
124 local node, host, resource = jid_split(to); | 124 local node, host, resource = jid_split(to); |
125 local to_bare = node and (node.."@"..host) or host; -- bare JID | 125 local to_bare = node and (node.."@"..host) or host; -- bare JID |
126 | 126 |
127 local to_type; | 127 local to_type; |
141 to_type = '/bare'; | 141 to_type = '/bare'; |
142 end | 142 end |
143 end | 143 end |
144 | 144 |
145 local event_data = {origin=origin, stanza=stanza}; | 145 local event_data = {origin=origin, stanza=stanza}; |
146 if origin.full_jid == stanza.attr.from then -- c2s connection | 146 if preevents then -- c2s connection |
147 if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing | 147 if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing |
148 end | 148 end |
149 local h = hosts[to_bare] or hosts[host or origin.host]; | 149 local h = hosts[to_bare] or hosts[host or origin.host]; |
150 if h then | 150 if h then |
151 if h.events.fire_event(stanza.name..to_type, event_data) then return; end -- do processing | 151 if h.events.fire_event(stanza.name..to_type, event_data) then return; end -- do processing |