Modify create_rule to support multiple ports as a list.

Updated the `create_rule` function to handle a list of ports by joining them into a comma-separated string. This enhances flexibility, allowing both single port and multiple port configurations for port forwarding rules.
This commit is contained in:
Nick Guy 2025-06-17 17:56:03 +01:00
parent a6e4c8cbd7
commit 4a82ab0b06

View file

@ -16,8 +16,12 @@ from flask import Flask, request
RULE_PREFIX = "[auto]::"
def create_rule(label, address, port):
return asusrouter.modules.port_forwarding.PortForwardingRule(RULE_PREFIX + label, address, None, "BOTH", None, port)
def create_rule(label, address, ports):
if isinstance(ports, list):
ports = ",".join(ports)
return asusrouter.modules.port_forwarding.PortForwardingRule(RULE_PREFIX + label, address, None, "BOTH", None, ports)
def rule_to_string(rule: asusrouter.modules.port_forwarding.PortForwardingRule):