[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [flashproxy/master] Make separate reg pools for IPv4 and IPv6.
commit 356b4e5e52403e07e4d7c3ae677620413cfef8f2
Author: David Fifield <david@xxxxxxxxxxxxxxx>
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:",
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits