commit f5be81ee5c96aad74bade49ba520ae7cafc77e12 Author: aagbsn <aag...@extc.org> Date: Sun Oct 20 17:47:09 2013 +0000
Get a Tor Controller connection for a tor ooniprobe did not launch. --- ooni/director.py | 14 ++++++++++++-- ooni/errors.py | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ooni/director.py b/ooni/director.py index 3f538ca..e7fb539 100644 --- a/ooni/director.py +++ b/ooni/director.py @@ -12,10 +12,10 @@ from ooni.nettest import NetTest, getNetTestInformation from ooni.settings import config from ooni import errors -from txtorcon import TorConfig -from txtorcon import TorState, launch_tor +from txtorcon import TorConfig, TorState, launch_tor, build_tor_connection from twisted.internet import defer, reactor +from twisted.internet.endpoints import TCP4ClientEndpoint class Director(object): """ @@ -123,6 +123,9 @@ class Director(object): if config.advanced.start_tor: yield self.startTor() + elif config.tor.control_port: + log.msg("Connecting to Tor Control Port...") + yield self.getTorState() config.probe_ip = geoip.ProbeIP() yield config.probe_ip.lookup() @@ -258,6 +261,13 @@ class Director(object): config.scapyFactory.registerProtocol(self.sniffer) log.msg("Starting packet capture to: %s" % config.reports.pcap) + @defer.inlineCallbacks + def getTorState(self): + connection = TCP4ClientEndpoint(reactor, '127.0.0.1', + config.tor.control_port) + config.tor_state = yield build_tor_connection(connection) + + def startTor(self): """ Starts Tor Launches a Tor with :param: socks_port :param: control_port diff --git a/ooni/errors.py b/ooni/errors.py index c167bbe..d90138b 100644 --- a/ooni/errors.py +++ b/ooni/errors.py @@ -147,6 +147,10 @@ class ReportAlreadyClosed(Exception): class TorStateNotFound(Exception): pass + +class TorControlPortNotFound(Exception): + pass + class ReportNotCreated(Exception): pass _______________________________________________ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits