commit e5b7cbbccec5a4a238d386d927d5b8a66aad262b Author: Damian Johnson atagar@torproject.org Date: Tue Jun 27 09:42:45 2017 -0700
Randomize BridgeDescriptor created fields
These come from CollecTor. Can they even be signed? Regardless, randomizing their attributes. --- stem/descriptor/server_descriptor.py | 16 +++++++--------- test/unit/descriptor/server_descriptor.py | 3 +-- 2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py index a66faa8..6ffe914 100644 --- a/stem/descriptor/server_descriptor.py +++ b/stem/descriptor/server_descriptor.py @@ -116,14 +116,6 @@ SINGLE_FIELDS = ( DEFAULT_IPV6_EXIT_POLICY = stem.exit_policy.MicroExitPolicy('reject 1-65535') REJECT_ALL_POLICY = stem.exit_policy.ExitPolicy('reject *:*')
-BRIDGE_SERVER_HEADER = ( - ('router', 'Unnamed 10.45.227.253 9001 0 0'), - ('router-digest', '006FD96BA35E7785A6A3B8B75FE2E2435A13BDB4'), - ('published', '2012-03-22 17:34:38'), - ('bandwidth', '409600 819200 5120'), - ('reject', '*:*'), -) -
def _parse_file(descriptor_file, is_bridge = False, validate = False, **kwargs): """ @@ -965,7 +957,13 @@ class BridgeDescriptor(ServerDescriptor): if sign: raise NotImplementedError('Signing of %s not implemented' % cls.__name__)
- return _descriptor_content(attr, exclude, sign, BRIDGE_SERVER_HEADER) + return _descriptor_content(attr, exclude, sign, ( + ('router', 'Unnamed%s %s 9001 0 0' % (random.randint(0, sys.maxint), _random_ipv4_address())), + ('router-digest', '006FD96BA35E7785A6A3B8B75FE2E2435A13BDB4'), + ('published', _random_date()), + ('bandwidth', '409600 819200 5120'), + ('reject', '*:*'), + ))
def digest(self): return self._digest diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py index c881751..8578726 100644 --- a/test/unit/descriptor/server_descriptor.py +++ b/test/unit/descriptor/server_descriptor.py @@ -732,8 +732,7 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
desc = BridgeDescriptor.create()
- self.assertEqual('Unnamed', desc.nickname) - self.assertEqual('10.45.227.253', desc.address) + self.assertTrue(desc.nickname.startswith('Unnamed')) self.assertEqual(None, desc.fingerprint) self.assertEqual('006FD96BA35E7785A6A3B8B75FE2E2435A13BDB4', desc.digest())