if session.setup then
if session.sha ~= nil and transfers[session.sha] ~= nil then
local sha = session.sha;
- if transfers[sha].activated == true and transfers[sha].initiator == conn and transfers[sha].target ~= nil then
- transfers[sha].target:write(data);
+ if transfers[sha].activated == true and transfers[sha].target ~= nil then
+ if transfers[sha].initiator == conn then
+ transfers[sha].target:write(data);
+ else
+ transfers[sha].initiator:write(data);
+ end
return;
end
end
session.sha = sha;
module:log("debug", "initiator connected ... ");
throttle_sending(conn, transfers[sha].target);
+ throttle_sending(transfers[sha].target, conn);
end
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)
+ conn:lock_read(true)
else
module:log("warn", "Neither data transfer nor initial connect of a participator of a transfer.")
- conn.close();
+ conn:close();
end
else
if data ~= nil then
module:log("warn", "unknown connection with no authentication data -> closing it");
- conn.close();
+ conn:close();
end
end
end
if session.sha and transfers[session.sha] then
local initiator, target = transfers[session.sha].initiator, transfers[session.sha].target;
if initiator == conn and target ~= nil then
- target.close();
+ target:close();
elseif target == conn and initiator ~= nil then
- initiator.close();
+ initiator:close();
end
transfers[session.sha] = nil;
end
elseif(transfers[sha] ~= nil and transfers[sha].initiator ~= nil and transfers[sha].target ~= nil) then
origin.send(reply);
transfers[sha].activated = true;
+ transfers[sha].target:lock_read(false);
+ transfers[sha].initiator:lock_read(false);
end
else
module:log("error", "activation failed: sid: %s, initiator: %s, target: %s", tostring(sid), tostring(from), tostring(to));
connlisteners.start(module.host .. ':proxy65');
component = componentmanager.register_component(host, handle_to_domain);
-local sender_lock_threshold = 1024;
+local sender_lock_threshold = 4096;
function throttle_sending(sender, receiver)
sender:pattern(sender_lock_threshold);
local sender_locked;