comparison mod_onions/mod_onions.lua @ 2345:2df32ac11b31

mod_onions: Reduce line count for redirect check
author Kim Alvefur <zash@zash.se>
date Fri, 04 Nov 2016 22:35:09 +0100
parents c928b7ac75b7
children c0237567bbb1
comparison
equal deleted inserted replaced
2344:c928b7ac75b7 2345:2df32ac11b31
63 session.socks5_buffer = data; 63 session.socks5_buffer = data;
64 return; 64 return;
65 end 65 end
66 66
67 -- this means the server tells us to connect on an IPv4 address 67 -- this means the server tells us to connect on an IPv4 address
68 local ip1 = byte(data, 5); 68 local ip = string.format("%d.%d.%d.%d", byte(data, 5,8));
69 local ip2 = byte(data, 6);
70 local ip3 = byte(data, 7);
71 local ip4 = byte(data, 8);
72 local port = band(byte(data, 9), lshift(byte(data, 10), 8)); 69 local port = band(byte(data, 9), lshift(byte(data, 10), 8));
73 module:log("debug", "Should connect to: "..ip1.."."..ip2.."."..ip3.."."..ip4..":"..port); 70 module:log("debug", "Should connect to: %s:%d", ip, port);
74 71
75 if not (ip1 == 0 and ip2 == 0 and ip3 == 0 and ip4 == 0 and port == 0) then 72 if not (ip == "0.0.0.0" and port == 0) then
76 module:log("debug", "The SOCKS5 proxy tells us to connect to a different IP, don't know how. :("); 73 module:log("debug", "The SOCKS5 proxy tells us to connect to a different IP, don't know how. :(");
77 session:close(false); 74 session:close(false);
78 return; 75 return;
79 end 76 end
80 77