[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Refactor code for setting of tor port
commit 1e3954bb26b2ac94b968d3e60cbf7ef75bb4c9b9
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date: Fri May 13 15:33:00 2016 +0200
Refactor code for setting of tor port
---
ooni/director.py | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/ooni/director.py b/ooni/director.py
index 82d0e85..e6f864e 100644
--- a/ooni/director.py
+++ b/ooni/director.py
@@ -345,11 +345,13 @@ class Director(object):
log.msg("%d%%: %s" % (prog, summary))
tor_config = TorConfig()
- if config.tor.control_port:
- tor_config.ControlPort = config.tor.control_port
+ if config.tor.control_port is None:
+ config.tor.control_port = int(randomFreePort())
+ if config.tor.socks_port is None:
+ config.tor.socks_port = int(randomFreePort())
- if config.tor.socks_port:
- tor_config.SocksPort = config.tor.socks_port
+ tor_config.ControlPort = config.tor.control_port
+ tor_config.SocksPort = config.tor.socks_port
if config.tor.data_dir:
data_dir = os.path.expanduser(config.tor.data_dir)
@@ -384,18 +386,6 @@ class Director(object):
tor_config.User = pwd.getpwuid(os.geteuid()).pw_name
tor_config.save()
-
- if not hasattr(tor_config, 'ControlPort'):
- control_port = int(randomFreePort())
- tor_config.ControlPort = control_port
- config.tor.control_port = control_port
-
- if not hasattr(tor_config, 'SocksPort'):
- socks_port = int(randomFreePort())
- tor_config.SocksPort = socks_port
- config.tor.socks_port = socks_port
-
- tor_config.save()
log.debug("Setting control port as %s" % tor_config.ControlPort)
log.debug("Setting SOCKS port as %s" % tor_config.SocksPort)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits