aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-01-13 15:29:00 +0000
committerMatthew Wild <mwild1@gmail.com>2009-01-13 15:29:00 +0000
commit4dc4d175d135e293f48ed6a15f61b19c4dafe8d7 (patch)
treec4a1aeb92f7ccaccc8fd919d065d3add4c71c12d /core
parentbb7d8604f252ce84bdea1cb791114dfc40c5a958 (diff)
parent8b979ccaf40ae38dbeaa5e7a4edb2e6d760fdffa (diff)
downloadprosody-4dc4d175d135e293f48ed6a15f61b19c4dafe8d7.tar.gz
prosody-4dc4d175d135e293f48ed6a15f61b19c4dafe8d7.zip
Automated merge with http://waqas.ath.cx:8000/
Diffstat (limited to 'core')
-rw-r--r--core/actions.lua19
-rw-r--r--core/modulemanager.lua19
-rw-r--r--core/sessionmanager.lua1
3 files changed, 36 insertions, 3 deletions
diff --git a/core/actions.lua b/core/actions.lua
new file mode 100644
index 00000000..d0be5aeb
--- /dev/null
+++ b/core/actions.lua
@@ -0,0 +1,19 @@
+
+local actions = {};
+
+function register(path, t)
+ local curr = actions;
+ for comp in path:gmatch("([^/]+)/") do
+ if curr[comp] == nil then
+ curr[comp] = {};
+ end
+ curr = curr[comp];
+ if type(curr) ~= "table" then
+ return nil, "path-taken";
+ end
+ end
+ curr[path:match("/([^/]+)$")] = t;
+ return true;
+end
+
+return { actions = actions, register= register }; \ No newline at end of file
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index efb909ac..52fbc65d 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -27,7 +27,7 @@ local addDiscoInfoHandler = require "core.discomanager".addDiscoInfoHandler;
local eventmanager = require "core.eventmanager";
local config = require "core.configmanager";
local multitable_new = require "util.multitable".new;
-
+local register_actions = require "core.actions".register;
local loadfile, pcall = loadfile, pcall;
local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv;
@@ -68,11 +68,11 @@ function load_modules_for_host(host)
local disabled_set = {};
if modules_enabled then
if modules_disabled then
- for _, module in pairs(modules_disabled) do
+ for _, module in ipairs(modules_disabled) do
disabled_set[module] = true;
end
end
- for _, module in pairs(modules_enabled) do
+ for _, module in ipairs(modules_enabled) do
if not disabled_set[module] then
load(host, module);
end
@@ -256,4 +256,17 @@ end
--------------------------------------------------------------------
+local actions = {};
+
+function actions.load(params)
+ --return true, "Module loaded ("..params.module.." on "..params.host..")";
+ return load(params.host, params.module);
+end
+
+function actions.unload(params)
+ return unload(params.host, params.module);
+end
+
+register_actions("/modules", actions);
+
return _M;
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index 963de7ce..f04ca29c 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -58,6 +58,7 @@ function new_session(conn)
log("info", "open sessions now: ".. open_sessions);
local w = conn.write;
session.send = function (t) w(tostring(t)); end
+ session.ip = conn.ip();
return session;
end