From 752df97c84549c703b43edaf0f7faefdc4505485 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 8 Apr 2013 15:53:18 +0100 Subject: sessionmanager, s2smanager: Remove open_session tracing --- core/s2smanager.lua | 9 +-------- core/sessionmanager.lua | 11 +---------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 5777cb8e..e4de498a 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -24,15 +24,8 @@ local fire_event = prosody.events.fire_event; module "s2smanager" -local open_sessions = 0; - function new_incoming(conn) 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; - end - open_sessions = open_sessions + 1; session.log = logger_init("s2sin"..tostring(session):match("[a-f0-9]+$")); incoming_s2s[session] = true; return session; @@ -62,7 +55,7 @@ local resting_session = { -- Resting, not dead function retire_session(session, reason) local log = session.log or log; for k in pairs(session) do - if k ~= "trace" and k ~= "log" and k ~= "id" and k ~= "conn" then + if k ~= "log" and k ~= "id" and k ~= "conn" then session[k] = nil; end end diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index e721835d..d178fb2d 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -29,17 +29,8 @@ local getmetatable = getmetatable; module "sessionmanager" -local open_sessions = 0; - function new_session(conn) local session = { conn = conn, type = "c2s_unauthed", conntime = gettime() }; - if true then - session.trace = newproxy(true); - getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end; - end - open_sessions = open_sessions + 1; - log("debug", "open sessions now: %d", open_sessions); - local filter = initialize_filters(session); local w = conn.write; session.send = function (t) @@ -72,7 +63,7 @@ local resting_session = { -- Resting, not dead function retire_session(session) local log = session.log or log; for k in pairs(session) do - if k ~= "trace" and k ~= "log" and k ~= "id" then + if k ~= "log" and k ~= "id" then session[k] = nil; end end -- cgit v1.2.3 From 09e6b19e4f830e277665d7c73c9cb1881c3839ec Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 8 Apr 2013 16:40:27 +0100 Subject: net.http: Throw error when connecting to a http:// URL without LuaSec available --- net/http.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/http.lua b/net/http.lua index a1e4e523..ec55af92 100644 --- a/net/http.lua +++ b/net/http.lua @@ -11,6 +11,8 @@ local b64 = require "util.encodings".base64.encode; local url = require "socket.url" local httpstream_new = require "util.httpstream".new; +local ssl_available = pcall(require, "ssl"); + local server = require "net.server" local t_insert, t_concat = table.insert, table.concat; @@ -177,6 +179,9 @@ function request(u, ex, callback) req.method, req.headers, req.body = method, headers, body; local using_https = req.scheme == "https"; + if using_https and not ssl_available then + error("SSL not available, unable to contact https URL"); + end local port = tonumber(req.port) or (using_https and 443 or 80); -- Connect the socket, and wrap it with net.server -- cgit v1.2.3 From 84b29550d6ef5ec3d4472e4525e7c101edaf7dbb Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 8 Apr 2013 16:56:40 +0100 Subject: util.pposix: syslog(): Support an optional source parameter (producing messages of the form ': ' --- util-src/pposix.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/util-src/pposix.c b/util-src/pposix.c index 99a308cf..c8c25ba9 100644 --- a/util-src/pposix.c +++ b/util-src/pposix.c @@ -204,12 +204,13 @@ int level_constants[] = { }; int lc_syslog_log(lua_State* L) { - int level = luaL_checkoption(L, 1, "notice", level_strings); - level = level_constants[level]; + int level = level_constants[luaL_checkoption(L, 1, "notice", level_strings)]; - luaL_checkstring(L, 2); + if(lua_gettop(L) == 3) + syslog(level, "%s: %s", luaL_checkstring(L, 2), luaL_checkstring(L, 3)); + else + syslog(level, "%s", lua_tostring(L, 2)); - syslog(level, "%s", lua_tostring(L, 2)); return 0; } -- cgit v1.2.3 From 9c5ea7b6a8ef13f87fbcd0554ff8a0b712c4b3a7 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 8 Apr 2013 16:57:05 +0100 Subject: mod_posix: Pass logger name to syslog, so that sources now get logged --- plugins/mod_posix.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua index e871e5cf..96a05d73 100644 --- a/plugins/mod_posix.lua +++ b/plugins/mod_posix.lua @@ -118,9 +118,9 @@ function syslog_sink_maker(config) local syslog, format = pposix.syslog_log, string.format; return function (name, level, message, ...) if ... then - syslog(level, format(message, ...)); + syslog(level, name, format(message, ...)); else - syslog(level, message); + syslog(level, name, message); end end; end -- cgit v1.2.3 From 4031be743b96e3def712842f985b510651c8fcbe Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 8 Apr 2013 16:57:59 +0100 Subject: mod_posix, util.pposix: Bump version for API change --- plugins/mod_posix.lua | 2 +- util-src/pposix.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua index 96a05d73..f1957d1d 100644 --- a/plugins/mod_posix.lua +++ b/plugins/mod_posix.lua @@ -7,7 +7,7 @@ -- -local want_pposix_version = "0.3.5"; +local want_pposix_version = "0.3.6"; local pposix = assert(require "util.pposix"); if pposix._VERSION ~= want_pposix_version then module:log("warn", "Unknown version (%s) of binary pposix module, expected %s", tostring(pposix._VERSION), want_pposix_version); end diff --git a/util-src/pposix.c b/util-src/pposix.c index c8c25ba9..f5cc8270 100644 --- a/util-src/pposix.c +++ b/util-src/pposix.c @@ -13,7 +13,7 @@ * POSIX support functions for Lua */ -#define MODULE_VERSION "0.3.5" +#define MODULE_VERSION "0.3.6" #include #include -- cgit v1.2.3 From 7e9a5cc5a36ae7d653836615143b5a78a505bfed Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 8 Apr 2013 17:21:16 +0100 Subject: mod_posix: Improve error message for a pposix version mismatch --- plugins/mod_posix.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua index f1957d1d..28fd7f38 100644 --- a/plugins/mod_posix.lua +++ b/plugins/mod_posix.lua @@ -10,7 +10,9 @@ local want_pposix_version = "0.3.6"; local pposix = assert(require "util.pposix"); -if pposix._VERSION ~= want_pposix_version then module:log("warn", "Unknown version (%s) of binary pposix module, expected %s", tostring(pposix._VERSION), want_pposix_version); end +if pposix._VERSION ~= want_pposix_version then + module:log("warn", "Unknown version (%s) of binary pposix module, expected %s. Perhaps you need to recompile?", tostring(pposix._VERSION), want_pposix_version); +end local signal = select(2, pcall(require, "util.signal")); if type(signal) == "string" then -- cgit v1.2.3