# HG changeset patch # User Kim Alvefur # Date 1364008659 -3600 # Node ID 30484214d49b9c25a2594a0939d19c59557ad4d4 # Parent a344c1120e2bc5859846a84e3df0a8698fbfa9d9# Parent e119e378b1d9778b5f17fa3c36cb4ad7178c7fff Merge 0.9->trunk diff -r a344c1120e2b -r 30484214d49b core/certmanager.lua --- a/core/certmanager.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/core/certmanager.lua Sat Mar 23 04:17:39 2013 +0100 @@ -27,7 +27,7 @@ module "certmanager" -- Global SSL options if not overridden per-host -local default_ssl_config = configmanager.get("*", "core", "ssl"); +local default_ssl_config = configmanager.get("*", "ssl"); local default_capath = "/etc/ssl/certs"; local default_verify = (ssl and ssl.x509 and { "peer", "client_once", }) or "none"; local default_options = { "no_sslv2", luasec_has_noticket and "no_ticket" or nil }; @@ -100,7 +100,7 @@ end function reload_ssl_config() - default_ssl_config = configmanager.get("*", "core", "ssl"); + default_ssl_config = configmanager.get("*", "ssl"); end prosody.events.add_handler("config-reloaded", reload_ssl_config); diff -r a344c1120e2b -r 30484214d49b core/configmanager.lua --- a/core/configmanager.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/core/configmanager.lua Sat Mar 23 04:17:39 2013 +0100 @@ -25,7 +25,7 @@ local config = setmetatable({ ["*"] = { } }, config_mt); -- When host not found, use global -local host_mt = { }; +local host_mt = { __index = function(_, k) return config["*"][k] end } function getconfig() return config; diff -r a344c1120e2b -r 30484214d49b core/hostmanager.lua --- a/core/hostmanager.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/core/hostmanager.lua Sat Mar 23 04:17:39 2013 +0100 @@ -74,7 +74,7 @@ host = host; s2sout = {}; events = events_new(); - dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen(); + dialback_secret = configmanager.get(host, "dialback_secret") or uuid_gen(); send = host_send; modules = {}; }; diff -r a344c1120e2b -r 30484214d49b core/loggingmanager.lua --- a/core/loggingmanager.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/core/loggingmanager.lua Sat Mar 23 04:17:39 2013 +0100 @@ -146,7 +146,7 @@ logger.reset(); - local debug_mode = config.get("*", "core", "debug"); + local debug_mode = config.get("*", "debug"); default_logging = { { to = "console" , levels = { min = (debug_mode and "debug") or "info" } } }; default_file_logging = { @@ -154,7 +154,7 @@ }; default_timestamp = "%b %d %H:%M:%S"; - logging_config = config.get("*", "core", "log") or default_logging; + logging_config = config.get("*", "log") or default_logging; for name, sink_maker in pairs(old_sink_types) do diff -r a344c1120e2b -r 30484214d49b core/moduleapi.lua --- a/core/moduleapi.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/core/moduleapi.lua Sat Mar 23 04:17:39 2013 +0100 @@ -167,12 +167,9 @@ end function api:get_option(name, default_value) - local value = config.get(self.host, self.name, name); + local value = config.get(self.host, name); if value == nil then - value = config.get(self.host, "core", name); - if value == nil then - value = default_value; - end + value = default_value; end return value; end diff -r a344c1120e2b -r 30484214d49b core/modulemanager.lua --- a/core/modulemanager.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/core/modulemanager.lua Sat Mar 23 04:17:39 2013 +0100 @@ -44,12 +44,12 @@ -- Load modules when a host is activated function load_modules_for_host(host) - local component = config.get(host, "core", "component_module"); + local component = config.get(host, "component_module"); - local global_modules_enabled = config.get("*", "core", "modules_enabled"); - local global_modules_disabled = config.get("*", "core", "modules_disabled"); - local host_modules_enabled = config.get(host, "core", "modules_enabled"); - local host_modules_disabled = config.get(host, "core", "modules_disabled"); + local global_modules_enabled = config.get("*", "modules_enabled"); + local global_modules_disabled = config.get("*", "modules_disabled"); + local host_modules_enabled = config.get(host, "modules_enabled"); + local host_modules_disabled = config.get(host, "modules_disabled"); if host_modules_enabled == global_modules_enabled then host_modules_enabled = nil; end if host_modules_disabled == global_modules_disabled then host_modules_disabled = nil; end @@ -218,7 +218,7 @@ saved = ret; else log("warn", "Error saving module '%s:%s' state: %s", host, name, ret); - if not config.get(host, "core", "force_module_reload") then + if not config.get(host, "force_module_reload") then log("warn", "Aborting reload due to error, set force_module_reload to ignore this"); return nil, "save-state-failed"; else diff -r a344c1120e2b -r 30484214d49b core/sessionmanager.lua --- a/core/sessionmanager.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/core/sessionmanager.lua Sat Mar 23 04:17:39 2013 +0100 @@ -140,7 +140,7 @@ local sessions = hosts[session.host].sessions[session.username].sessions; if sessions[resource] then -- Resource conflict - local policy = config_get(session.host, "core", "conflict_resolve"); + local policy = config_get(session.host, "conflict_resolve"); local increment; if policy == "random" then resource = uuid_generate(); diff -r a344c1120e2b -r 30484214d49b core/usermanager.lua --- a/core/usermanager.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/core/usermanager.lua Sat Mar 23 04:17:39 2013 +0100 @@ -42,8 +42,8 @@ host_session.events.add_handler("item-added/auth-provider", function (event) local provider = event.item; - local auth_provider = config.get(host, "core", "authentication") or default_provider; - if config.get(host, "core", "anonymous_login") then + local auth_provider = config.get(host, "authentication") or default_provider; + if config.get(host, "anonymous_login") then log("error", "Deprecated config option 'anonymous_login'. Use authentication = 'anonymous' instead."); auth_provider = "anonymous"; end -- COMPAT 0.7 @@ -61,8 +61,8 @@ end end); host_session.users = new_null_provider(); -- Start with the default usermanager provider - local auth_provider = config.get(host, "core", "authentication") or default_provider; - if config.get(host, "core", "anonymous_login") then auth_provider = "anonymous"; end -- COMPAT 0.7 + local auth_provider = config.get(host, "authentication") or default_provider; + if config.get(host, "anonymous_login") then auth_provider = "anonymous"; end -- COMPAT 0.7 if auth_provider ~= "null" then modulemanager.load(host, "auth_"..auth_provider); end @@ -116,8 +116,8 @@ jid = jid_bare(jid); host = host or "*"; - local host_admins = config.get(host, "core", "admins"); - local global_admins = config.get("*", "core", "admins"); + local host_admins = config.get(host, "admins"); + local global_admins = config.get("*", "admins"); if host_admins and host_admins ~= global_admins then if type(host_admins) == "table" then diff -r a344c1120e2b -r 30484214d49b plugins/mod_admin_adhoc.lua --- a/plugins/mod_admin_adhoc.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_admin_adhoc.lua Sat Mar 23 04:17:39 2013 +0100 @@ -10,8 +10,7 @@ local hosts = prosody.hosts; local t_concat = table.concat; -local iterators = require "util.iterators"; -local keys, values = iterators.keys, iterators.values; +local keys = require "util.iterators".keys; local usermanager_user_exists = require "core.usermanager".user_exists; local usermanager_create_user = require "core.usermanager".create_user; local usermanager_delete_user = require "core.usermanager".delete_user; @@ -19,9 +18,8 @@ local usermanager_set_password = require "core.usermanager".set_password; local hostmanager_activate = require "core.hostmanager".activate; local hostmanager_deactivate = require "core.hostmanager".deactivate; -local is_admin = require "core.usermanager".is_admin; local rm_load_roster = require "core.rostermanager".load_roster; -local st, jid, uuid = require "util.stanza", require "util.jid", require "util.uuid"; +local st, jid = require "util.stanza", require "util.jid"; local timer_add_task = require "util.timer".add_task; local dataforms_new = require "util.dataforms".new; local array = require "util.array"; diff -r a344c1120e2b -r 30484214d49b plugins/mod_announce.lua --- a/plugins/mod_announce.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_announce.lua Sat Mar 23 04:17:39 2013 +0100 @@ -8,6 +8,7 @@ local st, jid = require "util.stanza", require "util.jid"; +local hosts = prosody.hosts; local is_admin = require "core.usermanager".is_admin; function send_to_online(message, host) diff -r a344c1120e2b -r 30484214d49b plugins/mod_auth_anonymous.lua --- a/plugins/mod_auth_anonymous.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_auth_anonymous.lua Sat Mar 23 04:17:39 2013 +0100 @@ -8,6 +8,7 @@ local new_sasl = require "util.sasl".new; local datamanager = require "util.datamanager"; +local hosts = prosody.hosts; -- define auth provider local provider = {}; diff -r a344c1120e2b -r 30484214d49b plugins/mod_c2s.lua --- a/plugins/mod_c2s.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_c2s.lua Sat Mar 23 04:17:39 2013 +0100 @@ -29,6 +29,7 @@ local sessions = module:shared("sessions"); local core_process_stanza = prosody.core_process_stanza; +local hosts = prosody.hosts; local stream_callbacks = { default_ns = "jabber:client", handlestanza = core_process_stanza }; local listener = {}; diff -r a344c1120e2b -r 30484214d49b plugins/mod_component.lua --- a/plugins/mod_component.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_component.lua Sat Mar 23 04:17:39 2013 +0100 @@ -19,7 +19,7 @@ local uuid_gen = require "util.uuid".generate; local core_process_stanza = prosody.core_process_stanza; - +local hosts = prosody.hosts; local log = module._log; diff -r a344c1120e2b -r 30484214d49b plugins/mod_groups.lua --- a/plugins/mod_groups.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_groups.lua Sat Mar 23 04:17:39 2013 +0100 @@ -80,7 +80,7 @@ end function module.load() - groups_file = config.get(module:get_host(), "core", "groups_file"); + groups_file = module:get_option_string("groups_file"); if not groups_file then return; end module:hook("roster-load", inject_roster_contacts); diff -r a344c1120e2b -r 30484214d49b plugins/mod_http.lua --- a/plugins/mod_http.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_http.lua Sat Mar 23 04:17:39 2013 +0100 @@ -9,6 +9,7 @@ module:set_global(); module:depends("http_errors"); +local portmanager = require "core.portmanager"; local moduleapi = require "core.moduleapi"; local url_parse = require "socket.url".parse; local url_build = require "socket.url".build; diff -r a344c1120e2b -r 30484214d49b plugins/mod_http_errors.lua --- a/plugins/mod_http_errors.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_http_errors.lua Sat Mar 23 04:17:39 2013 +0100 @@ -2,7 +2,6 @@ local server = require "net.http.server"; local codes = require "net.http.codes"; -local termcolours = require "util.termcolours"; local show_private = module:get_option_boolean("http_errors_detailed", false); local always_serve = module:get_option_boolean("http_errors_always_show", true); diff -r a344c1120e2b -r 30484214d49b plugins/mod_iq.lua --- a/plugins/mod_iq.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_iq.lua Sat Mar 23 04:17:39 2013 +0100 @@ -9,7 +9,7 @@ local st = require "util.stanza"; -local full_sessions = full_sessions; +local full_sessions = prosody.full_sessions; if module:get_host_type() == "local" then module:hook("iq/full", function(data) diff -r a344c1120e2b -r 30484214d49b plugins/mod_message.lua --- a/plugins/mod_message.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_message.lua Sat Mar 23 04:17:39 2013 +0100 @@ -7,8 +7,8 @@ -- -local full_sessions = full_sessions; -local bare_sessions = bare_sessions; +local full_sessions = prosody.full_sessions; +local bare_sessions = prosody.bare_sessions; local st = require "util.stanza"; local jid_bare = require "util.jid".bare; diff -r a344c1120e2b -r 30484214d49b plugins/mod_motd.lua --- a/plugins/mod_motd.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_motd.lua Sat Mar 23 04:17:39 2013 +0100 @@ -13,7 +13,6 @@ if not motd_text then return; end -local jid_join = require "util.jid".join; local st = require "util.stanza"; motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n%s+", "\n"); -- Strip indentation from the config diff -r a344c1120e2b -r 30484214d49b plugins/mod_presence.lua --- a/plugins/mod_presence.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_presence.lua Sat Mar 23 04:17:39 2013 +0100 @@ -19,7 +19,9 @@ local jid_split = require "util.jid".split; local jid_bare = require "util.jid".bare; local datetime = require "util.datetime"; -local hosts = hosts; +local hosts = prosody.hosts; +local bare_sessions = prosody.bare_sessions; +local full_sessions = prosody.full_sessions; local NULL = {}; local rostermanager = require "core.rostermanager"; diff -r a344c1120e2b -r 30484214d49b plugins/mod_privacy.lua --- a/plugins/mod_privacy.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_privacy.lua Sat Mar 23 04:17:39 2013 +0100 @@ -9,10 +9,9 @@ module:add_feature("jabber:iq:privacy"); -local prosody = prosody; local st = require "util.stanza"; local datamanager = require "util.datamanager"; -local bare_sessions, full_sessions = bare_sessions, full_sessions; +local bare_sessions, full_sessions = prosody.bare_sessions, prosody.full_sessions; local util_Jid = require "util.jid"; local jid_bare = util_Jid.bare; local jid_split, jid_join = util_Jid.split, util_Jid.join; diff -r a344c1120e2b -r 30484214d49b plugins/mod_private.lua --- a/plugins/mod_private.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_private.lua Sat Mar 23 04:17:39 2013 +0100 @@ -9,7 +9,6 @@ local st = require "util.stanza" -local jid_split = require "util.jid".split; local datamanager = require "util.datamanager" module:add_feature("jabber:iq:private"); diff -r a344c1120e2b -r 30484214d49b plugins/mod_proxy65.lua --- a/plugins/mod_proxy65.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_proxy65.lua Sat Mar 23 04:17:39 2013 +0100 @@ -95,7 +95,7 @@ local proxy_port = next(portmanager.get_active_services():search("proxy65", nil)[1] or {}); local proxy_acl = module:get_option("proxy65_acl"); - -- COMPAT w/pre-0.9 where proxy65_port was specified the components section of the config + -- COMPAT w/pre-0.9 where proxy65_port was specified in the components section of the config local legacy_config = module:get_option_number("proxy65_port"); if legacy_config then module:log("warn", "proxy65_port is deprecated, please put proxy65_ports = { %d } into the global section instead", legacy_config); diff -r a344c1120e2b -r 30484214d49b plugins/mod_register.lua --- a/plugins/mod_register.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_register.lua Sat Mar 23 04:17:39 2013 +0100 @@ -7,7 +7,6 @@ -- -local hosts = _G.hosts; local st = require "util.stanza"; local datamanager = require "util.datamanager"; local dataform_new = require "util.dataforms".new; diff -r a344c1120e2b -r 30484214d49b plugins/mod_roster.lua --- a/plugins/mod_roster.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_roster.lua Sat Mar 23 04:17:39 2013 +0100 @@ -69,7 +69,6 @@ and query.tags[1].attr.jid ~= "pending" then local item = query.tags[1]; local from_node, from_host = jid_split(stanza.attr.from); - local from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID local jid = jid_prep(item.attr.jid); local node, host, resource = jid_split(jid); if not resource and host then diff -r a344c1120e2b -r 30484214d49b plugins/mod_tls.lua --- a/plugins/mod_tls.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/mod_tls.lua Sat Mar 23 04:17:39 2013 +0100 @@ -25,6 +25,7 @@ local global_ssl_ctx = prosody.global_ssl_ctx; +local hosts = prosody.hosts; local host = hosts[module.host]; local function can_do_tls(session) @@ -91,10 +92,10 @@ end); function module.load() - local ssl_config = config.rawget(module.host, "core", "ssl"); + local ssl_config = config.rawget(module.host, "ssl"); if not ssl_config then local base_host = module.host:match("%.(.*)"); - ssl_config = config.get(base_host, "core", "ssl"); + ssl_config = config.get(base_host, "ssl"); end host.ssl_ctx = create_context(host.host, "client", ssl_config); -- for outgoing connections host.ssl_ctx_in = create_context(host.host, "server", ssl_config); -- for incoming connections diff -r a344c1120e2b -r 30484214d49b plugins/muc/mod_muc.lua --- a/plugins/muc/mod_muc.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/plugins/muc/mod_muc.lua Sat Mar 23 04:17:39 2013 +0100 @@ -30,7 +30,7 @@ local uuid_gen = require "util.uuid".generate; local datamanager = require "util.datamanager"; local um_is_admin = require "core.usermanager".is_admin; -local hosts = hosts; +local hosts = prosody.hosts; rooms = {}; local rooms = rooms; diff -r a344c1120e2b -r 30484214d49b util/openssl.lua --- a/util/openssl.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/util/openssl.lua Sat Mar 23 04:17:39 2013 +0100 @@ -100,13 +100,13 @@ if name == certhost or name:sub(-1-#certhost) == "."..certhost then found_matching_hosts = true; self:add_dNSName(name); - --print(name .. "#component_module: " .. (config.get(name, "core", "component_module") or "nil")); - if config.get(name, "core", "component_module") == nil then + --print(name .. "#component_module: " .. (config.get(name, "component_module") or "nil")); + if config.get(name, "component_module") == nil then self:add_sRVName(name, "xmpp-client"); end - --print(name .. "#anonymous_login: " .. tostring(config.get(name, "core", "anonymous_login"))); - if not (config.get(name, "core", "anonymous_login") or - config.get(name, "core", "authentication") == "anonymous") then + --print(name .. "#anonymous_login: " .. tostring(config.get(name, "anonymous_login"))); + if not (config.get(name, "anonymous_login") or + config.get(name, "authentication") == "anonymous") then self:add_sRVName(name, "xmpp-server"); end self:add_xmppAddr(name); diff -r a344c1120e2b -r 30484214d49b util/prosodyctl.lua --- a/util/prosodyctl.lua Fri Mar 22 15:16:43 2013 +0000 +++ b/util/prosodyctl.lua Sat Mar 23 04:17:39 2013 +0100 @@ -182,12 +182,12 @@ end function getpid() - local pidfile = config.get("*", "core", "pidfile"); + local pidfile = config.get("*", "pidfile"); if not pidfile then return false, "no-pidfile"; end - local modules_enabled = set.new(config.get("*", "core", "modules_enabled")); + local modules_enabled = set.new(config.get("*", "modules_enabled")); if not modules_enabled:contains("posix") then return false, "no-posix"; end