[tor-commits] [flashproxy/master] drop the "chain" terminology and use PROXY_TRANSPORT to describe the proxy's capabilities

infinity0 at torproject.org infinity0 at torproject.org
Mon Oct 28 14:47:41 UTC 2013


commit 011e04c8856fc768e53374bf9c83667ac5d40af1
Author: Ximin Luo <infinity0 at gmx.com>
Date:   Mon Oct 7 16:54:33 2013 +0100

    drop the "chain" terminology and use PROXY_TRANSPORT to describe the proxy's capabilities
---
 facilitator/fac.py          |   12 ++++--------
 facilitator/facilitator     |   17 ++++++++---------
 facilitator/facilitator.cgi |    6 +++---
 3 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/facilitator/fac.py b/facilitator/fac.py
index c08ee2a..9cbfa79 100644
--- a/facilitator/fac.py
+++ b/facilitator/fac.py
@@ -250,14 +250,12 @@ def transact(f, command, *params):
         raise ValueError("No newline at end of string returned by facilitator: %r" % line)
     return parse_transaction(line[:-1])
 
-def put_reg(facilitator_addr, client_addr, transport_chain, registrant_addr=None):
+def put_reg(facilitator_addr, client_addr, transport, registrant_addr=None):
     """Send a registration to the facilitator using a one-time socket. Returns
     true iff the command was successful."""
-    # TODO(infinity0): replace "transport_chain" with better terminology, e.g.
-    # transport_pair
     f = fac_socket(facilitator_addr)
     params = [("CLIENT", format_addr(client_addr))]
-    params.append(("TRANSPORT_CHAIN", transport_chain))
+    params.append(("TRANSPORT", transport))
     if registrant_addr is not None:
         params.append(("FROM", format_addr(registrant_addr)))
     try:
@@ -266,7 +264,7 @@ def put_reg(facilitator_addr, client_addr, transport_chain, registrant_addr=None
         f.close()
     return command == "OK"
 
-def get_reg(facilitator_addr, proxy_addr, transport_list):
+def get_reg(facilitator_addr, proxy_addr, proxy_transport_list):
     """
     Get a client registration for proxy 'proxy_addr' from the
     facilitator at 'facilitator_addr' using a one-time
@@ -277,15 +275,13 @@ def get_reg(facilitator_addr, proxy_addr, transport_list):
     "relay-<transport>" if successful, or a dict with the key "client"
     mapped to the value "" if there are no registrations available for
     proxy_addr. Raises an exception otherwise."""
-    # TODO(infinity0): replace "transport_list" with better terminology, e.g.
-    # transport_suffix_list
     f = fac_socket(facilitator_addr)
 
     # Form a list (in transact() format) with the transports that we
     # should send to the facilitator.  Then pass that list to the
     # transact() function.
     # For example, TRANSPORT=obfs2 TRANSPORT=obfs3.
-    transports = [("TRANSPORT", transport) for transport in transport_list]
+    transports = [("PROXY_TRANSPORT", tp) for tp in proxy_transport_list]
 
     try:
         command, params = transact(f, "GET", ("FROM", format_addr(proxy_addr)), *transports)
diff --git a/facilitator/facilitator b/facilitator/facilitator
index d4088ff..9c8de92 100755
--- a/facilitator/facilitator
+++ b/facilitator/facilitator
@@ -111,8 +111,7 @@ class Reg(namedtuple("Reg", "addr transport")):
 
 class Endpoints(object):
     """
-    Tracks endpoints (either client/server) and the transport chains that
-    they support.
+    Tracks endpoints (either client/server) and the transports they support.
     """
 
     matchingLock = threading.Condition()
@@ -357,9 +356,9 @@ class Handler(SocketServer.StreamRequestHandler):
         except ValueError as e:
             return self.error(u"syntax error in proxy address %s: %%(cause)s" % safe_str(repr(proxy_spec)), e)
 
-        transport_list = fac.param_getlist("TRANSPORT", params)
+        transport_list = fac.param_getlist("PROXY_TRANSPORT", params)
         if not transport_list:
-            return self.error(u"TRANSPORT missing FROM param")
+            return self.error(u"PROXY_TRANSPORT missing FROM param")
 
         try:
             client_reg, relay_reg = get_match_for_proxy(proxy_addr, transport_list)
@@ -382,15 +381,15 @@ class Handler(SocketServer.StreamRequestHandler):
         return True
 
     # Handle a PUT request (client made a registration request; register it.)
-    # Example: PUT CLIENT="1.1.1.1:5555" TRANSPORT_CHAIN="obfs3|websocket"
+    # Example: PUT CLIENT="1.1.1.1:5555" TRANSPORT="obfs3|websocket"
     def do_PUT(self, params):
-        # Check out if we recognize the transport chain in this registration request
-        transport = fac.param_first("TRANSPORT_CHAIN", params)
+        # Check out if we recognize the transport in this registration request
+        transport = fac.param_first("TRANSPORT", params)
         if transport is None:
-            return self.error(u"PUT missing TRANSPORT_CHAIN param")
+            return self.error(u"PUT missing TRANSPORT param")
 
         transport = Transport.parse(transport)
-        # See if we have relays that support this transport chain
+        # See if we have relays that support this transport
         if all(not pts.supports(transport) for pts in SERVERS.itervalues()):
             return self.error(u"Unrecognized transport: %s" % transport)
 
diff --git a/facilitator/facilitator.cgi b/facilitator/facilitator.cgi
index c3eadf4..a68d84e 100755
--- a/facilitator/facilitator.cgi
+++ b/facilitator/facilitator.cgi
@@ -107,9 +107,9 @@ def do_post():
             continue
 
         if key == "client": # reg without transport info -- default to websocket.
-            transport_chain = "websocket"
+            transport = "websocket"
         else: # reg with transport info -- get the "websocket" part out of "client-websocket".
-            transport_chain = key[len("client-"):]
+            transport = key[len("client-"):]
 
         # Get the "1.2.3.4:9000" part of "client-websocket=1.2.3.4:9000".
         client_spec = fs[key].value.strip()
@@ -124,7 +124,7 @@ def do_post():
 
         # XXX need to link these registrations together, so that
         # when one is answerered the rest are invalidated.
-        if not fac.put_reg(FACILITATOR_ADDR, client_addr, transport_chain, remote_addr):
+        if not fac.put_reg(FACILITATOR_ADDR, client_addr, transport, remote_addr):
             exit_error(500)
 
     print """\





More information about the tor-commits mailing list