From 8501f494c6938e1979cb4738d86057eee41ad5fe Mon Sep 17 00:00:00 2001 From: Sheppy Date: Wed, 21 Dec 2022 21:44:53 +0100 Subject: [PATCH] fix: portstring & newline --- vm.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vm.py b/vm.py index 7f91f28..9d93403 100644 --- a/vm.py +++ b/vm.py @@ -52,9 +52,8 @@ class VM: entries = [] BASE = "iptables -t mangle -{option} " - RULE = "PREROUTING -p {proto} -s {ip} {port} -j MARK --set-xmark 0x1/0xffffffff" + RULE = "PREROUTING -p {proto} -s {ip} {port} -j MARK --set-xmark 0x1/0xffffffff\n" PORT_SIMPLE = "--sport {port}" - PORT_MULTI = "--match multiport --sports {port}" option = "A" if remove: @@ -66,8 +65,8 @@ class VM: port = portStruct.get("port") partport = PORT_SIMPLE.format(port=port) if type(port) == str and "-" in port: - port = port.replace("-", "") - part_port = PORT_MULTI.format(port=port) + port = port.replace("-", ":").replace(" ","") + partport = PORT_SIMPLE.format(port=port) entry = BASE.format(option=option) entry += RULE.format(ip=self.ip, port=partport, proto=portStruct.get("proto", "tcp"))