Software /
code /
prosody
Changeset
2888:ab6dac843e9c
Merge with 0.7
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 17 Mar 2010 14:36:23 +0000 |
parents | 2881:4e6c6b1ddce7 (current diff) 2887:765e7070d0a8 (diff) |
children | 2893:98cbc092c64c 2894:066c199135d5 |
files | |
diffstat | 1 files changed, 16 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_compression.lua Mon Mar 15 23:02:16 2010 -0700 +++ b/plugins/mod_compression.lua Wed Mar 17 14:36:23 2010 +0000 @@ -8,6 +8,8 @@ local st = require "util.stanza"; local zlib = require "zlib"; local pcall = pcall; +local tostring = tostring; + local xmlns_compression_feature = "http://jabber.org/features/compress" local xmlns_compression_protocol = "http://jabber.org/protocol/compress" local xmlns_stream = "http://etherx.jabber.org/streams"; @@ -71,7 +73,7 @@ local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"); (session.sends2s or session.send)(error_st); session.log("error", "Failed to create zlib.deflate filter."); - module:log("error", deflate_stream); + module:log("error", "%s", tostring(deflate_stream)); return end return deflate_stream @@ -83,8 +85,8 @@ if status == false then local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"); (session.sends2s or session.send)(error_st); - session.log("error", "Failed to create zlib.deflate filter."); - module:log("error", inflate_stream); + session.log("error", "Failed to create zlib.inflate filter."); + module:log("error", "%s", tostring(inflate_stream)); return end return inflate_stream @@ -104,7 +106,7 @@ text = compressed; extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); }); - module:log("warn", compressed); + module:log("warn", "%s", tostring(compressed)); return; end session.conn:write(compressed); @@ -125,7 +127,7 @@ text = decompressed; extra = st.stanza("failure", {xmlns="http://jabber.org/protocol/compress"}):tag("processing-failed"); }); - module:log("warn", decompressed); + module:log("warn", "%s", tostring(decompressed)); return; end old_data(conn, decompressed); @@ -166,15 +168,17 @@ function(session, stanza) -- fail if we are already compressed if session.compressed then - local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("unsupported-method"); + local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"); (session.sends2s or session.send)(error_st); session.log("warn", "Tried to establish another compression layer."); + return; end -- checking if the compression method is supported - local method = stanza:child_with_name("method")[1]; + local method = stanza:child_with_name("method"); + method = method and (method[1] or ""); if method == "zlib" then - session.log("debug", method.." compression selected."); + session.log("debug", "%s compression selected.", tostring(method)); -- create deflate and inflate streams local deflate_stream = get_deflate_stream(session); @@ -199,10 +203,12 @@ return true; end; session.compressed = true; - else - session.log("warn", method.." compression selected. But we don't support it."); + elseif method then + session.log("info", "%s compression selected, but we don't support it.", tostring(method)); local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("unsupported-method"); (session.sends2s or session.send)(error_st); + else + (session.sends2s or session.send)(st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed")); end end );