From 78bfd52cb8dda9f080dbff723c4b4a969041e026 Mon Sep 17 00:00:00 2001 From: titoko Date: Tue, 18 Dec 2012 22:23:17 +0100 Subject: [PATCH] End of exception handling --- firewall.yml | 4 ++-- yunohost_firewall.py | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/firewall.yml b/firewall.yml index 688c1da7..b0220024 100644 --- a/firewall.yml +++ b/firewall.yml @@ -1,6 +1,6 @@ ipv4: - TCP: [22, 25, 53, 80, 443, 5222, 5269, 5280] + TCP: ['22', '25', '53', '80', '443', '5222', '5269', '5280'] UDP: [] ipv6: - TCP: [22] + TCP: ['22'] UDP: [] diff --git a/yunohost_firewall.py b/yunohost_firewall.py index 467b19a1..d0291b47 100644 --- a/yunohost_firewall.py +++ b/yunohost_firewall.py @@ -39,8 +39,7 @@ def firewall_allow(protocol=None,port=None,ipv6=None): else: raise YunoHostError(22,_("Port not between 1 and 65535 : ")+port) - firewall_reload() - return firewall_list() + return firewall_reload() @@ -65,8 +64,7 @@ def firewall_disallow(protocol=None,port=None,ipv6=None): update_yml(port,protocol,'r',ipv6) win_msg(_("Port successfully closed")) - firewall_reload() - return firewall_list + return firewall_reload() @@ -133,6 +131,7 @@ def firewall_reload(): os.system ("ip6tables -P INPUT DROP") win_msg(_("Firewall successfully reloaded")) + return firewall_list() @@ -162,18 +161,18 @@ def update_yml(port=None,protocol=None,mode=None,ipv6=None): firewall[ip][protocol].append(port) else: - raise YunoHostError(22,_("Port already openned")+port) + raise YunoHostError(22,_("Port already openned ")+port) else: if port in firewall[ip][protocol]: firewall[ip][protocol].remove(port) else: - raise YunoHostError(22,_("Port already closed")+port) + raise YunoHostError(22,_("Port already closed ")+port) firewall[ip][protocol].sort(key=int) os.system("mv firewall.yml firewall.yml.old") + with open('firewall.yml','w') as f: yaml.dump(firewall,f) -