mirror of
https://github.com/FAUSheppy/athq-vm-management
synced 2025-12-06 13:51:35 +01:00
feat: configurate interfaces for listen directive
This commit is contained in:
@@ -1,8 +1,26 @@
|
|||||||
server {
|
server {
|
||||||
|
|
||||||
# {{ comment }}
|
# {{ comment }}
|
||||||
|
{% if port_interfaces %}
|
||||||
|
|
||||||
|
{% if "ipv4-all" in port_interfaces %}
|
||||||
|
listen {{ portstring }} {% if udp %} udp {% endif %}{% if ssl %} ssl {% endif %};
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if "ipv6-all" in port_interfaces %}
|
||||||
|
listen [::]:{{ portstring }} {% if udp %} udp {% endif %}{% if ssl %} ssl {% endif %};
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for pi in port_interfaces %}
|
||||||
|
{% if not pi.startswith("ipv") %}
|
||||||
|
listen {{ pi }}:{{ portstring }} {% if udp %} udp {% endif %}{% if ssl %} ssl {% endif %};
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% else %}
|
||||||
listen {{ portstring }} {% if udp %} udp {% endif %}{% if ssl %} ssl {% endif %};
|
listen {{ portstring }} {% if udp %} udp {% endif %}{% if ssl %} ssl {% endif %};
|
||||||
listen [::]:{{ portstring }} {% if udp %} udp {% endif %}{% if ssl %} ssl {% endif %};
|
listen [::]:{{ portstring }} {% if udp %} udp {% endif %}{% if ssl %} ssl {% endif %};
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if not extra_content or not "proxy_timeout" in extra_content %}
|
{% if not extra_content or not "proxy_timeout" in extra_content %}
|
||||||
proxy_timeout {{ proxy_timeout }};
|
proxy_timeout {{ proxy_timeout }};
|
||||||
|
|||||||
6
vm.py
6
vm.py
@@ -62,6 +62,8 @@ class VM:
|
|||||||
|
|
||||||
name = str(portStruct.get("name")).replace(" ", "")
|
name = str(portStruct.get("name")).replace(" ", "")
|
||||||
portstring = str(portStruct.get("port")).replace(" ", "")
|
portstring = str(portStruct.get("port")).replace(" ", "")
|
||||||
|
port_interfaces = portStruct.get("interfaces")
|
||||||
|
assert(port_interfaces is None or type(port_interfaces) == list)
|
||||||
transparent = portStruct.get("transparent")
|
transparent = portStruct.get("transparent")
|
||||||
proto = portStruct.get("proto") or "tcp"
|
proto = portStruct.get("proto") or "tcp"
|
||||||
isUDP = proto == "udp"
|
isUDP = proto == "udp"
|
||||||
@@ -75,7 +77,9 @@ class VM:
|
|||||||
|
|
||||||
component = template.render(targetip=self.ip, udp=isUDP, portstring=portstring,
|
component = template.render(targetip=self.ip, udp=isUDP, portstring=portstring,
|
||||||
transparent=transparent, proxy_timeout=proxy_timeout,
|
transparent=transparent, proxy_timeout=proxy_timeout,
|
||||||
comment=compositeName, extra_content=extra_content)
|
comment=compositeName, extra_content=extra_content,
|
||||||
|
port_interfaces=port_interfaces)
|
||||||
|
|
||||||
components.append(component)
|
components.append(component)
|
||||||
|
|
||||||
return components
|
return components
|
||||||
|
|||||||
Reference in New Issue
Block a user