Skip to content

Commit

Permalink
fixed import & firewall bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
corrad1nho committed Aug 29, 2018
1 parent e90a4e6 commit 26f8b5c
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 112 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
##Changelog

version 0.7.3:
- [change] firewall is reloaded on gui startup
- [change] checking for presence of other firewall services such as ufw when configuring firewall
- [change] selection box for protocols adjusts size
- [bugfix] previous iptables rules are now properly saved/restored
- [bugfix] sometimes external is displayed twice
- [bugfix] Qomui crashes when adding folder and provider not specified
- [bugfix] WireGuard dns-servers not set correctly when second tunnel in bypass active
- [bugfix] manually imported WireGuard configs are not added to server list - [issue #24](https://github.com/corrad1nho/qomui/issues/24)
- [bugfix] potential permission error for temporary files created during importing configs

version 0.7.2:
- [change] cli supports new import and connection methods
- [bugfix] timer for connection attempts may close active OpenVPN tunnel
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.2
0.7.3
47 changes: 46 additions & 1 deletion qomui/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import shlex
import os
import logging
from subprocess import check_call, check_output, CalledProcessError
from subprocess import check_call, check_output, CalledProcessError, Popen, PIPE, STDOUT
from PyQt5 import QtCore, QtGui, Qt, QtWidgets
from collections import Counter

ROOTDIR = "/usr/share/qomui"
Expand Down Expand Up @@ -173,6 +174,50 @@ def get_config():
logging.debug("Failed to load firewall configuration")
return None

def check_firewall_services():
firewall_services = ["ufw", "firewalld", "qomui"]
detected_firewall = []

for fw in firewall_services:

try:
result = check_output(["systemctl", "is-enabled", fw], stderr=devnull).decode("utf-8")

if result == "enabled\n":
detected_firewall.append(fw)
logging.warning("Detected enable firewall service: {}".format(fw))

else:
logging.debug("{}.service is not enabled".format(fw))

except (FileNotFoundError, CalledProcessError) as e:
logging.debug("{}.service does either not exist or is not enabled".format(fw))

return detected_firewall

def save_iptables():
outfile = open("{}/iptables_before.rules".format(ROOTDIR), "w")
save = Popen(["iptables-save"], stdout=outfile, stderr=PIPE)
save.wait()
outfile.flush()

if save.stderr:
logging.debug("Failed to save current iptables rules")

else:
logging.debug("Saved iptables rule")

def restore_iptables():
infile = open("{}/iptables_before.rules".format(ROOTDIR), "r")
restore = Popen(["iptables-restore"], stdin=infile, stderr=PIPE)
save.wait()

if save.stderr:
logging.debug("Failed to restore iptables rules")

else:
logging.debug("restored previous iptables rules")




Loading

0 comments on commit 26f8b5c

Please sign in to comment.