mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 00:24:40 +01:00
ui, fw: fixed adding rules when using service name
We were failing adding system fw rules when the user selected a destination port by service name. We allow to specify port ranges with '-' (8080-8088), and as some service names contain '-' in the name (ftp-data, netbios-ns), it was failing.
This commit is contained in:
parent
ced8410d43
commit
0dfec48120
2 changed files with 18 additions and 6 deletions
|
@ -1445,10 +1445,10 @@ The value must be in the format: VALUE/UNITS/TIME, for example:
|
||||||
# 3. otherwise validate that the entered value is an
|
# 3. otherwise validate that the entered value is an
|
||||||
# int
|
# int
|
||||||
try:
|
try:
|
||||||
if "," in statem_value or "-" in statem_value:
|
|
||||||
raise ValueError("port entered is multiport or a port range")
|
|
||||||
service_idx = self.net_srv.service_by_name(statem_value)
|
service_idx = self.net_srv.service_by_name(statem_value)
|
||||||
statem_value = self.net_srv.port_by_index(service_idx)
|
statem_value = self.net_srv.port_by_index(service_idx)
|
||||||
|
if service_idx > 0 and "," in statem_value or "-" in statem_value:
|
||||||
|
raise ValueError("port entered is multiport or a port range")
|
||||||
except:
|
except:
|
||||||
if "," not in statem_value and "-" not in statem_value:
|
if "," not in statem_value and "-" not in statem_value:
|
||||||
if not self._is_valid_int_value(statem_value):
|
if not self._is_valid_int_value(statem_value):
|
||||||
|
|
|
@ -435,16 +435,28 @@ class NetworkServices():
|
||||||
return self.srv_array
|
return self.srv_array
|
||||||
|
|
||||||
def service_by_index(self, idx):
|
def service_by_index(self, idx):
|
||||||
return self.srv_array[idx]
|
try:
|
||||||
|
return self.srv_array[idx]
|
||||||
|
except:
|
||||||
|
return ""
|
||||||
|
|
||||||
def service_by_name(self, name):
|
def service_by_name(self, name):
|
||||||
return self.srv_array.index(name)
|
try:
|
||||||
|
return self.srv_array.index(name)
|
||||||
|
except:
|
||||||
|
return -1
|
||||||
|
|
||||||
def port_by_index(self, idx):
|
def port_by_index(self, idx):
|
||||||
return self.ports_list[idx]
|
try:
|
||||||
|
return self.ports_list[idx]
|
||||||
|
except:
|
||||||
|
return -1
|
||||||
|
|
||||||
def index_by_port(self, port):
|
def index_by_port(self, port):
|
||||||
return self.ports_list.index(str(port))
|
try:
|
||||||
|
return self.ports_list.index(str(port))
|
||||||
|
except:
|
||||||
|
return -1
|
||||||
|
|
||||||
class Icons():
|
class Icons():
|
||||||
"""Util to display Qt's built-in icons when the system is not configured as
|
"""Util to display Qt's built-in icons when the system is not configured as
|
||||||
|
|
Loading…
Add table
Reference in a new issue