Software / code / prosody
Comparison
plugins/mod_proxy65.lua @ 2138:8bb1a2d82896
mod_proxy65: Update for new net.server API, untested
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 22 Nov 2009 15:06:30 +0000 |
| parent | 2137:c5d87a3316f8 |
| child | 2244:730038d3e9e3 |
comparison
equal
deleted
inserted
replaced
| 2137:c5d87a3316f8 | 2138:8bb1a2d82896 |
|---|---|
| 46 end | 46 end |
| 47 if(supported) then | 47 if(supported) then |
| 48 module:log("debug", "new session found ... ") | 48 module:log("debug", "new session found ... ") |
| 49 session.setup = true; | 49 session.setup = true; |
| 50 sessions[conn] = session; | 50 sessions[conn] = session; |
| 51 conn.write(string.char(5, 0)); | 51 conn:write(string.char(5, 0)); |
| 52 end | 52 end |
| 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].initiator == conn and transfers[sha].target ~= nil then |
| 59 transfers[sha].target.write(data); | 59 transfers[sha].target:write(data); |
| 60 return; | 60 return; |
| 61 end | 61 end |
| 62 end | 62 end |
| 63 if data ~= nil and data:len() == 0x2F and -- 40 == length of SHA1 HASH, and 7 other bytes => 47 => 0x2F | 63 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 | 64 data:sub(1):byte() == 0x05 and -- SOCKS5 has 5 in first byte |
| 79 elseif transfers[sha].target ~= nil then | 79 elseif transfers[sha].target ~= nil then |
| 80 transfers[sha].initiator = conn; | 80 transfers[sha].initiator = conn; |
| 81 session.sha = sha; | 81 session.sha = sha; |
| 82 module:log("debug", "initiator connected ... "); | 82 module:log("debug", "initiator connected ... "); |
| 83 end | 83 end |
| 84 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) | 84 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) |
| 85 else | 85 else |
| 86 log:module("warn", "Neither data transfer nor initial connect of a participator of a transfer.") | 86 log:module("warn", "Neither data transfer nor initial connect of a participator of a transfer.") |
| 87 conn.close(); | 87 conn.close(); |
| 88 end | 88 end |
| 89 else | 89 else |