Changeset

1676:719350956714

Add config option handling.
author Tobias Markmann <tm@ayena.de>
date Thu, 13 Aug 2009 11:56:22 +0200
parents 1675:bddd5ef9565e
children 1677:f0961ce9830c
files plugins/mod_compression.lua
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_compression.lua	Thu Aug 13 11:35:50 2009 +0200
+++ b/plugins/mod_compression.lua	Thu Aug 13 11:56:22 2009 +0200
@@ -13,6 +13,17 @@
 local xmlns_compression_protocol = "http://jabber.org/protocol/compress"
 local compression_stream_feature = st.stanza("compression", {xmlns=xmlns_compression_feature}):tag("method"):text("zlib"):up();
 
+local compression_level = module:get_option("compression_level");
+
+-- if not defined assume admin wants best compression
+if compression_level == nil then compression_level = 9 end;
+
+compression_level = tonumber(compression_level);
+if not compression_level or compression_level < 1 or compression_level > 9 then
+	module:log("warn", "Invalid compression level in config: %s", tostring(compression_level));
+	module:log("warn", "Module loading aborted. Compression won't be available.");
+	return;
+end
 
 module:add_event_hook("stream-features",
 		function (session, features)