Commit 854f12ac authored by Matt Traudt's avatar Matt Traudt Committed by Matt Traudt
Browse files

Make a controller required

parent df4639db
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -257,12 +257,11 @@ def result_putter_error(target):

def run_speedtest(args, conf):
    controller = stem_utils.launch_tor(conf)
    cb = CB(args, conf, controller=controller)
    rl = RelayList(args, conf, controller=controller)
    cb = CB(args, conf, controller)
    rl = RelayList(args, conf, controller)
    rd = ResultDump(args, conf, end_event)
    rp = RelayPrioritizer(args, conf, rl, rd)
    helpers, error_msg = HelperRelayList.from_config(
        args, conf, controller=controller)
    helpers, error_msg = HelperRelayList.from_config(args, conf, controller)
    if not helpers:
        fail_hard(error_msg)
    max_pending_results = conf.getint('scanner', 'measurement_threads')
+3 −9
Original line number Diff line number Diff line
@@ -38,16 +38,10 @@ class CircuitBuilder:
    them, but CircuitBuilder will keep track of existing circuits and close
    them when it is deleted.
    '''
    def __init__(self, args, conf, controller=None,
                 close_circuits_on_exit=True):
        if controller is None:
            c, error_msg = stem_utils.init_controller_with_config(conf)
            assert c, error_msg
            self.controller = c
        else:
    def __init__(self, args, conf, controller, close_circuits_on_exit=True):
        self.controller = controller
        self.rng = random.SystemRandom()
        self.relay_list = RelayList(args, conf, controller=self.controller)
        self.relay_list = RelayList(args, conf, self.controller)
        self.built_circuits = set()
        self.close_circuits_on_exit = close_circuits_on_exit

+4 −9
Original line number Diff line number Diff line
@@ -41,12 +41,7 @@ class HelperRelay:


class HelperRelayList:
    def __init__(self, args, conf, helpers, controller=None):
        if controller is None:
            c, error_msg = stem_utils.init_controller_with_config(conf)
            assert c, error_msg
            self.controller = c
        else:
    def __init__(self, args, conf, helpers, controller):
        self.controller = controller
        assert len(helpers) > 0
        for helper in helpers:
@@ -61,7 +56,7 @@ class HelperRelayList:
        self._reachability_lock = RLock()

    @staticmethod
    def from_config(args, conf, controller=None):
    def from_config(args, conf, controller):
        ''' Returns a new HelperRelayList and an empty string if everything
        goes okay loading HelperRelays from the given config file. Otherwise,
        returns None and an error string '''
@@ -80,7 +75,7 @@ class HelperRelayList:
            helpers.append(HelperRelay(conf[helper_sec]))
        if len(helpers) < 1:
            return None, 'No enabled helpers in config'
        return HelperRelayList(args, conf, helpers, controller=controller), ''
        return HelperRelayList(args, conf, helpers, controller), ''

    def _should_perform_reachability_test(self):
        return self._last_reachability_test + self._reachability_test_every <\
+2 −6
Original line number Diff line number Diff line
@@ -11,11 +11,7 @@ class RelayList:
    '''
    REFRESH_INTERVAL = 300  # seconds

    def __init__(self, args, conf, controller=None):
        if controller is None:
            c, error_msg = stem_utils.init_controller_with_config(conf)
            assert c, error_msg
        else:
    def __init__(self, args, conf, controller):
        self._controller = controller
        self.rng = random.SystemRandom()
        self._refresh()