aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-05-04 02:27:26 +0100
committerMatthew Wild <mwild1@gmail.com>2012-05-04 02:27:26 +0100
commit8d103e370b6069b9485c3d6b6f27f8ca0884010f (patch)
tree1cdc85866206cd63aa1591f6b9c2347247d718af /plugins
parent2cc95ea48abfc0f80268171277e055680e848f75 (diff)
downloadprosody-8d103e370b6069b9485c3d6b6f27f8ca0884010f.tar.gz
prosody-8d103e370b6069b9485c3d6b6f27f8ca0884010f.zip
mod_s2s: Cache to_host and from_host in local variables, and use these instead of repeated lookups
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_s2s/mod_s2s.lua23
1 files changed, 13 insertions, 10 deletions
diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua
index abe1992c..3087ba24 100644
--- a/plugins/mod_s2s/mod_s2s.lua
+++ b/plugins/mod_s2s/mod_s2s.lua
@@ -213,17 +213,20 @@ function stream_callbacks.streamopened(session, attr)
return;
end
+ -- For convenience we'll put the sanitised values into these variables
+ to, from = session.to_host, session.from_host;
+
session.streamid = uuid_gen();
(session.log or log)("debug", "Incoming s2s received %s", st.stanza("stream:stream", attr):top_tag());
- if session.to_host then
- if not hosts[session.to_host] then
+ if to then
+ if not hosts[to] then
-- Attempting to connect to a host we don't serve
session:close({
condition = "host-unknown";
- text = "This host does not serve "..session.to_host
+ text = "This host does not serve "..to
});
return;
- elseif hosts[session.to_host].disallow_s2s then
+ elseif hosts[to].disallow_s2s then
-- Attempting to connect to a host that disallows s2s
session:close({
condition = "policy-violation";
@@ -237,23 +240,23 @@ function stream_callbacks.streamopened(session, attr)
send("<?xml version='1.0'?>");
send(st.stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback',
- ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host, to=session.from_host, version=(session.version > 0 and "1.0" or nil) }):top_tag());
+ ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=to, to=from, version=(session.version > 0 and "1.0" or nil) }):top_tag());
if session.version >= 1.0 then
local features = st.stanza("stream:features");
- if session.to_host then
- hosts[session.to_host].events.fire_event("s2s-stream-features", { origin = session, features = features });
+ if to then
+ hosts[to].events.fire_event("s2s-stream-features", { origin = session, features = features });
else
- (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", session.from_host or "unknown host");
+ (session.log or log)("warn", "No 'to' on stream header from %s means we can't offer any features", from or "unknown host");
end
log("debug", "Sending stream features: %s", tostring(features));
send(features);
end
- local host_session = hosts[session.to_host];
+ local host_session = hosts[to];
session.send = function(stanza)
- host_session.events.fire_event("route/remote", { from_host = session.to_host, to_host = session.from_host, stanza = stanza})
+ host_session.events.fire_event("route/remote", { from_host = to, to_host = from, stanza = stanza})
end;
elseif session.direction == "outgoing" then
-- If we are just using the connection for verifying dialback keys, we won't try and auth it