# HG changeset patch # User Waqas Hussain # Date 1289587410 -18000 # Node ID 321767e78029a4455c1931feca05675576d9032e # Parent 26c9ba8f309c92070b8fa2cf5dcd7418d7ebf07e mod_component: Logging tweaks. diff -r 26c9ba8f309c -r 321767e78029 plugins/mod_component.lua --- a/plugins/mod_component.lua Fri Nov 12 23:35:02 2010 +0500 +++ b/plugins/mod_component.lua Fri Nov 12 23:43:30 2010 +0500 @@ -60,9 +60,8 @@ if session.type ~= "component" then return; end if main_session == session then return; end - log("info", "Handling component auth"); if (not session.host) or #stanza.tags > 0 then - (session.log or log)("warn", "Component handshake invalid"); + (session.log or log)("warn", "Invalid component handshake for host: %s", session.host); session:close("not-authorized"); return true; end @@ -77,25 +76,21 @@ local supplied_token = t_concat(stanza); local calculated_token = sha1(session.streamid..secret, true); if supplied_token:lower() ~= calculated_token:lower() then - log("info", "Component for %s authentication failed", session.host); + log("info", "Component authentication failed for %s", session.host); session:close{ condition = "not-authorized", text = "Given token does not match calculated token" }; return true; end - -- Authenticated now - log("info", "Component authenticated: %s", session.host); - - session.component_validate_from = module:get_option_boolean("validate_from_addresses") ~= false; - -- If component not already created for this host, create one now if not main_session then send = session.send; main_session = session; session.on_destroy = on_destroy; - log("info", "Component successfully registered"); + session.component_validate_from = module:get_option_boolean("validate_from_addresses") ~= false; + log("info", "Component successfully authenticated: %s", session.host); session.send(st.stanza("handshake")); - else - log("error", "Multiple components bound to the same address, first one wins (TODO: Implement stanza distribution)"); + else -- TODO: Implement stanza distribution + log("error", "Multiple components bound to the same address, first one wins: %s", session.host); session:close{ condition = "conflict", text = "Component already connected" }; end