Software /
code /
prosody
Comparison
plugins/mod_compression.lua @ 4898:010c01841ed0
mod_compression: advertise/activate compression only for authenticated sessions in accordance to XEP-0170. (Thanks fippo)
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Sat, 19 May 2012 22:05:23 +0200 |
parent | 4481:408c2f688e4e |
child | 5351:901ed253bbf7 |
comparison
equal
deleted
inserted
replaced
4897:1a90e5225b22 | 4898:010c01841ed0 |
---|---|
1 -- Prosody IM | 1 -- Prosody IM |
2 -- Copyright (C) 2009 Tobias Markmann | 2 -- Copyright (C) 2009-2012 Tobias Markmann |
3 -- | 3 -- |
4 -- This project is MIT/X11 licensed. Please see the | 4 -- This project is MIT/X11 licensed. Please see the |
5 -- COPYING file in the source package for more information. | 5 -- COPYING file in the source package for more information. |
6 -- | 6 -- |
7 | 7 |
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 then | 29 if not origin.compressed and (origin.type == "c2s" or origin.type == "s2sin" or origin.type == "s2sout") 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 then | 38 if not origin.compressed and (origin.type == "c2s" or origin.type == "s2sin" or origin.type == "s2sout") 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 then | 46 if not session.compressed and (session.type == "c2s" or session.type == "s2sin" or 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 |