commit adda03fda6a091fe3184e8c8eefcdc23e2ef4620 Author: David Fifield david@bamsoftware.com Date: Thu Oct 17 04:59:58 2013 -0700
Remove some outdated comments.
Move documentation of the registration message format to read_client_registrations. --- facilitator/fac.py | 14 ++++++++++++-- facilitator/facilitator.cgi | 11 ----------- 2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/facilitator/fac.py b/facilitator/fac.py index a1ac614..d7d108e 100644 --- a/facilitator/fac.py +++ b/facilitator/fac.py @@ -162,7 +162,16 @@ def get_single(qs, key, default=None): return vals[0]
def read_client_registrations(body, defhost=None, defport=None): - """Parse the lines of body and yield an Endpoint for each.""" + """Yield client registrations (as Endpoints) from an encoded registration + message body. The message format is one registration per line, with each + line being encoded as application/x-www-form-urlencoded. The key "client" is + required and contains the client address and port (perhaps filled in by + defhost and defport). The key "client-transport" is optional and defaults to + "websocket". + Example: + client=1.2.3.4:9000&client-transport=websocket + client=1.2.3.4:9090&client-transport=obfs3|websocket + """ for line in body.splitlines(): qs = urlparse.parse_qs(line, keep_blank_values=True, strict_parsing=True) addr = parse_addr_spec(get_single(qs, "client"), defhost, defport) @@ -305,7 +314,8 @@ def transact(f, command, *params):
def put_reg(facilitator_addr, client_addr, transport): """Send a registration to the facilitator using a one-time socket. Returns - true iff the command was successful.""" + true iff the command was successful. transport is a transport string such as + "websocket" or "obfs3|websocket".""" f = fac_socket(facilitator_addr) params = [("CLIENT", format_addr(client_addr))] params.append(("TRANSPORT", transport)) diff --git a/facilitator/facilitator.cgi b/facilitator/facilitator.cgi index e8b658e..42a888e 100755 --- a/facilitator/facilitator.cgi +++ b/facilitator/facilitator.cgi @@ -89,20 +89,9 @@ Access-Control-Allow-Origin: *\r def do_post(): """Parse client registration."""
- # Old style client registration: - # client=1.2.3.4:9000 - # New style client registration: - # client-addr=1.2.3.4:9000&client-transport=websocket - # client-addr=1.2.3.4:9090&client-transport=obfs3|websocket - if path_info != "/": exit_error(400)
- # We iterate through the items in the POST body, and see if any of - # them look like "client-websocket=1.2.3.4:9000". We then split - # all those items and send them as separate registrations to the - # facilitator. - # # We treat sys.stdin as being a bunch of newline-separated query strings. I # think that this is technically a violation of the # application/x-www-form-urlencoded content-type the client likely used, but
tor-commits@lists.torproject.org