comparison mod_onions/mod_onions.lua @ 1061:f4031e7ccec1

mod_onions: The SOCKS5 port is now a string, as it should be. Added a boolean option onions_tor_all to pass all s2s traffic through Tor.
author Thijs Alkemade <me@thijsalkema.de>
date Mon, 10 Jun 2013 21:39:48 +0200
parents 25b83ed7838a
children 8f59b45fe6a7
comparison
equal deleted inserted replaced
1060:25b83ed7838a 1061:f4031e7ccec1
6 local portmanager = require "core.portmanager"; 6 local portmanager = require "core.portmanager";
7 local byte = string.byte; 7 local byte = string.byte;
8 local c = string.char; 8 local c = string.char;
9 9
10 local proxy_ip = module:get_option("onions_socks5_host") or "127.0.0.1"; 10 local proxy_ip = module:get_option("onions_socks5_host") or "127.0.0.1";
11 local proxy_port = module:get_option("onions_socks5_port") or "9050"; 11 local proxy_port = module:get_option("onions_socks5_port") or 9050;
12 local forbid_else = module:get_option("onions_only") or false; 12 local forbid_else = module:get_option("onions_only") or false;
13 local torify_all = module:get_option("onions_tor_all") or false;
13 14
14 local sessions = module:shared("sessions"); 15 local sessions = module:shared("sessions");
15 16
16 -- The socks5listener handles connection while still connecting to the proxy, 17 -- The socks5listener handles connection while still connecting to the proxy,
17 -- then it hands them over to the normal listener (in mod_s2s) 18 -- then it hands them over to the normal listener (in mod_s2s)
18 local socks5listener = { default_port = tonumber(proxy_port), default_mode = "*a", default_interface = "*" }; 19 local socks5listener = { default_port = proxy_port, default_mode = "*a", default_interface = "*" };
19 20
20 local function socks5_connect_sent(conn, data) 21 local function socks5_connect_sent(conn, data)
21 22
22 local session = sessions[conn]; 23 local session = sessions[conn];
23 24
213 214
214 if not event.to_host:find(".onion(.?)$") then 215 if not event.to_host:find(".onion(.?)$") then
215 if forbid_else then 216 if forbid_else then
216 module:log("debug", event.to_host .. " is not an onion. Blocking it."); 217 module:log("debug", event.to_host .. " is not an onion. Blocking it.");
217 return false; 218 return false;
218 else 219 elseif not torify_all then
219 return; 220 return;
220 end 221 end
221 end 222 end
222 223
223 module:log("debug", "Onion routing something to ".. event.to_host); 224 module:log("debug", "Onion routing something to ".. event.to_host);