173 core_route_stanza(origin, stanza); |
173 core_route_stanza(origin, stanza); |
174 end |
174 end |
175 end |
175 end |
176 |
176 |
177 function core_route_stanza(origin, stanza) |
177 function core_route_stanza(origin, stanza) |
178 -- Hooks |
|
179 --- ...later |
|
180 |
|
181 -- Deliver |
|
182 local to = stanza.attr.to; |
178 local to = stanza.attr.to; |
183 local node, host, resource = jid_split(to); |
179 local node, host, resource = jid_split(to); |
184 local to_bare = node and (node.."@"..host) or host; -- bare JID |
180 local to_bare = node and (node.."@"..host) or host; -- bare JID |
185 local from = stanza.attr.from; |
181 local from = stanza.attr.from; |
186 local from_node, from_host, from_resource = jid_split(from); |
182 local from_node, from_host, from_resource = jid_split(from); |
188 |
184 |
189 -- Auto-detect origin if not specified |
185 -- Auto-detect origin if not specified |
190 origin = origin or hosts[from_host]; |
186 origin = origin or hosts[from_host]; |
191 if not origin then return false; end |
187 if not origin then return false; end |
192 |
188 |
193 if hosts[to_bare] and hosts[to_bare].type == "component" then -- hack to allow components to handle node@server |
|
194 return component_handle_stanza(origin, stanza); |
|
195 elseif hosts[host] and hosts[host].type == "component" then -- directed at a component |
|
196 return component_handle_stanza(origin, stanza); |
|
197 end |
|
198 |
|
199 if stanza.name == "presence" and (stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error") then resource = nil; end |
|
200 |
|
201 local host_session = hosts[host] |
189 local host_session = hosts[host] |
202 if host_session and host_session.type == "local" then |
190 if host_session and host_session.type == "local" then |
203 -- old stanza routing code removed |
191 -- old stanza routing code removed |
204 core_post_stanza(origin, stanza); |
192 core_post_stanza(origin, stanza); |
205 elseif origin.type == "c2s" then |
193 elseif origin.type == "c2s" then |