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:
parent
a6e4c8cbd7
commit
4a82ab0b06
1 changed files with 6 additions and 2 deletions
8
main.py
8
main.py
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue