[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] 4568 - Add filter for bridges with transports
commit c8c12c79556d8e4e16029f04672b20ffcf6ff07b
Author: aagbsn <aagbsn@xxxxxxxx>
Date: Wed Jun 6 01:08:59 2012 -0700
4568 - Add filter for bridges with transports
Adds a filter to select bridges with transport specified by name.
---
lib/bridgedb/Filters.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/lib/bridgedb/Filters.py b/lib/bridgedb/Filters.py
index 5654cb5..435845a 100644
--- a/lib/bridgedb/Filters.py
+++ b/lib/bridgedb/Filters.py
@@ -75,3 +75,21 @@ def filterBridgesByOnlyIP6(bridge):
if type(k) is IPv6Address:
return True
return False
+
+def filterBridgesByTransport(methodname, addressClass):
+ assert (addressClass) in (IPv4Address, IPv6Address)
+ ruleset = frozenset([methodname, addressClass])
+ try:
+ return funcs[ruleset]
+ except KeyError:
+ def f(bridge):
+ for transport in bridge.transports:
+ # ignore method name case
+ if isinstance(transport.address, addressClass) and \
+ transport.methodname.lower() == methodname.lower(): return True
+ return False
+ f.__name__ = "filterBridgesByTransport(%s,%s)" % (methodname,
+ type(addressClass))
+ setattr(f, "description", "transport=%s"%methodname)
+ funcs[ruleset] = f
+ return f
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits