commit 6eccd89f1c83b98047e47dd9d9db04a668b1d084 Author: David Fifield david@bamsoftware.com Date: Thu Oct 17 04:38:05 2013 -0700
Use read_client_registrations in facilitator.cgi.
This takes care of the other registration mechanism (apart from facilitator-reg-daemon). Now we're using the client=addr:port&client-transport=websocket style, rather than the client-websocket=addr:port style.
This is basically the same as the facilitator.cgi part of "New unified url-param syntax for both facilitator responses and client registrations." https://github.com/infinity0/flashproxy/commit/0377b7aba8026710bd2168b6ceb31... --- facilitator/facilitator.cgi | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
diff --git a/facilitator/facilitator.cgi b/facilitator/facilitator.cgi index 05286fd..47497b0 100755 --- a/facilitator/facilitator.cgi +++ b/facilitator/facilitator.cgi @@ -92,7 +92,8 @@ def do_post(): # Old style client registration: # client=1.2.3.4:9000 # New style client registration: - # client-websocket=1.2.3.4:9000&client-obfs3|websocket=1.2.3.4:10000 + # 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) @@ -101,29 +102,15 @@ def do_post(): # 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. - for key in fs.keys(): - if key != "client" and not key.startswith("client-"): - continue - - if key == "client": # reg without transport info -- default to websocket. - transport = "websocket" - else: # reg with transport info -- get the "websocket" part out of "client-websocket". - 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() - try: - client_addr = fac.parse_addr_spec(client_spec, defhost=remote_addr[0]) - except ValueError: - exit_error(400) - - # XXX what if previous registrations passed through - # successfully, but the last one failed and called - # exit_error()? + try: + regs = list(fac.read_client_registrations(sys.stdin.read(), defhost=remote_addr[0])) + except ValueError: + exit_error(400)
+ for reg in regs: # 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): + # when one is answerered (or errors) the rest are invalidated. + if not fac.put_reg(FACILITATOR_ADDR, reg.addr, reg.transport): exit_error(500)
print """\