Comparison

plugins/mod_compression.lua @ 2284:491b89d6816b

mod_compression: Make setup_compression work for s2s sessions too.
author Tobias Markmann <tm@ayena.de>
date Sun, 29 Nov 2009 23:04:19 +0100
parent 2283:156bb00ba5c0
child 2285:3dd7fdee9035
comparison
equal deleted inserted replaced
2283:156bb00ba5c0 2284:491b89d6816b
107 return 107 return
108 end 108 end
109 109
110 -- setup compression for session.w 110 -- setup compression for session.w
111 local function setup_compression(session) 111 local function setup_compression(session)
112 local old_send = session.send; 112 local old_send = (session.sends2s or session.send);
113 113
114 session.send = function(t) 114 local new_send = function(t)
115 local status, compressed, eof = pcall(deflate_stream, tostring(t), 'sync'); 115 local status, compressed, eof = pcall(deflate_stream, tostring(t), 'sync');
116 if status == false then 116 if status == false then
117 session:close({ 117 session:close({
118 condition = "undefined-condition"; 118 condition = "undefined-condition";
119 text = compressed; 119 text = compressed;
122 module:log("warn", compressed); 122 module:log("warn", compressed);
123 return; 123 return;
124 end 124 end
125 old_send(compressed); 125 old_send(compressed);
126 end; 126 end;
127
128 if session.sends2s then session.sends2s = new_send
129 elseif session.send then session.send = new_send end
127 end 130 end
128 setup_compression(session); 131 setup_compression(session);
129 132
130 -- setup decompression for session.data 133 -- setup decompression for session.data
131 local function setup_decompression(session) 134 local function setup_decompression(session)