plugins: Use integer config API with interval specification where sensible
authorKim Alvefur <zash@zash.se>
Mon, 17 Jul 2023 01:38:54 +0200
changeset 13217 50324f66ca2a
parent 13216 3e6e98cc63e9
child 13218 5022525364f6
plugins: Use integer config API with interval specification where sensible Many of these fall into a few categories: - util.cache size, must be >= 1 - byte or item counts that logically can't be negative - port numbers that should be in 1..0xffff
plugins/mod_auth_internal_hashed.lua
plugins/mod_blocklist.lua
plugins/mod_bosh.lua
plugins/mod_c2s.lua
plugins/mod_component.lua
plugins/mod_csi_simple.lua
plugins/mod_external_services.lua
plugins/mod_http.lua
plugins/mod_http_file_share.lua
plugins/mod_http_files.lua
plugins/mod_mam/mod_mam.lua
plugins/mod_muc_mam.lua
plugins/mod_net_multiplex.lua
plugins/mod_pep.lua
plugins/mod_pubsub/mod_pubsub.lua
plugins/mod_register_limits.lua
plugins/mod_s2s.lua
plugins/mod_smacks.lua
plugins/mod_storage_internal.lua
plugins/mod_storage_memory.lua
plugins/mod_storage_sql.lua
plugins/mod_tombstones.lua
plugins/mod_turn_external.lua
plugins/mod_websocket.lua
plugins/muc/history.lib.lua
plugins/muc/mod_muc.lua
--- a/plugins/mod_auth_internal_hashed.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_auth_internal_hashed.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -27,7 +27,7 @@
 local scram_name = "scram_"..hash_name:gsub("%-","_"):lower();
 
 -- Default; can be set per-user
-local default_iteration_count = module:get_option_number("default_iteration_count", 10000);
+local default_iteration_count = module:get_option_integer("default_iteration_count", 10000, 4096);
 
 local tokenauth = module:depends("tokenauth");
 
--- a/plugins/mod_blocklist.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_blocklist.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -35,7 +35,7 @@
 -- disk, which we want to avoid during routing. On the other hand, we don't
 -- want to use too much memory either, so this can be tuned by advanced
 -- users. TODO use science to figure out a better default, 64 is just a guess.
-local cache_size = module:get_option_number("blocklist_cache_size", 64);
+local cache_size = module:get_option_integer("blocklist_cache_size", 64, 1);
 local cache2 = require"prosody.util.cache".new(cache_size);
 
 local null_blocklist = {};
--- a/plugins/mod_bosh.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_bosh.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -45,7 +45,7 @@
 
 local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure");
 local cross_domain = module:get_option("cross_domain_bosh");
-local stanza_size_limit = module:get_option_number("c2s_stanza_size_limit", 1024*256);
+local stanza_size_limit = module:get_option_integer("c2s_stanza_size_limit", 1024*256, 10000);
 
 if cross_domain ~= nil then
 	module:log("info", "The 'cross_domain_bosh' option has been deprecated");
--- a/plugins/mod_c2s.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_c2s.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -28,7 +28,7 @@
 local c2s_timeout = module:get_option_period("c2s_timeout", "5 minutes");
 local stream_close_timeout = module:get_option_period("c2s_close_timeout", 5);
 local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true));
-local stanza_size_limit = module:get_option_number("c2s_stanza_size_limit", 1024*256);
+local stanza_size_limit = module:get_option_integer("c2s_stanza_size_limit", 1024*256,10000);
 
 local measure_connections = module:metric("gauge", "connections", "", "Established c2s connections", {"host", "type", "ip_family"});
 
--- a/plugins/mod_component.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_component.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -27,7 +27,8 @@
 local log = module._log;
 
 local opt_keepalives = module:get_option_boolean("component_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true));
-local stanza_size_limit = module:get_option_number("component_stanza_size_limit", module:get_option_number("s2s_stanza_size_limit", 1024*512));
+local stanza_size_limit = module:get_option_integer("component_stanza_size_limit",
+	module:get_option_integer("s2s_stanza_size_limit", 1024 * 512, 10000), 10000);
 
 local sessions = module:shared("sessions");
 
--- a/plugins/mod_csi_simple.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_csi_simple.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -12,7 +12,7 @@
 local filters = require "prosody.util.filters";
 local timer = require "prosody.util.timer";
 
-local queue_size = module:get_option_number("csi_queue_size", 256);
+local queue_size = module:get_option_integer("csi_queue_size", 256, 1);
 local resume_delay = module:get_option_period("csi_resume_inactive_delay", 5);
 
 local important_payloads = module:get_option_set("csi_important_payloads", { });
--- a/plugins/mod_external_services.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_external_services.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -8,7 +8,7 @@
 local set = require "prosody.util.set";
 
 local default_host = module:get_option_string("external_service_host", module.host);
-local default_port = module:get_option_number("external_service_port");
+local default_port = module:get_option_integer("external_service_port", nil, 1, 65535);
 local default_secret = module:get_option_string("external_service_secret");
 local default_ttl = module:get_option_period("external_service_ttl", "1 day");
 
--- a/plugins/mod_http.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_http.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -29,8 +29,8 @@
 
 server.set_default_host(module:get_option_string("http_default_host"));
 
-server.set_option("body_size_limit", module:get_option_number("http_max_content_size"));
-server.set_option("buffer_size_limit", module:get_option_number("http_max_buffer_size"));
+server.set_option("body_size_limit", module:get_option_number("http_max_content_size", 0));
+server.set_option("buffer_size_limit", module:get_option_number("http_max_buffer_size", 0));
 
 -- CORS settings
 local cors_overrides = module:get_option("http_cors_override", {});
--- a/plugins/mod_http_file_share.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_http_file_share.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -36,12 +36,12 @@
 
 local secret = module:get_option_string(module.name.."_secret", require"prosody.util.id".long());
 local external_base_url = module:get_option_string(module.name .. "_base_url");
-local file_size_limit = module:get_option_number(module.name .. "_size_limit", 10 * 1024 * 1024); -- 10 MB
+local file_size_limit = module:get_option_integer(module.name .. "_size_limit", 10 * 1024 * 1024, 0); -- 10 MB
 local file_types = module:get_option_set(module.name .. "_allowed_file_types", {});
 local safe_types = module:get_option_set(module.name .. "_safe_file_types", {"image/*","video/*","audio/*","text/plain"});
 local expiry = module:get_option_period(module.name .. "_expires_after", "1w");
-local daily_quota = module:get_option_number(module.name .. "_daily_quota", file_size_limit*10); -- 100 MB / day
-local total_storage_limit = module:get_option_number(module.name.."_global_quota", unlimited);
+local daily_quota = module:get_option_integer(module.name .. "_daily_quota", file_size_limit*10, 0); -- 100 MB / day
+local total_storage_limit = module:get_option_integer(module.name.."_global_quota", unlimited, 0);
 
 local create_jwt, verify_jwt = require"prosody.util.jwt".init("HS256", secret, secret, { default_ttl = 600 });
 
--- a/plugins/mod_http_files.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_http_files.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -12,8 +12,8 @@
 local fileserver = require"prosody.net.http.files";
 
 local base_path = module:get_option_path("http_files_dir", module:get_option_path("http_path"));
-local cache_size = module:get_option_number("http_files_cache_size", 128);
-local cache_max_file_size = module:get_option_number("http_files_cache_max_file_size", 4096);
+local cache_size = module:get_option_integer("http_files_cache_size", 128, 1);
+local cache_max_file_size = module:get_option_integer("http_files_cache_max_file_size", 4096, 1);
 local dir_indices = module:get_option_array("http_index_files", { "index.html", "index.htm" });
 local directory_index = module:get_option_boolean("http_dir_listing");
 
--- a/plugins/mod_mam/mod_mam.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_mam/mod_mam.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -37,14 +37,14 @@
 local time_now = require "prosody.util.time".now;
 local m_min = math.min;
 local timestamp, datestamp = import( "util.datetime", "datetime", "date");
-local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50);
+local default_max_items, max_max_items = 20, module:get_option_integer("max_archive_query_results", 50, 0);
 local strip_tags = module:get_option_set("dont_archive_namespaces", { "http://jabber.org/protocol/chatstates" });
 
 local archive_store = module:get_option_string("archive_store", "archive");
 local archive = module:open_store(archive_store, "archive");
 
 local cleanup_after = module:get_option_period("archive_expires_after", "1w");
-local archive_item_limit = module:get_option_number("storage_archive_item_limit", archive.caps and archive.caps.quota or 1000);
+local archive_item_limit = module:get_option_integer("storage_archive_item_limit", archive.caps and archive.caps.quota or 1000, 0);
 local archive_truncate = math.floor(archive_item_limit * 0.99);
 
 if not archive.find then
@@ -522,7 +522,7 @@
 	-- outside the cleanup range.
 
 	if not (archive.caps and archive.caps.wildcard_delete) then
-		local last_date = require "prosody.util.cache".new(module:get_option_number("archive_cleanup_date_cache_size", 1000));
+		local last_date = require "prosody.util.cache".new(module:get_option_integer("archive_cleanup_date_cache_size", 1000, 1));
 		function schedule_cleanup(username, date)
 			date = date or datestamp();
 			if last_date:get(username) == date then return end
--- a/plugins/mod_muc_mam.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_muc_mam.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -32,12 +32,12 @@
 local time_now = require "prosody.util.time".now;
 local m_min = math.min;
 local timestamp, datestamp = import("prosody.util.datetime", "datetime", "date");
-local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50);
+local default_max_items, max_max_items = 20, module:get_option_integer("max_archive_query_results", 50, 0);
 
 local cleanup_after = module:get_option_string("muc_log_expires_after", "1w");
 
 local default_history_length = 20;
-local max_history_length = module:get_option_number("max_history_messages", math.huge);
+local max_history_length = module:get_option_integer("max_history_messages", math.huge, 0);
 
 local function get_historylength(room)
 	return math.min(room._data.history_length or default_history_length, max_history_length);
@@ -53,7 +53,7 @@
 local archive_store = "muc_log";
 local archive = module:open_store(archive_store, "archive");
 
-local archive_item_limit = module:get_option_number("storage_archive_item_limit", archive.caps and archive.caps.quota or 1000);
+local archive_item_limit = module:get_option_integer("storage_archive_item_limit", archive.caps and archive.caps.quota or 1000, 0);
 local archive_truncate = math.floor(archive_item_limit * 0.99);
 
 if archive.name == "null" or not archive.find then
@@ -492,7 +492,7 @@
 	-- messages, we collect the union of sets of rooms from dates that fall
 	-- outside the cleanup range.
 
-	local last_date = require "prosody.util.cache".new(module:get_option_number("muc_log_cleanup_date_cache_size", 1000));
+	local last_date = require "prosody.util.cache".new(module:get_option_integer("muc_log_cleanup_date_cache_size", 1000, 1));
 	if not ( archive.caps and archive.caps.wildcard_delete ) then
 		function schedule_cleanup(roomname, date)
 			date = date or datestamp();
--- a/plugins/mod_net_multiplex.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_net_multiplex.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -1,8 +1,8 @@
 module:set_global();
 
 local array = require "prosody.util.array";
-local max_buffer_len = module:get_option_number("multiplex_buffer_size", 1024);
-local default_mode = module:get_option_number("network_default_read_size", 4096);
+local max_buffer_len = module:get_option_integer("multiplex_buffer_size", 1024, 1);
+local default_mode = module:get_option_integer("network_default_read_size", 4096, 0);
 
 local portmanager = require "prosody.core.portmanager";
 
--- a/plugins/mod_pep.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_pep.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -24,7 +24,7 @@
 local pep_service_items = {};
 
 -- size of caches with full pubsub service objects
-local service_cache_size = module:get_option_number("pep_service_cache_size", 1000);
+local service_cache_size = module:get_option_integer("pep_service_cache_size", 1000, 1);
 
 -- username -> util.pubsub service object
 local services = cache.new(service_cache_size, function (username, _)
@@ -36,7 +36,7 @@
 end):table();
 
 -- size of caches with smaller objects
-local info_cache_size = module:get_option_number("pep_info_cache_size", 10000);
+local info_cache_size = module:get_option_integer("pep_info_cache_size", 10000, 1);
 
 -- username -> recipient -> set of nodes
 local recipients = cache.new(info_cache_size):table();
@@ -49,7 +49,7 @@
 local node_config = module:open_store("pep", "map");
 local known_nodes = module:open_store("pep");
 
-local max_max_items = module:get_option_number("pep_max_items", 256);
+local max_max_items = module:get_option_number("pep_max_items", 256, 0);
 
 local function tonumber_max_items(n)
 	if n == "max" then
--- a/plugins/mod_pubsub/mod_pubsub.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_pubsub/mod_pubsub.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -39,7 +39,7 @@
 --   get(node_name)
 --   users(): iterator over (node_name)
 
-local max_max_items = module:get_option_number("pubsub_max_items", 256);
+local max_max_items = module:get_option_integer("pubsub_max_items", 256, 1);
 
 local function tonumber_max_items(n)
 	if n == "max" then
--- a/plugins/mod_register_limits.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_register_limits.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -21,9 +21,9 @@
 local allowlisted_ips = module:get_option_set("registration_allowlist", module:get_option("registration_whitelist", { "127.0.0.1", "::1" }))._items;
 local blocklisted_ips = module:get_option_set("registration_blocklist", module:get_option_set("registration_blacklist", {}))._items;
 
-local throttle_max = module:get_option_number("registration_throttle_max", min_seconds_between_registrations and 1);
+local throttle_max = module:get_option_number("registration_throttle_max", min_seconds_between_registrations and 1, 0);
 local throttle_period = module:get_option_period("registration_throttle_period", min_seconds_between_registrations);
-local throttle_cache_size = module:get_option_number("registration_throttle_cache_size", 100);
+local throttle_cache_size = module:get_option_integer("registration_throttle_cache_size", 100, 1);
 local blocklist_overflow = module:get_option_boolean("blocklist_on_registration_throttle_overload",
 	module:get_option_boolean("blacklist_on_registration_throttle_overload", false));
 
--- a/plugins/mod_s2s.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_s2s.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -41,7 +41,7 @@
 local secure_domains, insecure_domains =
 	module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items;
 local require_encryption = module:get_option_boolean("s2s_require_encryption", true);
-local stanza_size_limit = module:get_option_number("s2s_stanza_size_limit", 1024*512);
+local stanza_size_limit = module:get_option_integer("s2s_stanza_size_limit", 1024*512, 10000);
 
 local measure_connections_inbound = module:metric(
 	"gauge", "connections_inbound", "",
--- a/plugins/mod_smacks.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_smacks.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -66,14 +66,14 @@
 local sm2_attr = { xmlns = xmlns_sm2 };
 local sm3_attr = { xmlns = xmlns_sm3 };
 
-local queue_size = module:get_option_number("smacks_max_queue_size", 500);
+local queue_size = module:get_option_integer("smacks_max_queue_size", 500, 1);
 local resume_timeout = module:get_option_period("smacks_hibernation_time", "10 minutes");
 local s2s_smacks = module:get_option_boolean("smacks_enabled_s2s", true);
 local s2s_resend = module:get_option_boolean("smacks_s2s_resend", false);
-local max_unacked_stanzas = module:get_option_number("smacks_max_unacked_stanzas", 0);
-local max_inactive_unacked_stanzas = module:get_option_number("smacks_max_inactive_unacked_stanzas", 256);
+local max_unacked_stanzas = module:get_option_integer("smacks_max_unacked_stanzas", 0, 0);
+local max_inactive_unacked_stanzas = module:get_option_integer("smacks_max_inactive_unacked_stanzas", 256, 0);
 local delayed_ack_timeout = module:get_option_period("smacks_max_ack_delay", 30);
-local max_old_sessions = module:get_option_number("smacks_max_old_sessions", 10);
+local max_old_sessions = module:get_option_integer("smacks_max_old_sessions", 10, 0);
 
 local c2s_sessions = module:shared("/*/c2s/sessions");
 local local_sessions = prosody.hosts[module.host].sessions;
--- a/plugins/mod_storage_internal.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_storage_internal.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -11,7 +11,7 @@
 
 local host = module.host;
 
-local archive_item_limit = module:get_option_number("storage_archive_item_limit", 10000);
+local archive_item_limit = module:get_option_integer("storage_archive_item_limit", 10000, 0);
 local archive_item_count_cache = cache.new(module:get_option("storage_archive_item_limit_cache_size", 1000));
 
 local use_shift = module:get_option_boolean("storage_archive_experimental_fast_delete", false);
--- a/plugins/mod_storage_memory.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_storage_memory.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -9,7 +9,7 @@
 local auto_purge_enabled = module:get_option_boolean("storage_memory_temporary", false);
 local auto_purge_stores = module:get_option_set("storage_memory_temporary_stores", {});
 
-local archive_item_limit = module:get_option_number("storage_archive_item_limit", 1000);
+local archive_item_limit = module:get_option_integer("storage_archive_item_limit", 1000, 0);
 
 local memory = setmetatable({}, {
 	__index = function(t, k)
--- a/plugins/mod_storage_sql.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_storage_sql.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -152,7 +152,7 @@
 
 --- Archive store API
 
-local archive_item_limit = module:get_option_number("storage_archive_item_limit");
+local archive_item_limit = module:get_option_integer("storage_archive_item_limit", nil, 0);
 local archive_item_count_cache = cache.new(module:get_option("storage_archive_item_limit_cache_size", 1000));
 
 local item_count_cache_hit = module:measure("item_count_cache_hit", "rate");
--- a/plugins/mod_tombstones.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_tombstones.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -8,7 +8,7 @@
 -- Using a map store as key-value store so that removal of all user data
 -- does not also remove the tombstone, which would defeat the point
 local graveyard = module:open_store(nil, "map");
-local graveyard_cache = require "prosody.util.cache".new(module:get_option_number("tombstone_cache_size", 1024));
+local graveyard_cache = require "prosody.util.cache".new(module:get_option_integer("tombstone_cache_size", 1024, 1));
 
 local ttl = module:get_option_period("user_tombstone_expiry", nil);
 -- Keep tombstones forever by default
--- a/plugins/mod_turn_external.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_turn_external.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -3,10 +3,10 @@
 local secret = module:get_option_string("turn_external_secret");
 local host = module:get_option_string("turn_external_host", module.host);
 local user = module:get_option_string("turn_external_user");
-local port = module:get_option_number("turn_external_port", 3478);
+local port = module:get_option_integer("turn_external_port", 3478, 1, 65535);
 local ttl = module:get_option_period("turn_external_ttl", "1 day");
 local tcp = module:get_option_boolean("turn_external_tcp", false);
-local tls_port = module:get_option_number("turn_external_tls_port");
+local tls_port = module:get_option_integer("turn_external_tls_port", nil, 1, 65535);
 
 if not secret then
 	module:log_status("error", "Failed to initialize: the 'turn_external_secret' option is not set in your configuration");
--- a/plugins/mod_websocket.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/mod_websocket.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -28,9 +28,9 @@
 
 local t_concat = table.concat;
 
-local stanza_size_limit = module:get_option_number("c2s_stanza_size_limit", 1024 * 256);
-local frame_buffer_limit = module:get_option_number("websocket_frame_buffer_limit", 2 * stanza_size_limit);
-local frame_fragment_limit = module:get_option_number("websocket_frame_fragment_limit", 8);
+local stanza_size_limit = module:get_option_integer("c2s_stanza_size_limit", 1024 * 256, 10000);
+local frame_buffer_limit = module:get_option_integer("websocket_frame_buffer_limit", 2 * stanza_size_limit, 0);
+local frame_fragment_limit = module:get_option_integer("websocket_frame_fragment_limit", 8, 0);
 local stream_close_timeout = module:get_option_period("c2s_close_timeout", 5);
 local consider_websocket_secure = module:get_option_boolean("consider_websocket_secure");
 local cross_domain = module:get_option("cross_domain_websocket");
--- a/plugins/muc/history.lib.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/muc/history.lib.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -12,7 +12,7 @@
 local st = require "prosody.util.stanza";
 
 local default_history_length = 20;
-local max_history_length = module:get_option_number("max_history_messages", math.huge);
+local max_history_length = module:get_option_integer("max_history_messages", math.huge, 0);
 
 local function set_max_history_length(_max_history_length)
 	max_history_length = _max_history_length or math.huge;
--- a/plugins/muc/mod_muc.lua	Mon Jul 17 00:37:44 2023 +0200
+++ b/plugins/muc/mod_muc.lua	Mon Jul 17 01:38:54 2023 +0200
@@ -159,8 +159,8 @@
 	end
 end
 
-local max_rooms = module:get_option_number("muc_max_rooms");
-local max_live_rooms = module:get_option_number("muc_room_cache_size", 100);
+local max_rooms = module:get_option_integer("muc_max_rooms", nil, 0);
+local max_live_rooms = module:get_option_integer("muc_room_cache_size", 100, 1);
 
 local room_hit = module:measure("room_hit", "rate");
 local room_miss = module:measure("room_miss", "rate")
@@ -288,7 +288,7 @@
 	room:set_whois(module:get_option_boolean("muc_room_default_public_jids",
 		room:get_whois() == "anyone") and "anyone" or "moderators");
 	room:set_changesubject(module:get_option_boolean("muc_room_default_change_subject", room:get_changesubject()));
-	room:set_historylength(module:get_option_number("muc_room_default_history_length", room:get_historylength()));
+	room:set_historylength(module:get_option_integer("muc_room_default_history_length", room:get_historylength(), 0));
 	room:set_language(lang or module:get_option_string("muc_room_default_language"));
 	room:set_presence_broadcast(module:get_option("muc_room_default_presence_broadcast", room:get_presence_broadcast()));
 end