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

[tor-commits] [depictor/master] Replace the usage of the is_bwauth stem attribute that is deprecated now



commit 339c90d2d20a41f2d98900d7e42e576e65c740b8
Author: Tom Ritter <tom@xxxxxxxxx>
Date:   Tue Aug 7 10:30:21 2018 -0500

    Replace the usage of the is_bwauth stem attribute that is deprecated now
---
 data/consensus.cfg |  7 +++++++
 utility.py         |  8 +++++++-
 website.py         | 23 +++++++++++++----------
 write_website.py   |  5 ++++-
 4 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/data/consensus.cfg b/data/consensus.cfg
index ca11041..41a4147 100644
--- a/data/consensus.cfg
+++ b/data/consensus.cfg
@@ -12,6 +12,13 @@ graph_logical_max 25000
 # we highlight clockskew that is 20 seconds or greater
 clockskew_threshold 20
 
+# bwauths that should be graphed
+
+bwauths maatuska
+bwauths faravahar
+bwauths bastet
+bwauths moria1
+
 # recognized tor consensus parameters
 
 known_params bwweightscale
diff --git a/utility.py b/utility.py
index 6b2ee54..c931c59 100755
--- a/utility.py
+++ b/utility.py
@@ -11,6 +11,11 @@ import stem.util.enum
 
 from stem.util.lru_cache import lru_cache
 
+config = {'bwauths': []}
+def set_config(c):
+	global config
+	config = c
+
 @lru_cache()
 def get_dirauths():
 	#Remove any BridgeAuths
@@ -18,7 +23,8 @@ def get_dirauths():
 
 @lru_cache()
 def get_bwauths():
-	return dict((k.lower(), v) for (k, v) in stem.descriptor.remote.get_authorities().items() if v.is_bandwidth_authority)
+	global config
+	return dict((k.lower(), v) for (k, v) in stem.descriptor.remote.get_authorities().items() if v.nickname.lower() in config['bwauths'])
 
 downloader = stem.descriptor.remote.DescriptorDownloader(
 	timeout = 30,
diff --git a/website.py b/website.py
index 7baa0f8..0405099 100755
--- a/website.py
+++ b/website.py
@@ -18,7 +18,7 @@ from Crypto.PublicKey import RSA
 
 import stem.descriptor.remote
 
-from utility import get_dirauths, get_bwauths, unix_time, FileMock
+from utility import set_config, get_dirauths, get_bwauths, unix_time, FileMock
 
 class WebsiteWriter:
 	consensus = None
@@ -1680,6 +1680,18 @@ if __name__ == '__main__':
 	"""
 	import stem
 	import pickle
+	CONFIG = stem.util.conf.config_dict('consensus', {
+                                    'known_params': [],
+                                    'bwauths': [],
+                                    'ignore_fallback_authorities': False,
+                                    'graph_logical_min': 125,
+                                    'graph_logical_max': 25000,
+                                    'clockskew_threshold': 0,
+                                    })
+	config = stem.util.conf.get_config("consensus")
+	config.load(os.path.join(os.path.dirname(__file__), 'data', 'consensus.cfg'))
+	set_config(CONFIG)
+
 	w = WebsiteWriter()
 
 	c = pickle.load(open('consensus.p', 'rb'))
@@ -1690,15 +1702,6 @@ if __name__ == '__main__':
 	w.set_fallback_dirs(f)
 		
 
-	CONFIG = stem.util.conf.config_dict('consensus', {
-                                    'known_params': [],
-                                    'ignore_fallback_authorities': False,
-                                    'graph_logical_min': 125,
-                                    'graph_logical_max': 25000,
-                                    'clockskew_threshold': 0,
-                                    })
-	config = stem.util.conf.get_config("consensus")
-	config.load(os.path.join(os.path.dirname(__file__), 'data', 'consensus.cfg'))
 	w.set_config(CONFIG)
 
 	w.write_website(os.path.join(os.path.dirname(__file__), 'out', \
diff --git a/write_website.py b/write_website.py
index f79e2c3..538c10c 100755
--- a/write_website.py
+++ b/write_website.py
@@ -32,13 +32,14 @@ from graphs import GraphWriter
 # dir-source line: dir-source authority_name v3ident hostname ip  DirPort  OrPort
 # r line: r nickname base64(fingerprint + "=")   -> python -c "x = ''; import sys; import base64; sys.stdout.write(''.join('{:02x}'.format(ord(c)) for c in base64.b64decode(x)))"
 
+#Also make sure to define the list of bwauths in the consensus.cfg file
+
 #stem.descriptor.remote.DIRECTORY_AUTHORITIES = {
 #'Faravahar': DirectoryAuthority(
 #    nickname = 'Faravahar',
 #    address = '154.35.175.225',
 #    or_port = 443,
 #    dir_port = 80,
-#    is_bandwidth_authority = True,
 #    fingerprint = 'CF6D0AAFB385BE71B8E111FC5CFF4B47923733BC',
 #    v3ident = 'EFCBE720AB3A82B99F9E953CD5BF50F7EEFC7B97',
 #  ),	
@@ -46,6 +47,7 @@ from graphs import GraphWriter
 
 CONFIG = stem.util.conf.config_dict('consensus', {
 	'known_params': [],
+	'bwauths': [],
 	'ignore_fallback_authorities' : False,
 	'graph_logical_min' : 125,
 	'graph_logical_max' : 25000,
@@ -56,6 +58,7 @@ def main():
 	# loads configuration data
 	config = stem.util.conf.get_config("consensus")
 	config.load(os.path.join(os.path.dirname(__file__), 'data', 'consensus.cfg'))
+	set_config(CONFIG)
 
 	consensuses, consensus_fetching_issues, consensus_fetching_runtimes = get_consensuses()
 	votes, vote_fetching_issues, vote_fetching_runtimes = get_votes()

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