aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/stanza_router.lua6
-rw-r--r--lxmppd.cfg.dist47
-rw-r--r--main.lua6
-rw-r--r--util/datamanager.lua13
4 files changed, 42 insertions, 30 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index 03018c8b..4f6918d2 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -51,7 +51,7 @@ function core_process_stanza(origin, stanza)
if origin.type == "c2s" then
stanza.attr.from = origin.full_jid; -- quick fix to prevent impersonation (FIXME this would be incorrect when the origin is not c2s)
end
-
+
if not to then
core_handle_stanza(origin, stanza);
elseif origin.type == "c2s" and stanza.name == "presence" and stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" then
@@ -78,7 +78,7 @@ function core_handle_stanza(origin, stanza)
if modules_handle_stanza(origin, stanza) then return; end
if origin.type == "c2s" or origin.type == "c2s_unauthed" then
local session = origin;
-
+
if stanza.name == "presence" and origin.roster then
if stanza.attr.type == nil or stanza.attr.type == "unavailable" then
for jid in pairs(origin.roster) do -- broadcast to all interested contacts
@@ -260,7 +260,7 @@ end
function core_route_stanza(origin, stanza)
-- Hooks
--- ...later
-
+
-- Deliver
local to = stanza.attr.to;
local node, host, resource = jid_split(to);
diff --git a/lxmppd.cfg.dist b/lxmppd.cfg.dist
index b1b0d9ad..c743f2cb 100644
--- a/lxmppd.cfg.dist
+++ b/lxmppd.cfg.dist
@@ -1,25 +1,26 @@
+---- lxmppd configuration file ----
-sessions = {};
-hosts = {
- ["localhost"] = {
- type = "local";
- connected = true;
- sessions = {};
- };
- ["getjabber.ath.cx"] = {
- type = "local";
- connected = true;
- sessions = {};
- };
- }
-
--- If the following is not defined, no SSL will be set up on 5223
-ssl_ctx = {
- mode = "server",
- protocol = "sslv23",
-
- key = "/home/matthew/ssl_cert/server.key",
- certificate = "/home/matthew/ssl_cert/server.crt",
- capath = "/etc/ssl/certs", verify = "none",
- }
+-- define the local hosts
+hosts = {
+ ["localhost"] = {
+ type = "local";
+ connected = true;
+ sessions = {};
+ };
+ ["getjabber.ath.cx"] = {
+ type = "local";
+ connected = true;
+ sessions = {};
+ };
+}
+
+-- if the following is not defined, no SSL will be set up on 5223
+ssl_ctx = {
+ mode = "server",
+ protocol = "sslv23",
+
+ key = "/home/matthew/ssl_cert/server.key",
+ certificate = "/home/matthew/ssl_cert/server.crt",
+ capath = "/etc/ssl/certs", verify = "none",
+}
diff --git a/main.lua b/main.lua
index e2ac7803..939f4512 100644
--- a/main.lua
+++ b/main.lua
@@ -10,12 +10,12 @@ function log(type, area, message)
end
dofile "lxmppd.cfg"
-
+
-- Maps connections to sessions --
sessions = {};
-
+
-- Load and initialise core modules --
-
+
require "util.import"
require "core.xmlhandlers"
require "core.rostermanager"
diff --git a/util/datamanager.lua b/util/datamanager.lua
index e5a74acd..aad370d1 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -5,8 +5,10 @@ local char = string.char;
local loadfile, setfenv, pcall = loadfile, setfenv, pcall;
local log = log;
local io_open = io.open;
+local os_remove = os.remove;
local tostring = tostring;
local error = error;
+local next = next;
local indent = function(f, i)
for n = 1, i do
@@ -93,14 +95,23 @@ function load(username, host, datastore)
end
function store(username, host, datastore, data)
+ if not data then
+ data = {};
+ end
+ -- save the datastore
local f, msg = io_open(getpath(username, host, datastore), "w+");
if not f then
log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..(username or "nil").."@"..(host or "nil"));
- return nil;
+ return;
end
f:write("return ");
simplesave(f, data, 1);
f:close();
+ if not next(data) then -- try to delete empty datastore
+ os_remove(getpath(username, host, datastore));
+ end
+ -- we write data even when we are deleting because lua doesn't have a
+ -- platform independent way of checking for non-exisitng files
return true;
end