Software /
code /
prosody
Comparison
plugins/mod_proxy65.lua @ 2310:e74c6740a42b
mod_proxy65: Make the proxying bidirectional
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> |
---|---|
date | Thu, 03 Dec 2009 17:05:35 +0100 |
parent | 2309:7dc6049a69e8 |
child | 2311:5fe837ebe542 |
comparison
equal
deleted
inserted
replaced
2309:7dc6049a69e8 | 2310:e74c6740a42b |
---|---|
53 return; | 53 return; |
54 end | 54 end |
55 if session.setup then | 55 if session.setup then |
56 if session.sha ~= nil and transfers[session.sha] ~= nil then | 56 if session.sha ~= nil and transfers[session.sha] ~= nil then |
57 local sha = session.sha; | 57 local sha = session.sha; |
58 if transfers[sha].activated == true and transfers[sha].initiator == conn and transfers[sha].target ~= nil then | 58 if transfers[sha].activated == true and transfers[sha].target ~= nil then |
59 transfers[sha].target:write(data); | 59 if transfers[sha].initiator == conn then |
60 transfers[sha].target:write(data); | |
61 else | |
62 transfers[sha].initiator:write(data); | |
63 end | |
60 return; | 64 return; |
61 end | 65 end |
62 end | 66 end |
63 if data ~= nil and data:len() == 0x2F and -- 40 == length of SHA1 HASH, and 7 other bytes => 47 => 0x2F | 67 if data ~= nil and data:len() == 0x2F and -- 40 == length of SHA1 HASH, and 7 other bytes => 47 => 0x2F |
64 data:sub(1):byte() == 0x05 and -- SOCKS5 has 5 in first byte | 68 data:sub(1):byte() == 0x05 and -- SOCKS5 has 5 in first byte |
78 module:log("debug", "target connected ... "); | 82 module:log("debug", "target connected ... "); |
79 elseif transfers[sha].target ~= nil then | 83 elseif transfers[sha].target ~= nil then |
80 transfers[sha].initiator = conn; | 84 transfers[sha].initiator = conn; |
81 session.sha = sha; | 85 session.sha = sha; |
82 module:log("debug", "initiator connected ... "); | 86 module:log("debug", "initiator connected ... "); |
83 throttle_sending(conn, transfers[sha].target); | 87 throttle_sending(conn, transfers[sha].target); |
88 throttle_sending(transfers[sha].target, conn); | |
84 end | 89 end |
85 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) |
86 else | 91 else |
87 module:log("warn", "Neither data transfer nor initial connect of a participator of a transfer.") | 92 module:log("warn", "Neither data transfer nor initial connect of a participator of a transfer.") |
88 conn.close(); | 93 conn.close(); |