Skip to content

Commit

Permalink
Added flush_input_output() as separate func
Browse files Browse the repository at this point in the history
  • Loading branch information
jotyGill committed Sep 24, 2019
1 parent ecaed02 commit 7278fd1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions openpyn/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ def clear_fw_rules() -> None:
]


# flush input and output iptables rules.
def flush_input_output() -> None:
root.verify_root_access("Root access needed to modify 'iptables' rules")
logger.info("Flushing ALL INPUT and OUTPUT Rules")
subprocess.call(["sudo", "iptables", "-F", "OUTPUT"])
subprocess.call(["sudo", "iptables", "-F", "INPUT"])


def do_dns(iface: str, dest: str, what: str) -> None:
# for pp in ("udp", "tcp"):
pp = "udp"
Expand Down Expand Up @@ -77,10 +85,6 @@ def apply_dns_rules():
def apply_fw_rules(interfaces_details: List, vpn_server_ips: List, skip_dns_patch: bool) -> None:
root.verify_root_access("Root access needed to modify 'iptables' rules")

# empty the INPUT and OUTPUT chain of any current rules
subprocess.check_call(["sudo", "iptables", "-F", "OUTPUT"])
subprocess.check_call(["sudo", "iptables", "-F", "INPUT"])

apply_dns_rules()
logger.notice("Temporarily disabling ipv6 to prevent leakage")
manage_ipv6(disable=True)
Expand Down

0 comments on commit 7278fd1

Please sign in to comment.