From 1eeeaf731844a81f039d4b1cab6cdfe20d8d0e30 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 7 Mar 2009 19:28:12 +0000 Subject: prosody: Load logger after reading the config --- prosody | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/prosody b/prosody index 15c94c92..0e38c6c2 100755 --- a/prosody +++ b/prosody @@ -32,10 +32,6 @@ pcall(require, "luarocks.require") config = require "core.configmanager" -log = require "util.logger".init("general"); - --- Disable log output, needs to read from config --- require "util.logger".setwriter(function () end); do -- TODO: Check for other formats when we add support for them @@ -63,6 +59,11 @@ do end end +log = require "util.logger".init("general"); + +-- Disable log output, needs to read from config +-- require "util.logger".setwriter(function () end); + require "util.dependencies" local server = require "net.server" -- cgit v1.2.3 From 8a253c1cc93aa94a1a3782954035720f45e8b96c Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Sat, 7 Mar 2009 20:33:21 +0100 Subject: Support to filter logging by source via pattern matching from config file. --- util/logger.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/util/logger.lua b/util/logger.lua index 791e222b..9969f934 100644 --- a/util/logger.lua +++ b/util/logger.lua @@ -13,8 +13,13 @@ local debug = debug; local tostring = tostring; local math_max = math.max; +local config = require "core.configmanager"; +local log_sources = config.get("*", "core", "log_sources"); + local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring; local do_pretty_printing = not os.getenv("WINDIR"); +local find = require "string".find; +local ipairs = ipairs; module "logger" @@ -32,6 +37,18 @@ local sourcewidth = 20; local outfunction = nil; function init(name) + if log_sources then + local log_this = false; + for _, source in ipairs(log_sources) do + if find(name, source) then + log_this = true + break + end + end + + if not log_this then return function () end end + end + --name = nil; -- While this line is not commented, will automatically fill in file/line number info local namelen = #name; return function (level, message, ...) -- cgit v1.2.3 From b657bdb211b25227ea37c9db458ec960b060c0d9 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 7 Mar 2009 19:40:00 +0000 Subject: util.logger: Small code tidying :) --- util/logger.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/logger.lua b/util/logger.lua index 9969f934..2c8eea30 100644 --- a/util/logger.lua +++ b/util/logger.lua @@ -18,7 +18,7 @@ local log_sources = config.get("*", "core", "log_sources"); local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring; local do_pretty_printing = not os.getenv("WINDIR"); -local find = require "string".find; +local find = string.find; local ipairs = ipairs; module "logger" @@ -41,8 +41,8 @@ function init(name) local log_this = false; for _, source in ipairs(log_sources) do if find(name, source) then - log_this = true - break + log_this = true; + break; end end -- cgit v1.2.3 From a40ad27d1e7ffccd986487ddb02e6d685a628a17 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 7 Mar 2009 19:56:53 +0000 Subject: net.server: Allow replacement of send function on an open socket --- net/server.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/server.lua b/net/server.lua index 361c5949..891d32db 100644 --- a/net/server.lua +++ b/net/server.lua @@ -386,6 +386,10 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport pattern = new or pattern return pattern end + handler.setsend = function ( newsend ) + send = newsend or send + return send + end handler.bufferlen = function( readlen, sendlen ) maxsendlen = sendlen or maxsendlen maxreadlen = readlen or maxreadlen -- cgit v1.2.3 From 9dd38d32f927e10b0a1d9346cc0e000009d8256a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 7 Mar 2009 19:57:28 +0000 Subject: net.adns: Set new send in net.server after 'connecting UDP' socket --- net/adns.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/adns.lua b/net/adns.lua index 200784aa..cb784d40 100644 --- a/net/adns.lua +++ b/net/adns.lua @@ -29,7 +29,7 @@ function new_async_socket(sock) newconn.handler, newconn._socket = server.wrapclient(sock, "dns", 53, listener); newconn.handler.settimeout = function () end newconn.handler.setsockname = function (_, ...) return sock:setsockname(...); end - newconn.handler.setpeername = function (_, ...) return sock:setpeername(...); end + newconn.handler.setpeername = function (_, ...) local ret = sock:setpeername(...); _.setsend(sock.send); return ret; end newconn.handler.connect = function (_, ...) return sock:connect(...) end newconn.handler.send = function (_, data) return _.write(data) end return newconn.handler; -- cgit v1.2.3 From 90fa7296e47fa3439f9842b6904c35dba48364e7 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 7 Mar 2009 20:17:09 +0000 Subject: mod_saslauth: Disable SASL ANONYMOUS unless explicitly enabled with sasl_anonymous = true --- plugins/mod_saslauth.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua index ed19a150..4804607b 100644 --- a/plugins/mod_saslauth.lua +++ b/plugins/mod_saslauth.lua @@ -17,6 +17,7 @@ local t_concat, t_insert = table.concat, table.insert; local tostring = tostring; local jid_split = require "util.jid".split local md5 = require "util.hashes".md5; +local config = require "core.configmanager"; local log = require "util.logger".init("mod_saslauth"); @@ -106,7 +107,9 @@ module:add_event_hook("stream-features", -- TODO: Provide PLAIN only if TLS is active, this is a SHOULD from the introduction of RFC 4616. This behavior could be overridden via configuration but will issuing a warning or so. features:tag("mechanism"):text("PLAIN"):up(); features:tag("mechanism"):text("DIGEST-MD5"):up(); - features:tag("mechanism"):text("ANONYMOUS"):up(); + if config.get(session.host or "*", "core", "sasl_anonymous") then + features:tag("mechanism"):text("ANONYMOUS"):up(); + end features:up(); else features:tag("bind", bind_attr):tag("required"):up():up(); -- cgit v1.2.3