fw rules: beautify rules escription

make it more nftables style:
 ip daddr 127.0.0.1 tcp dport 53 accept
instead of:
 ip daddr == 127.0.0.1 tcp dport == 53 accept

It'll be easier to translate our rules to nftables rules in this way.
This commit is contained in:
Gustavo Iñiguez Goia 2023-06-14 17:31:12 +02:00
parent 9bad34bb16
commit 77c3cf4512
Failed to generate hash of commit

View file

@ -2,6 +2,7 @@ from PyQt5.QtCore import QObject, pyqtSignal
from PyQt5.QtCore import QCoreApplication as QC
import uuid
from opensnitch import ui_pb2
from .enums import *
class Rules(QObject):
rulesUpdated = pyqtSignal()
@ -276,7 +277,15 @@ class Rules(QObject):
for e in rule.Expressions:
exprs += "{0} {1}".format(
e.Statement.Name,
"".join(["{0} {1} {2} ".format(h.Key, e.Statement.Op, h.Value) for h in e.Statement.Values ])
"".join(
[
"{0} {1}{2} ".format(
h.Key,
e.Statement.Op + " " if e.Statement.Op != Operator.EQUAL.value else "",
h.Value
) for h in e.Statement.Values
]
)
)
cols.append(exprs)
cols.append(rule.Target)