|
@@ -14,8 +14,6 @@ import time
|
|
import collections
|
|
import collections
|
|
import typing as t
|
|
import typing as t
|
|
|
|
|
|
-# TODO: double check this import
|
|
|
|
-# does it complain because libpcapreader is not a .py?
|
|
|
|
import ID2TLib.libpcapreader as pr
|
|
import ID2TLib.libpcapreader as pr
|
|
import lea
|
|
import lea
|
|
import numpy as np
|
|
import numpy as np
|
|
@@ -413,19 +411,18 @@ class BaseAttack(metaclass=abc.ABCMeta):
|
|
elif param_type == atkParam.ParameterTypes.TYPE_PERCENTAGE:
|
|
elif param_type == atkParam.ParameterTypes.TYPE_PERCENTAGE:
|
|
is_valid_float, value = self._is_float(value)
|
|
is_valid_float, value = self._is_float(value)
|
|
if is_valid_float:
|
|
if is_valid_float:
|
|
- is_valid = value >= 0 and value <= 1
|
|
|
|
|
|
+ is_valid = 0 <= value <= 1
|
|
else:
|
|
else:
|
|
is_valid = False
|
|
is_valid = False
|
|
elif param_type == atkParam.ParameterTypes.TYPE_PADDING:
|
|
elif param_type == atkParam.ParameterTypes.TYPE_PADDING:
|
|
if isinstance(value, int):
|
|
if isinstance(value, int):
|
|
- is_valid = value >= 0 and value <= 100
|
|
|
|
|
|
+ is_valid = 0 <= value <= 100
|
|
elif isinstance(value, str) and value.isdigit():
|
|
elif isinstance(value, str) and value.isdigit():
|
|
value = int(value)
|
|
value = int(value)
|
|
- is_valid = value >= 0 and value <= 100
|
|
|
|
|
|
+ is_valid = 0 <= value <= 100
|
|
elif param_type == atkParam.ParameterTypes.TYPE_INTERVAL_SELECT_STRAT:
|
|
elif param_type == atkParam.ParameterTypes.TYPE_INTERVAL_SELECT_STRAT:
|
|
is_valid = value in {"random", "optimal", "custom"}
|
|
is_valid = value in {"random", "optimal", "custom"}
|
|
|
|
|
|
-
|
|
|
|
# add value iff validation was successful
|
|
# add value iff validation was successful
|
|
if is_valid:
|
|
if is_valid:
|
|
self.params[param_name] = self.ValuePair(value, user_specified)
|
|
self.params[param_name] = self.ValuePair(value, user_specified)
|
|
@@ -503,7 +500,7 @@ class BaseAttack(metaclass=abc.ABCMeta):
|
|
|
|
|
|
return destination
|
|
return destination
|
|
|
|
|
|
- def get_reply_delay(self, ip_dst, default = 2000):
|
|
|
|
|
|
+ def get_reply_delay(self, ip_dst, default=2000):
|
|
"""
|
|
"""
|
|
Gets the minimum and the maximum reply delay for all the connections of a specific IP.
|
|
Gets the minimum and the maximum reply delay for all the connections of a specific IP.
|
|
|
|
|
|
@@ -524,7 +521,7 @@ class BaseAttack(metaclass=abc.ABCMeta):
|
|
all_max_delays = self.statistics.process_db_query("SELECT maxDelay FROM conv_statistics LIMIT 500;")
|
|
all_max_delays = self.statistics.process_db_query("SELECT maxDelay FROM conv_statistics LIMIT 500;")
|
|
max_delay = np.median(all_max_delays)
|
|
max_delay = np.median(all_max_delays)
|
|
|
|
|
|
- if math.isnan(min_delay): # max_delay is nan too then
|
|
|
|
|
|
+ if math.isnan(min_delay): # max_delay is nan too then
|
|
if default < 0:
|
|
if default < 0:
|
|
raise ValueError("Could not calculate min/max_delay")
|
|
raise ValueError("Could not calculate min/max_delay")
|
|
|
|
|