Software /
code /
prosody
Comparison
plugins/mod_proxy65.lua @ 2295:0d954d52062f
Merge with tip.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Tue, 01 Dec 2009 23:05:32 +0100 |
parent | 2273:b98b29f614ae |
child | 2305:7ddd00260808 |
comparison
equal
deleted
inserted
replaced
2293:abd28ed5d8b0 | 2295:0d954d52062f |
---|---|
65 data:sub(2):byte() == 0x01 and -- CMD must be 1 | 65 data:sub(2):byte() == 0x01 and -- CMD must be 1 |
66 data:sub(3):byte() == 0x00 and -- RSV must be 0 | 66 data:sub(3):byte() == 0x00 and -- RSV must be 0 |
67 data:sub(4):byte() == 0x03 and -- ATYP must be 3 | 67 data:sub(4):byte() == 0x03 and -- ATYP must be 3 |
68 data:sub(5):byte() == 40 and -- SHA1 HASH length must be 40 (0x28) | 68 data:sub(5):byte() == 40 and -- SHA1 HASH length must be 40 (0x28) |
69 data:sub(-2):byte() == 0x00 and -- PORT must be 0, size 2 byte | 69 data:sub(-2):byte() == 0x00 and -- PORT must be 0, size 2 byte |
70 data:sub(-1):byte() == 0x00 | 70 data:sub(-1):byte() == 0x00 |
71 then | 71 then |
72 local sha = data:sub(6, 45); -- second param is not count! it's the ending index (included!) | 72 local sha = data:sub(6, 45); -- second param is not count! it's the ending index (included!) |
73 if transfers[sha] == nil then | 73 if transfers[sha] == nil then |
74 transfers[sha] = {}; | 74 transfers[sha] = {}; |
75 transfers[sha].activated = false; | 75 transfers[sha].activated = false; |
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 module:log("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 |
90 if data ~= nil then | 90 if data ~= nil then |
91 module:log("warn", "unknown connection with no authentication data -> closing it"); | 91 module:log("warn", "unknown connection with no authentication data -> closing it"); |