[tor-commits] [flashproxy/master] Command-line parameters are optional in flashproxy-reg-appspot.
dcf at torproject.org
dcf at torproject.org
Sun May 19 16:11:39 UTC 2013
commit 112406b409531ae990dce9d3e7e246d0fba8528b
Author: David Fifield <david at bamsoftware.com>
Date: Sat May 18 22:49:33 2013 -0700
Command-line parameters are optional in flashproxy-reg-appspot.
---
flashproxy-reg-appspot | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/flashproxy-reg-appspot b/flashproxy-reg-appspot
index f0c5d5e..dddf7ec 100755
--- a/flashproxy-reg-appspot
+++ b/flashproxy-reg-appspot
@@ -48,10 +48,10 @@ class options(object):
def usage(f = sys.stdout):
print >> f, """\
-Usage: %(progname)s REMOTE[:PORT]
-Print a URL, which, when retrieved, will cause the client address
-REMOTE[:PORT] to be registered with the flash proxy facilitator. The
-default PORT is %(port)d.
+Usage: %(progname)s [REMOTE][:PORT]
+Register with a flash proxy facilitator through a Google App Engine app.
+By default the remote address registered is "%(remote_addr)s" (the
+external IP address is guessed).
-f, --facilitator=URL register with the given facilitator
(by default "%(fac_url)s").
@@ -61,8 +61,8 @@ default PORT is %(port)d.
-h, --help show this help.\
""" % {
"progname": sys.argv[0],
+ "remote_addr": format_addr((DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)),
"fac_url": DEFAULT_FACILITATOR_URL,
- "port": DEFAULT_REMOTE_PORT,
}
def parse_addr_spec(spec, defhost = None, defport = None):
@@ -127,16 +127,20 @@ for o, a in opt:
usage()
sys.exit()
-if len(args) != 1:
+if len(args) == 0:
+ remote_addr = (DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)
+elif len(args) == 1:
+ remote_addr = parse_addr_spec(args[0], DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)
+else:
usage(sys.stderr)
sys.exit(1)
-remote_addr = parse_addr_spec(args[0], DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)
if not remote_addr[0]:
- remote_addr = parse_addr_spec(get_external_ip(), defport=remote_addr[1])
-if not remote_addr[0]:
- print >> sys.stderr, "Could not determine external ip address."
- sys.exit(1)
+ spec = get_external_ip()
+ remote_addr = parse_addr_spec(spec, *remote_addr)
+ if not remote_addr[0]:
+ print >> sys.stderr, "Could not determine external ip address."
+ sys.exit(1)
spec = format_addr(remote_addr)
reg_plain = (u"client=%s" % spec).encode("utf-8")
More information about the tor-commits
mailing list