[tor-commits] [flashproxy/master] Make separate reg pools for IPv4 and IPv6.

dcf at torproject.org dcf at torproject.org
Sun Dec 23 09:11:59 UTC 2012


commit 356b4e5e52403e07e4d7c3ae677620413cfef8f2
Author: David Fifield <david at bamsoftware.com>
Date:   Wed Dec 19 19:16:43 2012 -0800

    Make separate reg pools for IPv4 and IPv6.
    
    This is only cosmetic at the moment, as all regs will go into the IPv4
    pool.
---
 facilitator/facilitator |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/facilitator/facilitator b/facilitator/facilitator
index 97155ca..c1cf89a 100755
--- a/facilitator/facilitator
+++ b/facilitator/facilitator
@@ -234,10 +234,10 @@ class Handler(SocketServer.StreamRequestHandler):
         print >> self.wfile, "ERROR"
 
     def do_GET(self, params):
-        reg = REGS.fetch()
+        reg = REGS_IPV4.fetch()
         if reg:
             log(u"proxy gets %s, relay %s (now %d)" %
-                (safe_str(unicode(reg)), options.relay_spec, len(REGS)))
+                (safe_str(unicode(reg)), options.relay_spec, num_regs()))
             print >> self.wfile, fac.render_transaction("OK", ("CLIENT", str(reg)), ("RELAY", options.relay_spec))
         else:
             log(u"proxy gets none")
@@ -260,10 +260,10 @@ class Handler(SocketServer.StreamRequestHandler):
             self.send_error()
             return False
 
-        if REGS.add(reg):
-            log(u"client %s (now %d)" % (safe_str(unicode(reg)), len(REGS)))
+        if REGS_IPV4.add(reg):
+            log(u"client %s (now %d)" % (safe_str(unicode(reg)), num_regs()))
         else:
-            log(u"client %s (already present, now %d)" % (safe_str(unicode(reg)), len(REGS)))
+            log(u"client %s (already present, now %d)" % (safe_str(unicode(reg)), num_regs()))
 
         self.send_ok()
         return True
@@ -273,7 +273,13 @@ class Handler(SocketServer.StreamRequestHandler):
 class Server(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
     allow_reuse_address = True
 
-REGS = RegSet()
+# Separate pools for IPv4 and IPv6 clients.
+REGS_IPV4 = RegSet()
+REGS_IPV6 = RegSet()
+
+def num_regs():
+    """Return the total number of registrations."""
+    return len(REGS_IPV4) + len(REGS_IPV6)
 
 def main():
     opts, args = getopt.gnu_getopt(sys.argv[1:], "dhl:p:r:",





More information about the tor-commits mailing list