[tor-commits] [bridgedb/master] Include bridge stability properties from #5482.

isis at torproject.org isis at torproject.org
Sat Mar 21 02:02:58 UTC 2015


commit 1fcb3c022ba05ba4830464af83e1e066ba55c41d
Author: Isis Lovecruft <isis at torproject.org>
Date:   Fri Dec 5 18:55:59 2014 -0800

    Include bridge stability properties from #5482.
    
    These have not been changed.
---
 lib/bridgedb/bridges.py |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/lib/bridgedb/bridges.py b/lib/bridgedb/bridges.py
index fede979..dec5e16 100644
--- a/lib/bridgedb/bridges.py
+++ b/lib/bridgedb/bridges.py
@@ -22,6 +22,8 @@ from Crypto.Util import asn1
 from Crypto.Util.number import bytes_to_long
 from Crypto.Util.number import long_to_bytes
 
+import bridgedb.Storage
+
 from bridgedb import safelog
 from bridgedb import bridgerequest
 from bridgedb.crypto import removePKCS1Padding
@@ -1326,3 +1328,43 @@ class Bridge(object):
                      % (self, ' '.join(dead)))
         for died in dead:
             self.transports.remove(died)
+
+    # Bridge Stability (`#5482 <https://bugs.torproject.org>`_) properties.
+    @property
+    def familiar(self):
+        """A bridge is "familiar" if 1/8 of all active bridges have appeared
+        more recently than it, or if it has been around for a Weighted Time of
+        eight days.
+        """
+        with bridgedb.Storage.getDB() as db:
+            return db.getBridgeHistory(self.fingerprint).familiar
+
+    @property
+    def wfu(self):
+        """Weighted Fractional Uptime"""
+        with bridgedb.Storage.getDB() as db:
+            return db.getBridgeHistory(self.fingerprint).weightedFractionalUptime
+
+    @property
+    def weightedTime(self):
+        """Weighted Time"""
+        with bridgedb.Storage.getDB() as db:
+            return db.getBridgeHistory(self.fingerprint).weightedTime
+
+    @property
+    def wmtbac(self):
+        """Weighted Mean Time Between Address Change"""
+        with bridgedb.Storage.getDB() as db:
+            return db.getBridgeHistory(self.fingerprint).wmtbac
+
+    @property
+    def tosa(self):
+        """The Time On Same Address (TOSA)"""
+        with bridgedb.Storage.getDB() as db:
+            return db.getBridgeHistory(self.fingerprint).tosa
+
+    @property
+    def weightedUptime(self):
+        """Weighted Uptime"""
+        with bridgedb.Storage.getDB() as db:
+            return db.getBridgeHistory(self.fingerprint).weightedUptime





More information about the tor-commits mailing list