56 lines
2.2 KiB
Diff
56 lines
2.2 KiB
Diff
From cd8e0c3774a6c7ca6679fd50a0fb6f211528d9cc Mon Sep 17 00:00:00 2001
|
|
From: Eric Garver <eric@garver.life>
|
|
Date: Thu, 19 Mar 2020 16:22:18 -0400
|
|
Subject: [PATCH] improvement: port: simplify queryPort
|
|
|
|
---
|
|
src/firewall/core/fw_zone.py | 10 +++-------
|
|
src/firewall/server/config_zone.py | 10 +++-------
|
|
2 files changed, 6 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/src/firewall/core/fw_zone.py b/src/firewall/core/fw_zone.py
|
|
index 5cda560..59d7a44 100644
|
|
--- a/src/firewall/core/fw_zone.py
|
|
+++ b/src/firewall/core/fw_zone.py
|
|
@@ -914,13 +914,9 @@ class FirewallZone(object):
|
|
del _obj.settings["ports"][port_id]
|
|
|
|
def query_port(self, zone, port, protocol):
|
|
- if self.__port_id(port, protocol) in self.get_settings(zone)["ports"]:
|
|
- return True
|
|
- else:
|
|
- # It might be a single port query that is inside a range
|
|
- for (_port, _protocol) in self.get_settings(zone)["ports"]:
|
|
- if portInPortRange(port, _port) and protocol == _protocol:
|
|
- return True
|
|
+ for (_port, _protocol) in self.get_settings(zone)["ports"]:
|
|
+ if portInPortRange(port, _port) and protocol == _protocol:
|
|
+ return True
|
|
|
|
return False
|
|
|
|
diff --git a/src/firewall/server/config_zone.py b/src/firewall/server/config_zone.py
|
|
index ed4eaba..bbbe7b5 100644
|
|
--- a/src/firewall/server/config_zone.py
|
|
+++ b/src/firewall/server/config_zone.py
|
|
@@ -484,13 +484,9 @@ class FirewallDConfigZone(slip.dbus.service.Object):
|
|
protocol = dbus_to_python(protocol, str)
|
|
log.debug1("%s.queryPort('%s', '%s')", self._log_prefix, port,
|
|
protocol)
|
|
- if (port,protocol) in self.getSettings()[6]:
|
|
- return True
|
|
- else:
|
|
- # It might be a single port query that is inside a range
|
|
- for (_port, _protocol) in self.getSettings()[6]:
|
|
- if portInPortRange(port, _port) and protocol == _protocol:
|
|
- return True
|
|
+ for (_port, _protocol) in self.getSettings()[6]:
|
|
+ if portInPortRange(port, _port) and protocol == _protocol:
|
|
+ return True
|
|
|
|
return False
|
|
|
|
--
|
|
1.8.3.1
|
|
|