[tor-commits] [flashproxy/master] Make the remote addr a command-line argument in registration helpers.

dcf at torproject.org dcf at torproject.org
Tue Sep 11 14:25:32 UTC 2012


commit f63a12411756bbb72f8ac53c22ec9afa6f243dab
Author: David Fifield <david at bamsoftware.com>
Date:   Tue Sep 11 07:05:49 2012 -0700

    Make the remote addr a command-line argument in registration helpers.
    
    Before, you registered a remote :1111 with fac.example.com like so:
    	flashproxy-reg-http -a :1111 fac.example.com
    Now it is like this:
    	flashproxy-reg-http -f fac.example.com :1111
    
    Not all registration helpers will have knowledge of a facilitator
    address, and I want them to have as uniform an interface as possible.
    Using -f for the facilitator address also matches flashproxy-client
    usage.
---
 flashproxy-client   |    4 ++--
 flashproxy-reg-http |   17 +++++++++--------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/flashproxy-client b/flashproxy-client
index dfe060f..f5c9a8b 100755
--- a/flashproxy-client
+++ b/flashproxy-client
@@ -639,8 +639,8 @@ def register():
     if options.facilitator_addr is None:
         log(u"Registering \"%s\"." % spec)
     else:
-        command += [format_addr(options.facilitator_addr)]
-    command += ["-a", spec]
+        command += ["-f", format_addr(options.facilitator_addr)]
+    command += [spec]
     try:
         p = subprocess.Popen(command)
     except OSError, e:
diff --git a/flashproxy-reg-http b/flashproxy-reg-http
index 1c989c0..e17abdf 100755
--- a/flashproxy-reg-http
+++ b/flashproxy-reg-http
@@ -18,12 +18,13 @@ class options(object):
 
 def usage(f = sys.stdout):
     print >> f, """\
-Usage: %(progname)s [HOSTNAME][:PORT]
+Usage: %(progname)s [REMOTE][:PORT]
 Register with a flash proxy facilitator using an HTTP POST. By default the
-facilitator address is "%(fac_addr)s".
+remote address registered is "%(remote_addr)s".
 
-  -a, --address=ADDRESS  register the given address instead of \"%(remote_addr)s\".
-  -h, --help             show this help. \
+  -f, --facilitator=HOST[:PORT]  register with the given facilitator (by
+                                   default "%(fac_addr)s".)
+  -h, --help                     show this help. \
 """ % {
     "progname": sys.argv[0],
     "fac_addr": format_addr((DEFAULT_FACILITATOR_HOST, DEFAULT_FACILITATOR_PORT)),
@@ -86,10 +87,10 @@ def format_addr(addr):
 options.facilitator_addr = (DEFAULT_FACILITATOR_HOST, DEFAULT_FACILITATOR_PORT)
 options.remote_addr = (DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)
 
-opts, args = getopt.gnu_getopt(sys.argv[1:], "a:h", ["address=", "help"])
+opts, args = getopt.gnu_getopt(sys.argv[1:], "f:h", ["facilitator=", "help"])
 for o, a in opts:
-    if o == "-a" or o == "--address":
-        options.remote_addr = parse_addr_spec(a, DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)
+    if o == "-f" or o == "--facilitator":
+        options.facilitator_addr = parse_addr_spec(a, DEFAULT_FACILITATOR_HOST, DEFAULT_FACILITATOR_PORT)
     elif o == "-h" or o == "--help":
         usage()
         sys.exit()
@@ -97,7 +98,7 @@ for o, a in opts:
 if len(args) == 0:
     pass
 elif len(args) == 1:
-    options.facilitator_addr = parse_addr_spec(args[0], DEFAULT_FACILITATOR_HOST, DEFAULT_FACILITATOR_PORT)
+    options.remote_addr = parse_addr_spec(args[0], DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)
 else:
     usage(sys.stderr)
     sys.exit(1)



More information about the tor-commits mailing list