Update yunohost_firewall.py

Update comment & return
This commit is contained in:
titoko 2012-12-13 11:23:10 +01:00 committed by Titoko
parent 89373e9c5b
commit d49edb2e4d

View file

@ -16,9 +16,12 @@ def firewall_allow(protocol=None,port=None,ipv6=None):
Allow port in iptables Allow port in iptables
Keyword arguments: Keyword arguments:
protocol protocol -- Protocol used
port port -- Port to open
ipv6 ipv6 -- Boolean ipv6
Return
Dict
""" """
if ipv6 == True: if ipv6 == True:
@ -43,6 +46,8 @@ def firewall_allow(protocol=None,port=None,ipv6=None):
update_yml(port,protocol,'a',ip) update_yml(port,protocol,'a',ip)
os.system(rule) os.system(rule)
return firewall_list()
def firewall_disallow(protocol=None,port=None,ipv6=None): def firewall_disallow(protocol=None,port=None,ipv6=None):
@ -50,9 +55,12 @@ def firewall_disallow(protocol=None,port=None,ipv6=None):
Disallow port in iptables Disallow port in iptables
Keyword arguments: Keyword arguments:
protocol protocol -- Protocol used
port port -- Port to open
ipv6 ipv6 -- Boolean ipv6
Return
Dict
""" """
@ -78,14 +86,20 @@ def firewall_disallow(protocol=None,port=None,ipv6=None):
update_yml(port,protocol,'r',ip) update_yml(port,protocol,'r',ip)
os.system(rule) os.system(rule)
return firewall_list
def firewall_list(): def firewall_list():
""" """
Display list of allow port Allow port in iptables
Keyword arguments: Keyword arguments:
None None
Return
Dict
""" """
with open ('firewall.yml') as f: with open ('firewall.yml') as f:
firewall = yaml.load(f) firewall = yaml.load(f)
@ -99,6 +113,9 @@ def firewall_reload():
Keyword arguments: Keyword arguments:
None None
Return
Dict
''' '''
with open('firewall.yml','r') as f: with open('firewall.yml','r') as f:
firewall = yaml.load(f) firewall = yaml.load(f)
@ -134,7 +151,8 @@ def firewall_reload():
os.system ("iptables -P INPUT DROP") os.system ("iptables -P INPUT DROP")
os.system ("ip6tables -P INPUT DROP") os.system ("ip6tables -P INPUT DROP")
firewall_list()
return firewall_list()
@ -143,10 +161,13 @@ def update_yml(port=None,protocol=None,mode=None,ip=None):
Update firewall.yml Update firewall.yml
Keyword arguments: Keyword arguments:
protocol protocol -- Protocol used
port port -- Port to open
mode mode -- a=append r=remove
ipv6 ipv6 -- Boolean ipv6
Return
None
""" """