示例#1
0
    def init_subsystems(self, args):
        """
        Initialize subsystems (this is resource intensive)
        """
        self.args = args
        self.config_path = os.path.abspath(self.args.config)
        self.config_data = self.load_config_file()
        self.is_testnet = args.is_testnet

        if self.is_testnet:
            logger.warning("Onionbalance configured on a testnet!")

        # Create stem controller and connect to the Tor network
        self.controller = stem_controller.StemController(args.ip, args.port)
        self.consensus = ob_consensus.Consensus()

        # Initialize our service
        self.services = self.initialize_services_from_config_data()

        # Catch interesting events (like receiving descriptors etc.)
        self.controller.add_event_listeners()

        logger.warning(
            "Onionbalance initialized (stem version: %s) (tor version: %s)!",
            stem.__version__, self.controller.controller.get_version())
        logger.warning("=" * 80)
示例#2
0
def test_disaster_srv():
    """
    Test that disaster SRV creation is correct based on little-t-tor's
    unittests as test vectors (in particular see test_disaster_srv())
    """
    my_consensus = consensus.Consensus(do_refresh_consensus=False)

    # Correct disaster SRV for TPs: 1, 2, 3, 4, 5
    correct_srvs = [
        "F8A4948707653837FA44ABB5BBC75A12F6F101E7F8FAF699B9715F4965D3507D",
        "C17966DF8B4834638E1B7BF38944C4995B92E89749D1623E417A44938D08FD67",
        "A3BAB4327F9C2F8B30A126DAD3ABCCE12DD813169A5D924244B57987AEE413C2",
        "C79ABE7116FCF7810F7A5C76198B97339990C738B456EFDBC1399189927BADEC",
        "941D5FE4289FBF2F853766EAC4B948B51C81A4137A44516342ABC80518E0183D"
    ]

    for i in range(1, 6):
        disaster_srv = my_consensus._get_disaster_srv(i)
        assert (disaster_srv.hex().upper() == correct_srvs[i - 1])