bugfix: Comment the config and Using the built-in code config.

This commit is contained in:
fumingwei
2024-06-05 10:38:03 +08:00
parent fa72c50f99
commit d23ba1aef5
2 changed files with 192 additions and 187 deletions

View File

@@ -30,17 +30,19 @@ from urllib.parse import urlparse, parse_qs
class ConfigLoader:
def __init__(self, config_path: str):
self.__config_path = config_path
self.__configs = self._load_configs()
self._config_path = config_path
self._configs = {}
if os.path.exists(self._config_path):
self._load_configs()
def _load_configs(self):
config_parser = ConfigParser()
config_parser.read(self.__config_path, encoding='UTF-8')
config_parser.read(self._config_path, encoding='UTF-8')
return config_parser.sections()
def get_value_by_section_and_key(self, section, key):
if section in self.__configs and key in self.__configs[section]:
value = self.__configs[section][key]
if section in self._configs and key in self._configs[section]:
value = self._configs[section][key]
if isinstance(value, str) and value.isdigit():
return int(value)
else:
@@ -223,6 +225,7 @@ class TcpPacketsCapture:
self._filter = f"tcp and src host {self._server_ip} and src port {self._server_port}"
def start(self):
time.sleep(0.5)
self._sniff_thread = AsyncSniffer(iface=self._iface_names, prn=self._packet_callback, filter=self._filter)
self._sniff_thread.start()
@@ -252,8 +255,10 @@ class TcpPacketsCapture:
self._quadruple_to_dscp_table[quadruple] = dscp_value
def stop(self):
self._sniff_thread.stop()
self._sniff_thread.join()
time.sleep(0.5)
if self._sniff_thread is not None and self._sniff_thread.running:
self._sniff_thread.stop()
self._sniff_thread.join()
def read_dscp_value_by_quadruple(self, quadruple):
if quadruple in self._quadruple_to_dscp_table:
@@ -1192,7 +1197,7 @@ class FirewallCasesRunner:
class ResultExportBuilder:
COLUMN_0 = "Test cases"
COLUMN_1 = "Result"
COLUMN_2 = "Fail Reason"
COLUMN_2 = "Description"
RESULT_OK = "ok"
RESULT_FAIL = "FAIL"
DEFAULT_INFO = "-"

View File

@@ -1,225 +1,225 @@
# enabled = 1 run this case
#Connection TIMEOUT, in seconds
#max_recv_speed_large byte/s
[Firewall_DenyDrop_DNS]
enabled = 1
conn_timeout = 3
max_recv_speed_large = 6553600
#max_recv_speed byte/s
# [Firewall_DenyDrop_DNS]
# enabled = 1
# conn_timeout = 3
# max_recv_speed = 6553600
[Firewall_DenyRedirect_A_DNS]
enabled = 1
conn_timeout = 3
max_recv_speed_large = 6553600
# [Firewall_DenyRedirect_A_DNS]
# enabled = 1
# conn_timeout = 3
# max_recv_speed = 6553600
[Firewall_DenyRedirect_AAAA_DNS]
enabled = 1
conn_timeout = 3
max_recv_speed_large = 6553600
# [Firewall_DenyRedirect_AAAA_DNS]
# enabled = 1
# conn_timeout = 3
# max_recv_speed = 6553600
[Firewall_DenyRedirect_ARangeTTL_DNS]
enabled = 1
conn_timeout = 3
max_recv_speed_large = 6553600
# [Firewall_DenyRedirect_ARangeTTL_DNS]
# enabled = 1
# conn_timeout = 3
# max_recv_speed = 6553600
[Firewall_DenyRedirect_AAAARangeTTL_DNS]
enabled = 1
conn_timeout = 3
max_recv_speed_large = 6553600
# [Firewall_DenyRedirect_AAAARangeTTL_DNS]
# enabled = 1
# conn_timeout = 3
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_CertExpired]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_CertExpired]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_CertSelfSigned]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_CertSelfSigned]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_CertUntrustedRoot]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_CertUntrustedRoot]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Redirect_HTTPS]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Redirect_HTTPS]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Deny_HTTPS]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Deny_HTTPS]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Replace_HTTPS]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Replace_HTTPS]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Hijack_HTTPS]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Hijack_HTTPS]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Insert_HTTPS]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Insert_HTTPS]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Redirect_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Redirect_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Deny_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Deny_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Replace_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Replace_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Hijack_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Hijack_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Insert_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Insert_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_Response_1k]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_Response_1k]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_Response_4k]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_Response_4k]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_Response_16k]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_Response_16k]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_Response_64k]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_Response_64k]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_Response_256k]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_Response_256k]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_Response_1M]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_Response_1M]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_Response_4M]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_Response_4M]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_Response_16M]
enabled = 1
conn_timeout = 4
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_Response_16M]
# enabled = 1
# conn_timeout = 4
# max_recv_speed = 6553600
[Proxy_Intercept_HTTPS_Response_64M]
enabled = 1
conn_timeout = 12
max_recv_speed_large = 6553600
# [Proxy_Intercept_HTTPS_Response_64M]
# enabled = 1
# conn_timeout = 12
# max_recv_speed = 6553600
[Firewall_Allow_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Firewall_Allow_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Firewall_DenyDrop_HTTP]
enabled = 1
conn_timeout = 4
max_recv_speed_large = 6553600
# [Firewall_DenyDrop_HTTP]
# enabled = 1
# conn_timeout = 4
# max_recv_speed = 6553600
[Firewall_DenyReset_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Firewall_DenyReset_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Firewall_DenyBlock_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Firewall_DenyBlock_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Firewall_Allow_HTTPS]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Firewall_Allow_HTTPS]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Firewall_DenyDrop_HTTPS]
enabled = 1
conn_timeout = 4
max_recv_speed_large = 6553600
# [Firewall_DenyDrop_HTTPS]
# enabled = 1
# conn_timeout = 4
# max_recv_speed = 6553600
[Firewall_DenyReset_HTTPS]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Firewall_DenyReset_HTTPS]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Firewall_DenyReset_FilterHost_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Firewall_DenyReset_FilterHost_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Firewall_DenyReset_FilterURL_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Firewall_DenyReset_FilterURL_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Deny_FilterHost_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Deny_FilterHost_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Proxy_Manipulation_Deny_FilterURL_HTTP]
enabled = 1
conn_timeout = 1
max_recv_speed_large = 6553600
# [Proxy_Manipulation_Deny_FilterURL_HTTP]
# enabled = 1
# conn_timeout = 1
# max_recv_speed = 6553600
[Shaping_RateLimit0bps_HTTP]
enabled = 1
conn_timeout = 12
max_recv_speed_large = 6553600
# [Shaping_RateLimit0bps_HTTP]
# enabled = 1
# conn_timeout = 12
# max_recv_speed = 6553600
[Shaping_RateLimit0bps_HTTPS]
enabled = 1
conn_timeout = 12
max_recv_speed_large = 6553600
# [Shaping_RateLimit0bps_HTTPS]
# enabled = 1
# conn_timeout = 12
# max_recv_speed = 6553600
[Shaping_RateLimit1000gbps_HTTP]
enabled = 1
conn_timeout = 12
max_recv_speed_large = 6553600
# [Shaping_RateLimit1000gbps_HTTP]
# enabled = 1
# conn_timeout = 12
# max_recv_speed = 6553600
[Shaping_RateLimit1000gbps_HTTPS]
enabled = 1
conn_timeout = 12
max_recv_speed_large = 6553600
# [Shaping_RateLimit1000gbps_HTTPS]
# enabled = 1
# conn_timeout = 12
# max_recv_speed = 6553600
[Shaping_NoRateLimit_HTTP]
enabled = 1
conn_timeout = 12
# [Shaping_NoRateLimit_HTTP]
# enabled = 1
# conn_timeout = 12
[Shaping_NoRateLimit_HTTPS]
enabled = 1
conn_timeout = 12
# [Shaping_NoRateLimit_HTTPS]
# enabled = 1
# conn_timeout = 12