From df5bec6e971a0e0f2dda68eb97e3c39e80114f68 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 7 Jan 2011 03:46:10 +0000 Subject: mod_motd: Process value to strip any indentation from the config --- plugins/mod_motd.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/mod_motd.lua b/plugins/mod_motd.lua index f323e606..462670e6 100644 --- a/plugins/mod_motd.lua +++ b/plugins/mod_motd.lua @@ -13,6 +13,8 @@ local motd_jid = module:get_option("motd_jid") or host; local st = require "util.stanza"; +motd_text = motd_text:gsub("^%s*(.-)%s*$", "%1"):gsub("\n%s+", "\n"); -- Strip indentation from the config + module:hook("resource-bind", function (event) local session = event.session; -- cgit v1.2.3 From 63e8a974377169b294a43888ab0e076449c8facb Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 7 Jan 2011 03:47:15 +0000 Subject: prosody.cfg.lua.dist: Add motd plugin --- prosody.cfg.lua.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/prosody.cfg.lua.dist b/prosody.cfg.lua.dist index 3134acb6..75c473a3 100644 --- a/prosody.cfg.lua.dist +++ b/prosody.cfg.lua.dist @@ -66,6 +66,7 @@ modules_enabled = { --"announce"; -- Send announcement to all online users --"welcome"; -- Welcome users who register accounts --"watchregistrations"; -- Alert admins of registrations + --"motd"; -- Send a message to users when they log in }; -- These modules are auto-loaded, should you -- cgit v1.2.3 From 909cdebf943ad24ce00d5d50e630994ba08a47ec Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 7 Jan 2011 04:22:28 +0000 Subject: storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code --- core/storagemanager.lua | 52 +++++++++++++--------------------------- plugins/mod_storage_internal.lua | 19 +++++++++++++++ 2 files changed, 36 insertions(+), 35 deletions(-) create mode 100644 plugins/mod_storage_internal.lua diff --git a/core/storagemanager.lua b/core/storagemanager.lua index 35fef503..e44f3e2c 100644 --- a/core/storagemanager.lua +++ b/core/storagemanager.lua @@ -1,5 +1,5 @@ -local error, type = error, type; +local error, type, pairs = error, type, pairs; local setmetatable = setmetatable; local config = require "core.configmanager"; @@ -9,12 +9,14 @@ local multitable = require "util.multitable"; local hosts = hosts; local log = require "util.logger".init("storagemanager"); -local olddm = {}; -- maintain old datamanager, for backwards compatibility -for k,v in pairs(datamanager) do olddm[k] = v; end local prosody = prosody; module("storagemanager") +local olddm = {}; -- maintain old datamanager, for backwards compatibility +for k,v in pairs(datamanager) do olddm[k] = v; end +_M.olddm = olddm; + local null_storage_method = function () return false, "no data storage active"; end local null_storage_driver = setmetatable( { @@ -27,15 +29,6 @@ local null_storage_driver = setmetatable( } ); ---TODO: Move default driver to mod_auth_internal -local default_driver_mt = { name = "internal" }; -default_driver_mt.__index = default_driver_mt; -function default_driver_mt:open(store) - return setmetatable({ host = self.host, store = store }, default_driver_mt); -end -function default_driver_mt:get(user) return olddm.load(user, self.host, self.store); end -function default_driver_mt:set(user, data) return olddm.store(user, self.host, self.store, data); end - local stores_available = multitable.new(); function initialize_host(host) @@ -53,20 +46,16 @@ end prosody.events.add_handler("host-activated", initialize_host, 101); local function load_driver(host, driver_name) - if not driver_name then - return; + if driver_name == "null" then + return null_storage_provider; end local driver = stores_available:get(host, driver_name); if driver then return driver; end - if driver_name ~= "internal" then - local ok, err = modulemanager.load(host, "storage_"..driver_name); - if not ok then - log("error", "Failed to load storage driver plugin %s on %s: %s", driver_name, host, err); - end - return stores_available:get(host, driver_name); - else - return setmetatable({host = host}, default_driver_mt); + local ok, err = modulemanager.load(host, "storage_"..driver_name); + if not ok then + log("error", "Failed to load storage driver plugin %s on %s: %s", driver_name, host, err); end + return stores_available:get(host, driver_name); end function open(host, store, typ) @@ -78,22 +67,15 @@ function open(host, store, typ) elseif option_type == "table" then driver_name = storage[store]; end + if not driver_name then + driver_name = config.get(host, "core", "default_storage") or "internal"; + end local driver = load_driver(host, driver_name); if not driver then - driver_name = config.get(host, "core", "default_storage"); - driver = load_driver(host, driver_name); - if not driver then - if driver_name or (type(storage) == "string" - or type(storage) == "table" and storage[store]) then - log("warn", "Falling back to null driver for %s storage on %s", store, host); - driver_name = "null"; - driver = null_storage_driver; - else - driver_name = "internal"; - driver = load_driver(host, driver_name); - end - end + log("warn", "Falling back to null driver for %s storage on %s", store, host); + driver_name = "null"; + driver = null_storage_driver; end local ret, err = driver:open(store, typ); diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua new file mode 100644 index 00000000..821d1e1a --- /dev/null +++ b/plugins/mod_storage_internal.lua @@ -0,0 +1,19 @@ +local datamanager = require "core.storagemanager".olddm; + +local host = module.host; + +local driver = { name = "internal" }; +local driver_mt = { __index = driver }; + +function driver:open(store) + return setmetatable({ store = store }, driver_mt); +end +function driver:get(user) + return datamanager.load(user, host, self.store); +end + +function driver:set(user, data) + return datamanager.store(user, host, self.store, data); +end + +module:add_item("data-driver", driver); -- cgit v1.2.3 From 0b78691f9e8ee178e2d68cc16c0c7db9c0b80d81 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 7 Jan 2011 04:32:27 +0000 Subject: prosody.cfg.lua.dist: Add note about the require_encryption options --- prosody.cfg.lua.dist | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prosody.cfg.lua.dist b/prosody.cfg.lua.dist index 75c473a3..ad533104 100644 --- a/prosody.cfg.lua.dist +++ b/prosody.cfg.lua.dist @@ -89,7 +89,12 @@ ssl = { certificate = "certs/localhost.cert"; } --- Require encryption on client/server connections? +-- Only allow encrypted streams? Encryption is already used when +-- available. These options will cause Prosody to deny connections that +-- are not encrypted. Note that some servers do not support s2s +-- encryption or have it disabled, including gmail.com and Google Apps +-- domains. + --c2s_require_encryption = false --s2s_require_encryption = false -- cgit v1.2.3 From 74408ff9f5ed48bfd4125729e2bdada3f19356be Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 7 Jan 2011 04:41:34 +0000 Subject: prosody.cfg.lua.dist: Update to include storage configuration and examples for SQL --- prosody.cfg.lua.dist | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/prosody.cfg.lua.dist b/prosody.cfg.lua.dist index ad533104..41850537 100644 --- a/prosody.cfg.lua.dist +++ b/prosody.cfg.lua.dist @@ -98,6 +98,18 @@ ssl = { --c2s_require_encryption = false --s2s_require_encryption = false +-- Select the storage backend to use. By default Prosody uses flat files +-- in its configured data directory, but it also supports more backends +-- through modules. An "sql" backend is included by default, but requires +-- additional dependencies. See http://prosody.im/doc/storage for more info. + +--storage = "sql" -- Default is "internal" + +-- For the "sql" backend, you can uncomment *one* of the below to configure: +--sql = { driver = "SQLite3", database = "prosody.sqlite" } -- Default. 'database' is the filename. +--sql = { driver = "MySQL", database = "prosody", username = "prosody", password = "secret", host = "localhost" } +--sql = { driver = "PostgreSQL", database = "prosody", username = "prosody", password = "secret", host = "localhost" } + -- Logging configuration -- For advanced logging see http://prosody.im/doc/logging log = { -- cgit v1.2.3