diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_console.lua | 2 | ||||
-rw-r--r-- | plugins/mod_dialback.lua | 70 | ||||
-rw-r--r-- | plugins/mod_disco.lua | 2 | ||||
-rw-r--r-- | plugins/mod_legacyauth.lua | 2 | ||||
-rw-r--r-- | plugins/mod_ping.lua | 2 | ||||
-rw-r--r-- | plugins/mod_private.lua | 2 | ||||
-rw-r--r-- | plugins/mod_register.lua | 2 | ||||
-rw-r--r-- | plugins/mod_roster.lua | 2 | ||||
-rw-r--r-- | plugins/mod_saslauth.lua | 2 | ||||
-rw-r--r-- | plugins/mod_selftests.lua | 2 | ||||
-rw-r--r-- | plugins/mod_time.lua | 2 | ||||
-rw-r--r-- | plugins/mod_tls.lua | 4 | ||||
-rw-r--r-- | plugins/mod_uptime.lua | 2 | ||||
-rw-r--r-- | plugins/mod_vcard.lua | 2 | ||||
-rw-r--r-- | plugins/mod_version.lua | 4 |
15 files changed, 65 insertions, 37 deletions
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua index 4ac3c5fe..d6383a78 100644 --- a/plugins/mod_console.lua +++ b/plugins/mod_console.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index 6bfed8fc..4e29b334 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- @@ -29,6 +29,8 @@ local log = require "util.logger".init("mod_dialback"); local xmlns_dialback = "jabber:server:dialback"; +local dialback_requests = setmetatable({}, { __mode = 'v' }); + module:add_handler({"s2sin_unauthed", "s2sin"}, "verify", xmlns_dialback, function (origin, stanza) -- We are being asked to verify the key, to ensure it was generated by us @@ -47,50 +49,78 @@ module:add_handler({"s2sin_unauthed", "s2sin"}, "verify", xmlns_dialback, origin.sends2s(st.stanza("db:verify", { from = attr.to, to = attr.from, id = attr.id, type = type }):text(stanza[1])); end); -module:add_handler("s2sin_unauthed", "result", xmlns_dialback, +module:add_handler({ "s2sin_unauthed", "s2sin" }, "result", xmlns_dialback, function (origin, stanza) -- he wants to be identified through dialback -- We need to check the key with the Authoritative server local attr = stanza.attr; - local attr = stanza.attr; - origin.from_host = attr.from; - origin.to_host = attr.to; - origin.dialback_key = stanza[1]; - log("debug", "asking %s if key %s belongs to them", origin.from_host, origin.dialback_key); - send_s2s(origin.to_host, origin.from_host, - st.stanza("db:verify", { from = origin.to_host, to = origin.from_host, id = origin.streamid }):text(origin.dialback_key)); - hosts[origin.to_host].s2sout[origin.from_host].dialback_verifying = origin; + origin.hosts[attr.from] = { dialback_key = stanza[1] }; + + if not hosts[attr.to] then + -- Not a host that we serve + log("info", "%s tried to connect to %s, which we don't serve", attr.from, attr.to); + origin:close("host-unknown"); + return; + end + + dialback_requests[attr.from] = origin; + + if not origin.from_host then + -- Just used for friendlier logging + origin.from_host = attr.from; + end + if not origin.to_host then + -- Just used for friendlier logging + origin.to_host = attr.to; + end + + log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]); + send_s2s(attr.to, attr.from, + st.stanza("db:verify", { from = attr.to, to = attr.from, id = origin.streamid }):text(stanza[1])); end); module:add_handler({ "s2sout_unauthed", "s2sout" }, "verify", xmlns_dialback, function (origin, stanza) - if origin.dialback_verifying then + local attr = stanza.attr; + local dialback_verifying = dialback_requests[attr.from]; + if dialback_verifying then local valid; - local attr = stanza.attr; if attr.type == "valid" then - s2s_make_authenticated(origin.dialback_verifying); + s2s_make_authenticated(dialback_verifying, attr.from); valid = "valid"; else -- Warn the original connection that is was not verified successfully - log("warn", "dialback for "..(origin.dialback_verifying.from_host or "(unknown)").." failed"); + log("warn", "authoritative server for "..(attr.from or "(unknown)").." denied the key"); valid = "invalid"; end - if not origin.dialback_verifying.sends2s then - log("warn", "Incoming s2s session %s was closed in the meantime, so we can't notify it of the db result", tostring(origin.dialback_verifying):match("%w+$")); + if not dialback_verifying.sends2s then + log("warn", "Incoming s2s session %s was closed in the meantime, so we can't notify it of the db result", tostring(dialback_verifying):match("%w+$")); else - origin.dialback_verifying.sends2s( + dialback_verifying.sends2s( st.stanza("db:result", { from = attr.to, to = attr.from, id = attr.id, type = valid }) - :text(origin.dialback_verifying.dialback_key)); + :text(dialback_verifying.hosts[attr.from].dialback_key)); end + dialback_requests[attr.from] = nil; end end); module:add_handler({ "s2sout_unauthed", "s2sout" }, "result", xmlns_dialback, function (origin, stanza) + -- Remote server is telling us whether we passed dialback + + local attr = stanza.attr; + if not hosts[attr.to] then + origin:close("host-unknown"); + return; + elseif hosts[attr.to].s2sout[attr.from] ~= origin then + -- This isn't right + origin:close("invalid-id"); + return; + end if stanza.attr.type == "valid" then - s2s_make_authenticated(origin); + s2s_make_authenticated(origin, attr.from); else - -- FIXME + -- FIXME: Waiting on #33 error("dialback failed!"); end end); diff --git a/plugins/mod_disco.lua b/plugins/mod_disco.lua index 455f92f1..9f643134 100644 --- a/plugins/mod_disco.lua +++ b/plugins/mod_disco.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_legacyauth.lua b/plugins/mod_legacyauth.lua index ca2d9f78..1869bba5 100644 --- a/plugins/mod_legacyauth.lua +++ b/plugins/mod_legacyauth.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_ping.lua b/plugins/mod_ping.lua index 922c9390..53a808cd 100644 --- a/plugins/mod_ping.lua +++ b/plugins/mod_ping.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_private.lua b/plugins/mod_private.lua index 8bcb6da6..76d18d39 100644 --- a/plugins/mod_private.lua +++ b/plugins/mod_private.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index cc02a5bc..120faeab 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_roster.lua b/plugins/mod_roster.lua index bbd678b8..83e9835d 100644 --- a/plugins/mod_roster.lua +++ b/plugins/mod_roster.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index bea1012a..4934523f 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_selftests.lua b/plugins/mod_selftests.lua index abfabc9b..1a2190dc 100644 --- a/plugins/mod_selftests.lua +++ b/plugins/mod_selftests.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_time.lua b/plugins/mod_time.lua index 3d73623c..675bc023 100644 --- a/plugins/mod_time.lua +++ b/plugins/mod_time.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua index 20cf7c3d..fc816ad1 100644 --- a/plugins/mod_tls.lua +++ b/plugins/mod_tls.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- @@ -33,8 +33,6 @@ module:add_handler("c2s_unauthed", "starttls", xmlns_starttls, function (session, stanza) if session.conn.starttls then session.send(st.stanza("proceed", { xmlns = xmlns_starttls })); - -- FIXME: I'm commenting the below, not sure why it was necessary - -- sessions[session.conn] = nil; session:reset_stream(); session.conn.starttls(); session.log("info", "TLS negotiation started..."); diff --git a/plugins/mod_uptime.lua b/plugins/mod_uptime.lua index 51457551..33dd66fb 100644 --- a/plugins/mod_uptime.lua +++ b/plugins/mod_uptime.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_vcard.lua b/plugins/mod_vcard.lua index fc71bb1b..10119252 100644 --- a/plugins/mod_vcard.lua +++ b/plugins/mod_vcard.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- diff --git a/plugins/mod_version.lua b/plugins/mod_version.lua index 0b7ebfaa..c263031a 100644 --- a/plugins/mod_version.lua +++ b/plugins/mod_version.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.1 +-- Prosody IM v0.2 -- Copyright (C) 2008 Matthew Wild -- Copyright (C) 2008 Waqas Hussain -- @@ -31,7 +31,7 @@ local function handle_version_request(session, stanza) if stanza.attr.type == "get" then session.send(st.reply(stanza):query(xmlns_version) :tag("name"):text("Prosody"):up() - :tag("version"):text("0.1"):up() + :tag("version"):text("0.2"):up() :tag("os"):text("the best operating system ever!")); end end |