feat: auto add ssh forward ports

This commit is contained in:
2023-01-01 18:02:13 +01:00
parent d5fc16a4cc
commit 98b770afa1
2 changed files with 18 additions and 0 deletions

16
vm.py
View File

@@ -16,6 +16,7 @@ class VM:
self.isExternal = args.get("external")
self.noTerminateACME = args.get("no-terminate-acme")
self.ansible = not args.get("noansible")
self.sshOutsidePort = None
if self.isExternal:
self.lease = None
@@ -74,6 +75,21 @@ class VM:
return components
def dumpSshFowardsNginx(self):
components = []
template = self.environment.get_template("nginx_stream_block.conf.j2")
if not self.isExternal:
self.sshOutsidePort = 7000 + int(self.ip.split(".")[-1])
component = template.render(targetip=self.ip, udp=False,
portstring=self.sshOutsidePort,
targetportoverwrite=7000,
transparent=False, proxy_timeout="24h",
comment="ssh-{}".format(self.hostname))
components.append(component)
return components
def dumpIptables(self, remove=False):
entries = []