Ejemplo n.º 1
0
    def testDistWithFilterIP6(self):
        d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
        for _ in xrange(250):
            d.insert(fakeBridge6(or_addresses=True))
            d.insert(fakeBridge(or_addresses=True))

        for i in xrange(500):
            b = d.getBridgesForIP(randomIP4String(), "x", 1, bridgeFilterRules=[filterBridgesByIP6])
            address, portlist = bridgedb.Bridges.parseORAddressLine(
                    random.choice(b).getConfigLine(addressClass=ipaddr.IPv6Address)[7:])
            assert type(address) is ipaddr.IPv6Address
            assert filterBridgesByIP6(random.choice(b))
Ejemplo n.º 2
0
    def testDistWithFilterIP6(self):
        d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
        for _ in xrange(250):
            d.insert(fakeBridge6(or_addresses=True))
            d.insert(fakeBridge(or_addresses=True))

        for i in xrange(500):
            bridges = d.getBridgesForIP(randomIPv4String(),
                                        "faketimestamp",
                                        bridgeFilterRules=[filterBridgesByIP6])
            bridge = random.choice(bridges)
            bridge_line = bridge.getConfigLine(addressClass=ipaddr.IPv6Address)
            address, portlist = networkstatus.parseALine(bridge_line)
            assert type(ipaddr.IPAddress(address)) is ipaddr.IPv6Address
            assert filterBridgesByIP6(random.choice(bridges))
Ejemplo n.º 3
0
    def testDistWithFilterIP6(self):
        d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
        for _ in xrange(250):
            d.insert(fakeBridge6(or_addresses=True))
            d.insert(fakeBridge(or_addresses=True))

        for i in xrange(500):
            bridges = d.getBridgesForIP(randomIPv4String(),
                                        "faketimestamp",
                                        bridgeFilterRules=[filterBridgesByIP6])
            bridge = random.choice(bridges)
            bridge_line = bridge.getConfigLine(addressClass=ipaddr.IPv6Address)
            address, portlist = networkstatus.parseALine(bridge_line)
            assert type(ipaddr.IPAddress(address)) is ipaddr.IPv6Address
            assert filterBridgesByIP6(random.choice(bridges))
Ejemplo n.º 4
0
    def testDistWithFilterBoth(self):
        d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
        for _ in xrange(250):
            d.insert(fakeBridge6(or_addresses=True))
            d.insert(fakeBridge(or_addresses=True))

        for i in xrange(50):
            bridges = d.getBridgesForIP(
                randomIPv4String(),
                "faketimestamp",
                1,
                bridgeFilterRules=[filterBridgesByIP4, filterBridgesByIP6])
            if bridges:
                t = bridges.pop()
                assert filterBridgesByIP4(t)
                assert filterBridgesByIP6(t)
                address, portlist = networkstatus.parseALine(
                    t.getConfigLine(addressClass=ipaddr.IPv4Address))
                assert type(address) is ipaddr.IPv4Address
                address, portlist = networkstatus.parseALine(
                    t.getConfigLine(addressClass=ipaddr.IPv6Address))
                assert type(address) is ipaddr.IPv6Address
Ejemplo n.º 5
0
    def testDistWithFilterBoth(self):
        d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
        for _ in xrange(250):
            d.insert(fakeBridge6(or_addresses=True))
            d.insert(fakeBridge(or_addresses=True))

        for i in xrange(50):
            bridges = d.getBridgesForIP(randomIPv4String(),
                                        "faketimestamp", 1,
                                        bridgeFilterRules=[
                                            filterBridgesByIP4,
                                            filterBridgesByIP6])
            if bridges:
                t = bridges.pop()
                assert filterBridgesByIP4(t)
                assert filterBridgesByIP6(t)
                address, portlist = networkstatus.parseALine(
                    t.getConfigLine(addressClass=ipaddr.IPv4Address))
                assert type(address) is ipaddr.IPv4Address
                address, portlist = networkstatus.parseALine(
                    t.getConfigLine(addressClass=ipaddr.IPv6Address))
                assert type(address) is ipaddr.IPv6Address