[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/master] 5027 - parse bridge block list in Main.py



commit 22248927f70b2ec2b7d7271e42b6ba48f04d10c1
Author: aagbsn <aagbsn@xxxxxxxx>
Date:   Sun Jul 1 04:22:40 2012 -0700

    5027 - parse bridge block list in Main.py
---
 lib/bridgedb/Main.py |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index d8a5c3c..4faec57 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -160,12 +160,9 @@ def load(cfg, splitter, clear=False):
     """Read all the bridge files from cfg, and pass them into a splitter
        object.
     """
-    countryblock = Bridges.CountryBlock()
     if clear:
         logging.info("Clearing old bridges")
         splitter.clear()
-        logging.info("Clearing old blocked bridges")
-        countryblock.clear() 
     logging.info("Loading bridges")
     status = {}
     addresses = {}
@@ -176,11 +173,6 @@ def load(cfg, splitter, clear=False):
             addresses[ID] = or_addresses
             #transports[ID] = transports
         f.close()
-    if hasattr(cfg, "COUNTRY_BLOCK_FILE"):
-        f = open(cfg.COUNTRY_BLOCK_FILE, 'r')
-        for fingerprint, countryCode in Bridges.parseCountryBlockFile(f):
-            countryblock.insert(fingerprint, countryCode)
-        f.close() 
     bridges = {} 
     for fname in cfg.BRIDGE_FILES:
         f = open(fname, 'r')
@@ -191,8 +183,6 @@ def load(cfg, splitter, clear=False):
                 running, stable = s
                 bridge.setStatus(running=running, stable=stable)
             bridge.or_addresses = addresses.get(bridge.getID())
-            bridge.setBlockingCountries(
-                    countryblock.getBlockingCountries(bridge.fingerprint)) 
             splitter.insert(bridge)
         f.close()
     # read pluggable transports from extra-info document
@@ -205,6 +195,21 @@ def load(cfg, splitter, clear=False):
             if bridges[ID].running:
                 bridges[ID].transports.append(Bridges.PluggableTransport(bridges[ID],
                     method_name, address, port, argdict))
+    if hasattr(cfg, "COUNTRY_BLOCK_FILE"):
+        f = open(cfg.COUNTRY_BLOCK_FILE, 'r')
+        for ID,address,portlist,countries in Bridges.parseCountryBlockFile(f):
+            if ID in bridges.keys() and bridges[ID].running:
+                for port in portlist:
+                    logging.debug(":.( Tears! %s blocked %s %s:%s" % (
+                        countries, bridges[ID].fingerprint, address, port))
+                    try:
+                        bridges[ID].blockingCountries["%s:%s" % \
+                                (address, port)].update(countries)
+                    except KeyError:
+                        bridges[ID].blockingCountries["%s:%s" % \
+                                (address, port)] = set(countries)
+        f.close() 
+
     bridges = None
 
 def loadProxyList(cfg):



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits