Software /
code /
prosody
Comparison
plugins/mod_compression.lua @ 4480:187ce118aea6
mod_compression: Use get_option_number
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 19 Jan 2012 16:38:04 +0100 |
parent | 3540:bc139431830b |
child | 4481:408c2f688e4e |
comparison
equal
deleted
inserted
replaced
4479:d1ddfc4709ce | 4480:187ce118aea6 |
---|---|
14 local xmlns_compression_protocol = "http://jabber.org/protocol/compress" | 14 local xmlns_compression_protocol = "http://jabber.org/protocol/compress" |
15 local xmlns_stream = "http://etherx.jabber.org/streams"; | 15 local xmlns_stream = "http://etherx.jabber.org/streams"; |
16 local compression_stream_feature = st.stanza("compression", {xmlns=xmlns_compression_feature}):tag("method"):text("zlib"):up(); | 16 local compression_stream_feature = st.stanza("compression", {xmlns=xmlns_compression_feature}):tag("method"):text("zlib"):up(); |
17 local add_filter = require "util.filters".add_filter; | 17 local add_filter = require "util.filters".add_filter; |
18 | 18 |
19 local compression_level = module:get_option("compression_level"); | 19 local compression_level = module:get_option_number("compression_level", 9); |
20 -- if not defined assume admin wants best compression | |
21 if compression_level == nil then compression_level = 9 end; | |
22 | 20 |
23 | |
24 compression_level = tonumber(compression_level); | |
25 if not compression_level or compression_level < 1 or compression_level > 9 then | 21 if not compression_level or compression_level < 1 or compression_level > 9 then |
26 module:log("warn", "Invalid compression level in config: %s", tostring(compression_level)); | 22 module:log("warn", "Invalid compression level in config: %s", tostring(compression_level)); |
27 module:log("warn", "Module loading aborted. Compression won't be available."); | 23 module:log("warn", "Module loading aborted. Compression won't be available."); |
28 return; | 24 return; |
29 end | 25 end |