2023-01-09 12:46:03 +00:00
|
|
|
from frostfs_testlib.shell import Shell
|
2022-08-01 06:16:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
class IpTablesHelper:
|
|
|
|
@staticmethod
|
2022-10-13 16:13:45 +00:00
|
|
|
def drop_input_traffic_to_port(shell: Shell, ports: list[str]) -> None:
|
2022-08-01 06:16:36 +00:00
|
|
|
for port in ports:
|
2022-10-13 16:13:45 +00:00
|
|
|
shell.exec(f"sudo iptables -A INPUT -p tcp --dport {port} -j DROP")
|
2022-08-01 06:16:36 +00:00
|
|
|
|
|
|
|
@staticmethod
|
2022-10-13 16:13:45 +00:00
|
|
|
def restore_input_traffic_to_port(shell: Shell, ports: list[str]) -> None:
|
2022-08-01 06:16:36 +00:00
|
|
|
for port in ports:
|
2022-10-13 16:13:45 +00:00
|
|
|
shell.exec(f"sudo iptables -D INPUT -p tcp --dport {port} -j DROP")
|