Comparison

plugins/mod_proxy65.lua @ 2311:5fe837ebe542

mod_proxy65: Don't read data from the connection untill the proxying is activated
author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
date Thu, 03 Dec 2009 17:07:37 +0100
parent 2310:e74c6740a42b
child 2320:2ca7445b882a
comparison
equal deleted inserted replaced
2310:e74c6740a42b 2311:5fe837ebe542
86 module:log("debug", "initiator connected ... "); 86 module:log("debug", "initiator connected ... ");
87 throttle_sending(conn, transfers[sha].target); 87 throttle_sending(conn, transfers[sha].target);
88 throttle_sending(transfers[sha].target, conn); 88 throttle_sending(transfers[sha].target, conn);
89 end 89 end
90 conn:write(string.char(5, 0, 0, 3, sha:len()) .. sha .. string.char(0, 0)); -- VER, REP, RSV, ATYP, BND.ADDR (sha), BND.PORT (2 Byte) 90 conn:write(string.char(5, 0, 0, 3, sha:len()) .. sha .. string.char(0, 0)); -- VER, REP, RSV, ATYP, BND.ADDR (sha), BND.PORT (2 Byte)
91 conn:lock_read(true)
91 else 92 else
92 module:log("warn", "Neither data transfer nor initial connect of a participator of a transfer.") 93 module:log("warn", "Neither data transfer nor initial connect of a participator of a transfer.")
93 conn.close(); 94 conn.close();
94 end 95 end
95 else 96 else
241 if transfers[sha] == nil then 242 if transfers[sha] == nil then
242 module:log("error", "transfers[sha]: nil"); 243 module:log("error", "transfers[sha]: nil");
243 elseif(transfers[sha] ~= nil and transfers[sha].initiator ~= nil and transfers[sha].target ~= nil) then 244 elseif(transfers[sha] ~= nil and transfers[sha].initiator ~= nil and transfers[sha].target ~= nil) then
244 origin.send(reply); 245 origin.send(reply);
245 transfers[sha].activated = true; 246 transfers[sha].activated = true;
247 transfers[sha].target:lock_read(false);
248 transfers[sha].initiator:lock_read(false);
246 end 249 end
247 else 250 else
248 module:log("error", "activation failed: sid: %s, initiator: %s, target: %s", tostring(sid), tostring(from), tostring(to)); 251 module:log("error", "activation failed: sid: %s, initiator: %s, target: %s", tostring(sid), tostring(from), tostring(to));
249 end 252 end
250 end 253 end