[tor-commits] [stem/master] Ensure created nicknames aren't too long

atagar at torproject.org atagar at torproject.org
Wed Jun 28 17:04:47 UTC 2017


commit a3194c8a344af5a613dbc528805bd379c3f41cf0
Author: Damian Johnson <atagar at torproject.org>
Date:   Wed Jun 28 10:04:26 2017 -0700

    Ensure created nicknames aren't too long
    
    Jenkins tests are failing because the random nicknames we make are often too
    long. Ensuring that isn't the case.
---
 stem/descriptor/server_descriptor.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 580b3d3..8228b1d 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -806,8 +806,10 @@ class RelayDescriptor(ServerDescriptor):
     if attr is None:
       attr = {}
 
+    nickname = ('Unnamed%i' % random.randint(0, sys.maxint))[:19]
+
     base_header = (
-      ('router', 'Unnamed%i %s 9001 0 0' % (random.randint(0, sys.maxint), _random_ipv4_address())),
+      ('router', '%s %s 9001 0 0' % (nickname, _random_ipv4_address())),
       ('published', _random_date()),
       ('bandwidth', '153600 256000 104590'),
       ('reject', '*:*'),



More information about the tor-commits mailing list