[tor-commits] [flashproxy/master] Allow forward_ports to forward multiple.

dcf at torproject.org dcf at torproject.org
Mon Jul 1 07:25:40 UTC 2013


commit c14004eac7e5bb90ca590884fb97693397070589
Author: David Fifield <david at bamsoftware.com>
Date:   Sun Jun 30 20:19:04 2013 -0700

    Allow forward_ports to forward multiple.
---
 flashproxy-client |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/flashproxy-client b/flashproxy-client
index 4bbcc28..e65a0a0 100755
--- a/flashproxy-client
+++ b/flashproxy-client
@@ -129,11 +129,13 @@ def safe_str(s):
     else:
         return s
 
-def forward_ports(external, internal):
+def forward_ports(pairs):
     script_path = os.path.join(get_script_dir(), "tor-fw-helper")
-    command = [script_path, "-p", "%d:%d" % (external, internal)]
+    command = [script_path]
+    for external, internal in pairs:
+        command += ["-p", "%d:%d" % (external, internal)]
     try:
-        log(u"Attempting NAT traversal for ports: %d:%d" % (external, internal))
+        log(u"Attempting NAT traversal for ports " + " ".join(["%d:%d" % p for p in pairs]))
         p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         stdout, stderr = p.communicate()
     except OSError, e:
@@ -1173,7 +1175,7 @@ def main():
 
     # Attempt to forward ports if requested.
     if options.port_forwarding:
-        forward_ports(remote_addr[1], remote_addr[1])
+        forward_ports(((remote_addr[1], remote_addr[1]),))
 
     # Remote sockets, accepting remote WebSocket connections from proxies.
     remote_listen = []





More information about the tor-commits mailing list