Comparison

plugins/mod_compression.lua @ 6056:29cbbe882441

mod_compression: Remove checks for impossible conditions
author Kim Alvefur <zash@zash.se>
date Thu, 03 Apr 2014 23:33:38 +0200
parent 6054:7a5ddbaf758d
child 6057:a3d7b8f4d9c7
comparison
equal deleted inserted replaced
6054:7a5ddbaf758d 6056:29cbbe882441
24 return; 24 return;
25 end 25 end
26 26
27 module:hook("stream-features", function(event) 27 module:hook("stream-features", function(event)
28 local origin, features = event.origin, event.features; 28 local origin, features = event.origin, event.features;
29 if not origin.compressed and (origin.type == "c2s" or origin.type == "s2sin" or origin.type == "s2sout") then 29 if not origin.compressed and origin.type == "c2s" then
30 -- FIXME only advertise compression support when TLS layer has no compression enabled 30 -- FIXME only advertise compression support when TLS layer has no compression enabled
31 features:add_child(compression_stream_feature); 31 features:add_child(compression_stream_feature);
32 end 32 end
33 end); 33 end);
34 34
35 module:hook("s2s-stream-features", function(event) 35 module:hook("s2s-stream-features", function(event)
36 local origin, features = event.origin, event.features; 36 local origin, features = event.origin, event.features;
37 -- FIXME only advertise compression support when TLS layer has no compression enabled 37 -- FIXME only advertise compression support when TLS layer has no compression enabled
38 if not origin.compressed and (origin.type == "c2s" or origin.type == "s2sin" or origin.type == "s2sout") then 38 if not origin.compressed and origin.type == "s2sin" then
39 features:add_child(compression_stream_feature); 39 features:add_child(compression_stream_feature);
40 end 40 end
41 end); 41 end);
42 42
43 -- Hook to activate compression if remote server supports it. 43 -- Hook to activate compression if remote server supports it.
44 module:hook_stanza(xmlns_stream, "features", 44 module:hook_stanza(xmlns_stream, "features",
45 function (session, stanza) 45 function (session, stanza)
46 if not session.compressed and (session.type == "c2s" or session.type == "s2sin" or session.type == "s2sout") then 46 if not session.compressed and session.type == "s2sout" then
47 -- does remote server support compression? 47 -- does remote server support compression?
48 local comp_st = stanza:child_with_name("compression"); 48 local comp_st = stanza:child_with_name("compression");
49 if comp_st then 49 if comp_st then
50 -- do we support the mechanism 50 -- do we support the mechanism
51 for a in comp_st:children() do 51 for a in comp_st:children() do