Mercurial > prosody-hg
comparison core/stanza_router.lua @ 621:cd2cab5400fc
Add support for dialback piggy-backing. Fixes #37. Thanks to CShadowRun for helping me test :)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 13 Dec 2008 17:43:52 +0000 |
| parents | 4ae3e81513f3 |
| children | 6957fe7b0313 |
comparison
equal
deleted
inserted
replaced
| 620:9f9f69d67edb | 621:cd2cab5400fc |
|---|---|
| 70 | 70 |
| 71 -- TODO also, stanzas should be returned to their original state before the function ends | 71 -- TODO also, stanzas should be returned to their original state before the function ends |
| 72 if origin.type == "c2s" then | 72 if origin.type == "c2s" then |
| 73 stanza.attr.from = origin.full_jid; | 73 stanza.attr.from = origin.full_jid; |
| 74 end | 74 end |
| 75 local to = stanza.attr.to; | 75 local to, xmlns = stanza.attr.to, stanza.attr.xmlns; |
| 76 local node, host, resource = jid_split(to); | 76 local node, host, resource = jid_split(to); |
| 77 local to_bare = node and (node.."@"..host) or host; -- bare JID | 77 local to_bare = node and (node.."@"..host) or host; -- bare JID |
| 78 local from = stanza.attr.from; | 78 local from = stanza.attr.from; |
| 79 local from_node, from_host, from_resource = jid_split(from); | 79 local from_node, from_host, from_resource = jid_split(from); |
| 80 local from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID | 80 local from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID |
| 81 | 81 |
| 82 if origin.type == "s2sin" then | |
| 83 if origin.from_host ~= from_host then -- remote server trying to impersonate some other server? | |
| 84 log("warn", "Received a stanza claiming to be from %s, over a conn authed for %s!", from, origin.from_host); | |
| 85 return; -- FIXME what should we do here? does this work with subdomains? | |
| 86 end | |
| 87 end | |
| 88 --[[if to and not(hosts[to]) and not(hosts[to_bare]) and (hosts[host] and hosts[host].type ~= "local") then -- not for us? | 82 --[[if to and not(hosts[to]) and not(hosts[to_bare]) and (hosts[host] and hosts[host].type ~= "local") then -- not for us? |
| 89 log("warn", "stanza recieved for a non-local server"); | 83 log("warn", "stanza recieved for a non-local server"); |
| 90 return; -- FIXME what should we do here? | 84 return; -- FIXME what should we do here? |
| 91 end]] -- FIXME | 85 end]] -- FIXME |
| 92 | 86 |
| 93 -- FIXME do stanzas not of jabber:client get handled by components? | 87 -- FIXME do stanzas not of jabber:client get handled by components? |
| 94 if origin.type == "s2sin" or origin.type == "c2s" then | 88 if (origin.type == "s2sin" or origin.type == "c2s") and (not xmlns or xmlns == "jabber:server" or xmlns == "jabber:client") then |
| 89 if origin.type == "s2sin" then | |
| 90 local host_status = origin.hosts[from_host]; | |
| 91 if not host_status or not host_status.authed then -- remote server trying to impersonate some other server? | |
| 92 log("warn", "Received a stanza claiming to be from %s, over a conn authed for %s!", from_host, origin.from_host); | |
| 93 return; -- FIXME what should we do here? does this work with subdomains? | |
| 94 end | |
| 95 end | |
| 95 if not to then | 96 if not to then |
| 96 core_handle_stanza(origin, stanza); | 97 core_handle_stanza(origin, stanza); |
| 97 elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server | 98 elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server |
| 98 core_handle_stanza(origin, stanza); | 99 core_handle_stanza(origin, stanza); |
| 99 elseif stanza.attr.xmlns and stanza.attr.xmlns ~= "jabber:client" and stanza.attr.xmlns ~= "jabber:server" then | 100 elseif stanza.attr.xmlns and stanza.attr.xmlns ~= "jabber:client" and stanza.attr.xmlns ~= "jabber:server" then |
