LiquidProxy Lua Edition
at master 21 lines 336 B view raw
1local gc = collectgarbage 2 3local rs = function(s1, s2) 4 s1:read_start(function(err, chunk) 5 if err then 6 l:error("Upstream error: "..err) 7 s2:close_reset() 8 elseif not chunk then 9 s2:shutdown(function() 10 s2:close() 11 gc() 12 end) 13 else 14 s2:write(chunk) 15 end 16 end) 17end 18 19return function(s1, s2) 20 rs(s1, s2) rs(s2, s1) 21end