[tor-commits] [bridgedb/master] Change import of `random.randint`; only use one random value to create IP.

isis at torproject.org isis at torproject.org
Sat Apr 19 17:02:42 UTC 2014


commit 4bc1ffb742c66502cd5fde3e57709bae0d462f71
Author: Isis Lovecruft <isis at torproject.org>
Date:   Mon Apr 7 03:07:46 2014 +0000

    Change import of `random.randint`; only use one random value to create IP.
---
 lib/bridgedb/HTTPServer.py |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/bridgedb/HTTPServer.py b/lib/bridgedb/HTTPServer.py
index 40a69af..06ae2ed 100644
--- a/lib/bridgedb/HTTPServer.py
+++ b/lib/bridgedb/HTTPServer.py
@@ -9,6 +9,7 @@ This module implements the web (http, https) interfaces to the bridge database.
 import base64
 import gettext
 import logging
+import random
 import re
 import textwrap
 import time
@@ -42,7 +43,6 @@ from bridgedb.Filters import filterBridgesByTransport
 from bridgedb.Filters import filterBridgesByNotBlockedIn
 from bridgedb.parse import headers
 
-from random import randint
 
 
 template_root = os.path.join(os.path.dirname(__file__),'templates')
@@ -439,8 +439,8 @@ class ReCaptchaProtectedResource(CaptchaProtectedResource):
             remoteIP = self.recaptchaRemoteIP
         else:
             # generate a random IP for the captcha submission
-            remoteIP = '%d.%d.%d.%d' % (randint(1,255),randint(1,255),
-                                        randint(1,255),randint(1,255))
+            remoteIP = IPv4Address(random.randint(0, 2**32-1)).compressed
+
         return remoteIP
 
     def checkSolution(self, request):





More information about the tor-commits mailing list