aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/componentmanager.lua2
-rw-r--r--core/configmanager.lua2
-rw-r--r--core/discomanager.lua2
-rw-r--r--core/modulemanager.lua2
-rw-r--r--core/offlinemanager.lua2
-rw-r--r--core/offlinemessage.lua2
-rw-r--r--core/presencemanager.lua2
-rw-r--r--core/rostermanager.lua2
-rw-r--r--core/s2smanager.lua17
-rw-r--r--core/sessionmanager.lua6
-rw-r--r--core/stanza_router.lua19
-rw-r--r--core/usermanager.lua2
-rw-r--r--core/xmlhandlers.lua20
13 files changed, 44 insertions, 36 deletions
diff --git a/core/componentmanager.lua b/core/componentmanager.lua
index 974b5bf1..a63cfd7a 100644
--- a/core/componentmanager.lua
+++ b/core/componentmanager.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/core/configmanager.lua b/core/configmanager.lua
index 6601fed6..a6e86347 100644
--- a/core/configmanager.lua
+++ b/core/configmanager.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/core/discomanager.lua b/core/discomanager.lua
index 16bf2227..21080635 100644
--- a/core/discomanager.lua
+++ b/core/discomanager.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/core/modulemanager.lua b/core/modulemanager.lua
index 84486b58..da5945ac 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.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/core/offlinemanager.lua b/core/offlinemanager.lua
index c327f979..b56b0ef7 100644
--- a/core/offlinemanager.lua
+++ b/core/offlinemanager.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/core/offlinemessage.lua b/core/offlinemessage.lua
index 9888f76d..36f2948d 100644
--- a/core/offlinemessage.lua
+++ b/core/offlinemessage.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/core/presencemanager.lua b/core/presencemanager.lua
index 6e27752b..e4dd6cc4 100644
--- a/core/presencemanager.lua
+++ b/core/presencemanager.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/core/rostermanager.lua b/core/rostermanager.lua
index b5698fc5..fc8a5862 100644
--- a/core/rostermanager.lua
+++ b/core/rostermanager.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/core/s2smanager.lua b/core/s2smanager.lua
index 7827381d..fa38d5cb 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -1,4 +1,4 @@
--- Prosody IM v0.1
+-- Prosody IM v0.2
-- Copyright (C) 2008 Matthew Wild
-- Copyright (C) 2008 Waqas Hussain
--
@@ -47,6 +47,9 @@ local dialback_secret = sha256_hash(tostring{} .. math.random() .. socket.gettim
local dns = require "net.dns";
+incoming_s2s = {};
+local incoming_s2s = incoming_s2s;
+
module "s2smanager"
local function compare_srv_priorities(a,b) return a.priority < b.priority or a.weight < b.weight; end
@@ -91,7 +94,7 @@ end
local open_sessions = 0;
function new_incoming(conn)
- local session = { conn = conn, type = "s2sin_unauthed", direction = "incoming" };
+ local session = { conn = conn, type = "s2sin_unauthed", direction = "incoming", hosts = {} };
if true then
session.trace = newproxy(true);
getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end;
@@ -99,6 +102,7 @@ function new_incoming(conn)
open_sessions = open_sessions + 1;
local w, log = conn.write, logger_init("s2sin"..tostring(conn):match("[a-f0-9]+$"));
session.sends2s = function (t) log("debug", "sending: %s", tostring(t)); w(tostring(t)); end
+ incoming_s2s[session] = true;
return session;
end
@@ -239,11 +243,16 @@ function verify_dialback(id, to, from, key)
return key == generate_dialback(id, to, from);
end
-function make_authenticated(session)
+function make_authenticated(session, host)
if session.type == "s2sout_unauthed" then
session.type = "s2sout";
elseif session.type == "s2sin_unauthed" then
session.type = "s2sin";
+ if host then
+ session.hosts[host].authed = true;
+ end
+ elseif session.type == "s2sin" and host then
+ session.hosts[host].authed = true;
else
return false;
end
@@ -284,6 +293,8 @@ function destroy_session(session)
if session.direction == "outgoing" then
hosts[session.from_host].s2sout[session.to_host] = nil;
+ elseif session.direction == "incoming" then
+ incoming_s2s[session] = nil;
end
for k in pairs(session) do
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index 34cc9f0f..963de7ce 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -1,4 +1,4 @@
--- Prosody IM v0.1
+-- Prosody IM v0.2
-- Copyright (C) 2008 Matthew Wild
-- Copyright (C) 2008 Waqas Hussain
--
@@ -113,8 +113,6 @@ function bind_resource(session, resource)
if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end
-- We don't support binding multiple resources
- session.conntimetotal = gettime()-session.conntime;
-
resource = resource or uuid_generate();
--FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing
@@ -209,4 +207,4 @@ function send_to_available_resources(user, host, stanza)
return count;
end
-return _M; \ No newline at end of file
+return _M;
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index c2214b1c..24eadedc 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -1,4 +1,4 @@
--- Prosody IM v0.1
+-- Prosody IM v0.2
-- Copyright (C) 2008 Matthew Wild
-- Copyright (C) 2008 Waqas Hussain
--
@@ -72,26 +72,27 @@ function core_process_stanza(origin, stanza)
if origin.type == "c2s" then
stanza.attr.from = origin.full_jid;
end
- local to = stanza.attr.to;
+ local to, xmlns = stanza.attr.to, stanza.attr.xmlns;
local node, host, resource = jid_split(to);
local to_bare = node and (node.."@"..host) or host; -- bare JID
local from = stanza.attr.from;
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
- if origin.type == "s2sin" then
- if origin.from_host ~= from_host then -- remote server trying to impersonate some other server?
- log("warn", "Received a stanza claiming to be from %s, over a conn authed for %s!", from, origin.from_host);
- return; -- FIXME what should we do here? does this work with subdomains?
- end
- end
--[[if to and not(hosts[to]) and not(hosts[to_bare]) and (hosts[host] and hosts[host].type ~= "local") then -- not for us?
log("warn", "stanza recieved for a non-local server");
return; -- FIXME what should we do here?
end]] -- FIXME
-- FIXME do stanzas not of jabber:client get handled by components?
- if origin.type == "s2sin" or origin.type == "c2s" then
+ if (origin.type == "s2sin" or origin.type == "c2s") and (not xmlns or xmlns == "jabber:server" or xmlns == "jabber:client") then
+ if origin.type == "s2sin" then
+ local host_status = origin.hosts[from_host];
+ if not host_status or not host_status.authed then -- remote server trying to impersonate some other server?
+ log("warn", "Received a stanza claiming to be from %s, over a conn authed for %s!", from_host, origin.from_host);
+ return; -- FIXME what should we do here? does this work with subdomains?
+ end
+ end
if not to then
core_handle_stanza(origin, stanza);
elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server
diff --git a/core/usermanager.lua b/core/usermanager.lua
index 2c02394f..2da64cff 100644
--- a/core/usermanager.lua
+++ b/core/usermanager.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/core/xmlhandlers.lua b/core/xmlhandlers.lua
index b4dd5479..d4d9e141 100644
--- a/core/xmlhandlers.lua
+++ b/core/xmlhandlers.lua
@@ -1,4 +1,4 @@
--- Prosody IM v0.1
+-- Prosody IM v0.2
-- Copyright (C) 2008 Matthew Wild
-- Copyright (C) 2008 Waqas Hussain
--
@@ -47,29 +47,27 @@ local ns_prefixes = {
function init_xmlhandlers(session, stream_callbacks)
local ns_stack = { "" };
- local curr_ns = "";
+ local curr_ns, name = "";
local curr_tag;
local chardata = {};
local xml_handlers = {};
local log = session.log or default_log;
-
- local send = session.send;
local cb_streamopened = stream_callbacks.streamopened;
local cb_streamclosed = stream_callbacks.streamclosed;
local cb_error = stream_callbacks.error or function (session, e) error("XML stream error: "..tostring(e)); end;
local cb_handlestanza = stream_callbacks.handlestanza;
- local stream_ns = stream_callbacks.ns;
+ local stream_tag = stream_callbacks.stream_tag;
local stanza
- function xml_handlers:StartElement(name, attr)
+ function xml_handlers:StartElement(tagname, attr)
if stanza and #chardata > 0 then
-- We have some character data in the buffer
stanza:text(t_concat(chardata));
chardata = {};
end
- curr_ns,name = name:match("^(.+)|([%w%-]+)$");
+ local curr_ns,name = tagname:match("^(.+)|([%w%-]+)$");
if curr_ns ~= "jabber:server" then
attr.xmlns = curr_ns;
end
@@ -91,7 +89,7 @@ function init_xmlhandlers(session, stream_callbacks)
if not stanza then --if we are not currently inside a stanza
if session.notopen then
- if name == "stream" and curr_ns == stream_ns then
+ if tagname == stream_tag then
if cb_streamopened then
cb_streamopened(session, attr);
end
@@ -120,10 +118,10 @@ function init_xmlhandlers(session, stream_callbacks)
t_insert(chardata, data);
end
end
- function xml_handlers:EndElement(name)
- curr_ns,name = name:match("^(.+)|([%w%-]+)$");
+ function xml_handlers:EndElement(tagname)
+ curr_ns,name = tagname:match("^(.+)|([%w%-]+)$");
if (not stanza) or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then
- if name == "stream" then
+ if tagname == stream_tag then
if cb_streamclosed then
cb_streamclosed(session);
end