aboutsummaryrefslogtreecommitdiffstats
path: root/tunnel.py
diff options
context:
space:
mode:
Diffstat (limited to 'tunnel.py')
-rw-r--r--tunnel.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tunnel.py b/tunnel.py
new file mode 100644
index 0000000..b8e7540
--- /dev/null
+++ b/tunnel.py
@@ -0,0 +1,18 @@
+import configparser
+import subprocess
+
+CONFIG = configparser.ConfigParser()
+CONFIG.read("tunnel.conf")
+
+cmd = ["ssh", "-nNTv"]
+
+if CONFIG.has_option("server", "ssh_port"):
+ cmd += ["-p", CONFIG.get("server", "ssh_port")]
+
+for section in CONFIG.sections():
+ if section.startswith("forward"):
+ cmd += ["-R", "%s:%s" % (CONFIG.get(section, "to"), CONFIG.get(section, "from"))]
+
+cmd.append(CONFIG.get("server", "host"))
+
+print("Using command: " + " ".join(cmd))