Software /
code /
prosody
Comparison
plugins/mod_compression.lua @ 6055:596539a30e9b
Merge 0.10->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 02 Apr 2014 17:42:22 +0100 |
parent | 6054:7a5ddbaf758d |
child | 6056:29cbbe882441 |
comparison
equal
deleted
inserted
replaced
6039:f8df0a996575 | 6055:596539a30e9b |
---|---|
123 end); | 123 end); |
124 end | 124 end |
125 | 125 |
126 module:hook("stanza/http://jabber.org/protocol/compress:compressed", function(event) | 126 module:hook("stanza/http://jabber.org/protocol/compress:compressed", function(event) |
127 local session = event.origin; | 127 local session = event.origin; |
128 | 128 |
129 if session.type == "s2sout_unauthed" or session.type == "s2sout" then | 129 if session.type == "s2sout" then |
130 session.log("debug", "Activating compression...") | 130 session.log("debug", "Activating compression...") |
131 -- create deflate and inflate streams | 131 -- create deflate and inflate streams |
132 local deflate_stream = get_deflate_stream(session); | 132 local deflate_stream = get_deflate_stream(session); |
133 if not deflate_stream then return true; end | 133 if not deflate_stream then return true; end |
134 | 134 |
148 end); | 148 end); |
149 | 149 |
150 module:hook("stanza/http://jabber.org/protocol/compress:compress", function(event) | 150 module:hook("stanza/http://jabber.org/protocol/compress:compress", function(event) |
151 local session, stanza = event.origin, event.stanza; | 151 local session, stanza = event.origin, event.stanza; |
152 | 152 |
153 if session.type == "c2s" or session.type == "s2sin" or session.type == "c2s_unauthed" or session.type == "s2sin_unauthed" then | 153 if session.type == "c2s" or session.type == "s2sin" then |
154 -- fail if we are already compressed | 154 -- fail if we are already compressed |
155 if session.compressed then | 155 if session.compressed then |
156 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"); | 156 local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed"); |
157 (session.sends2s or session.send)(error_st); | 157 (session.sends2s or session.send)(error_st); |
158 session.log("debug", "Client tried to establish another compression layer."); | 158 session.log("debug", "Client tried to establish another compression layer."); |