aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tunnel.conf11
-rw-r--r--tunnel.py18
2 files changed, 29 insertions, 0 deletions
diff --git a/tunnel.conf b/tunnel.conf
new file mode 100644
index 0000000..87998ed
--- /dev/null
+++ b/tunnel.conf
@@ -0,0 +1,11 @@
+[server]
+host = vps.eda.gay
+ssh_port = 2222
+
+[forward-eda.gay]
+from = 192.168.1.92:6969
+to = 0.0.0.0:6969
+
+[forward-invidious]
+from = 192.168.1.92:3000
+to = 0.0.0.0:3000
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))