log("warn", "Unhandled origin: %s", origin.type);
if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
-- s2s stanzas can get here
- (origin.sends2s or origin.send)(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
+ origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
end
end
end
local from_node, from_host, from_resource = jid_split(from);
local from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID
+ -- Auto-detect origin if not specified
+ origin = origin or hosts[from_host];
+ if not origin then return false; end
+
if stanza.name == "presence" and (stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable") then resource = nil; end
local host_session = hosts[host]
elseif origin.type == "component" or origin.type == "local" then
-- Route via s2s for components and modules
log("debug", "Routing outgoing stanza for %s to %s", origin.host, host);
- for k,v in pairs(origin) do print("origin:", tostring(k), tostring(v)); end
- print(tostring(host), tostring(from_host))
send_s2s(origin.host, host, stanza);
else
log("warn", "received stanza from unhandled connection type: %s", origin.type);