[tor-commits] [flashproxy/master] Add --transport option to reg programs.

dcf at torproject.org dcf at torproject.org
Thu Oct 10 19:02:21 UTC 2013


commit bef75a430ad9f1aeb1a6be6fe4cd7f780be38e03
Author: David Fifield <david at bamsoftware.com>
Date:   Wed Oct 9 22:50:33 2013 -0700

    Add --transport option to reg programs.
---
 flashproxy-reg-appspot |    9 ++++++++-
 flashproxy-reg-email   |    7 ++++++-
 flashproxy-reg-http    |    7 ++++++-
 flashproxy-reg-url     |    9 +++++++--
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/flashproxy-reg-appspot b/flashproxy-reg-appspot
index 163ec24..dc8a5aa 100755
--- a/flashproxy-reg-appspot
+++ b/flashproxy-reg-appspot
@@ -93,10 +93,13 @@ external IP address is guessed).
                         encrypt registrations to the given PEM-formatted
                           public key (default built-in).
   -h, --help            show this help.
+      --transport=TRANSPORT  register using the given transport
+                          (default "%(transport)s").
       --unsafe-logging  don't scrub IP addresses from logs.\
 """ % {
     "progname": sys.argv[0],
     "remote_addr": format_addr((DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)),
+    "transport": DEFAULT_TRANSPORT,
 }
 
 def safe_str(s):
@@ -182,6 +185,8 @@ def generate_url(addr):
         raise ValueError("Can't find executable directory for registration helpers")
     command = [os.path.join(script_dir, FLASHPROXY_REG_URL)]
     command += ["-f", urlparse.urlunparse(("https", FRONT_DOMAIN, "/", "", "", ""))]
+    if options.transport is not None:
+        command += ["--transport", options.transport]
     if options.facilitator_pubkey_filename is not None:
         command += ["--facilitator-pubkey", options.facilitator_pubkey_filename]
     command.append(format_addr(addr))
@@ -267,7 +272,7 @@ def get_external_ip():
     finally:
         f.close()
 
-opt, args = getopt.gnu_getopt(sys.argv[1:], "46h", ["disable-pin", "facilitator-pubkey=", "help", "unsafe-logging"])
+opt, args = getopt.gnu_getopt(sys.argv[1:], "46h", ["disable-pin", "facilitator-pubkey=", "help", "transport=", "unsafe-logging"])
 for o, a in opt:
     if o == "-4":
         options.address_family = socket.AF_INET
@@ -280,6 +285,8 @@ for o, a in opt:
     elif o == "-h" or o == "--help":
         usage()
         sys.exit()
+    elif o == "--transport":
+        options.transport = a
     elif o == "--unsafe-logging":
         options.safe_logging = False
 
diff --git a/flashproxy-reg-email b/flashproxy-reg-email
index add5e97..95edfbf 100755
--- a/flashproxy-reg-email
+++ b/flashproxy-reg-email
@@ -122,12 +122,15 @@ This program requires the M2Crypto library for Python.
   -h, --help              show this help.
   -s, --smtp=HOST[:PORT]  use the given SMTP server
                             (default "%(smtp_addr)s").
+      --transport=TRANSPORT  register using the given transport
+                            (default "%(transport)s").
       --unsafe-logging    don't scrub IP addresses from logs.\
 """ % {
     "progname": sys.argv[0],
     "remote_addr": format_addr((DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)),
     "email_addr": DEFAULT_EMAIL_ADDRESS,
     "smtp_addr": format_addr((DEFAULT_SMTP_HOST, DEFAULT_SMTP_PORT)),
+    "transport": DEFAULT_TRANSPORT,
 }
 
 def safe_str(s):
@@ -218,7 +221,7 @@ def get_facilitator_pubkey():
 options.email_addr = DEFAULT_EMAIL_ADDRESS
 options.smtp_addr = (DEFAULT_SMTP_HOST, DEFAULT_SMTP_PORT)
 
-opts, args = getopt.gnu_getopt(sys.argv[1:], "46de:hs:", ["debug", "disable-pin", "email=", "facilitator-pubkey=", "help", "smtp=", "unsafe-logging"])
+opts, args = getopt.gnu_getopt(sys.argv[1:], "46de:hs:", ["debug", "disable-pin", "email=", "facilitator-pubkey=", "help", "smtp=", "transport=", "unsafe-logging"])
 for o, a in opts:
     if o == "-4":
         options.address_family = socket.AF_INET
@@ -237,6 +240,8 @@ for o, a in opts:
         sys.exit()
     elif o == "-s" or o == "--smtp":
         options.smtp_addr = parse_addr_spec(a, DEFAULT_SMTP_HOST, DEFAULT_SMTP_PORT)
+    elif o == "--transport":
+        options.transport = a
     elif o == "--unsafe-logging":
         options.safe_logging = False
 
diff --git a/flashproxy-reg-http b/flashproxy-reg-http
index 4c776c3..100edd9 100755
--- a/flashproxy-reg-http
+++ b/flashproxy-reg-http
@@ -32,11 +32,14 @@ remote address registered is "%(remote_addr)s".
   -f, --facilitator=URL  register with the given facilitator
                            (default "%(fac_url)s").
   -h, --help             show this help.
+      --transport=TRANSPORT  register using the given transport
+                           (default "%(transport)s").
       --unsafe-logging   don't scrub IP addresses from logs.\
 """ % {
     "progname": sys.argv[0],
     "fac_url": DEFAULT_FACILITATOR_URL,
     "remote_addr": format_addr((DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)),
+    "transport": DEFAULT_TRANSPORT,
 }
 
 def safe_str(s):
@@ -108,7 +111,7 @@ def build_reg(addr, transport):
 options.facilitator_url = DEFAULT_FACILITATOR_URL
 options.remote_addr = (DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)
 
-opts, args = getopt.gnu_getopt(sys.argv[1:], "46f:h", ["facilitator=", "help", "unsafe-logging"])
+opts, args = getopt.gnu_getopt(sys.argv[1:], "46f:h", ["facilitator=", "help", "transport=", "unsafe-logging"])
 for o, a in opts:
     if o == "-4":
         options.address_family = socket.AF_INET
@@ -119,6 +122,8 @@ for o, a in opts:
     elif o == "-h" or o == "--help":
         usage()
         sys.exit()
+    elif o == "--transport":
+        options.transport = a
     elif o == "--unsafe-logging":
         options.safe_logging = False
 
diff --git a/flashproxy-reg-url b/flashproxy-reg-url
index e947650..c8ebd44 100755
--- a/flashproxy-reg-url
+++ b/flashproxy-reg-url
@@ -47,11 +47,14 @@ default PORT is %(port)d.
       --facilitator-pubkey=FILENAME
                          encrypt registrations to the given PEM-formatted
                            public key (default built-in).
-  -h, --help             show this help.\
+  -h, --help             show this help.
+      --transport=TRANSPORT  register using the given transport
+                           (default "%(transport)s").\
 """ % {
     "progname": sys.argv[0],
     "fac_url": DEFAULT_FACILITATOR_URL,
     "port": DEFAULT_REMOTE_PORT,
+    "transport": DEFAULT_TRANSPORT,
 }
 
 def parse_addr_spec(spec, defhost = None, defport = None):
@@ -118,7 +121,7 @@ def get_facilitator_pubkey():
 
 options.facilitator_url = DEFAULT_FACILITATOR_URL
 
-opt, args = getopt.gnu_getopt(sys.argv[1:], "f:h", ["facilitator=", "facilitator-pubkey=", "help"])
+opt, args = getopt.gnu_getopt(sys.argv[1:], "f:h", ["facilitator=", "facilitator-pubkey=", "help", "transport="])
 for o, a in opt:
     if o == "-f" or o == "--facilitator":
         options.facilitator_url = a
@@ -127,6 +130,8 @@ for o, a in opt:
     elif o == "-h" or o == "--help":
         usage()
         sys.exit()
+    elif o == "--transport":
+        options.transport = a
 
 if len(args) != 1:
     usage(sys.stderr)





More information about the tor-commits mailing list