Update yunohost_firewall.py

Update comments
This commit is contained in:
titoko 2012-12-13 10:38:37 +01:00
parent 448b14705e
commit 3b3b2120f8

View file

@ -12,6 +12,15 @@ except ImportError:
def firewall_allow(protocol=None,port=None,ipv6=None): def firewall_allow(protocol=None,port=None,ipv6=None):
"""
Allow port in iptables
Keyword arguments:
protocol
port
ipv6
"""
if ipv6 == True: if ipv6 == True:
ip = 'ipv6' ip = 'ipv6'
iptables="ip6tables" iptables="ip6tables"
@ -37,6 +46,15 @@ def firewall_allow(protocol=None,port=None,ipv6=None):
def firewall_disallow(protocol=None,port=None,ipv6=None): def firewall_disallow(protocol=None,port=None,ipv6=None):
"""
Disallow port in iptables
Keyword arguments:
protocol
port
ipv6
"""
if ipv6 == True: if ipv6 == True:
ip = 'ipv6' ip = 'ipv6'
@ -63,9 +81,12 @@ def firewall_disallow(protocol=None,port=None,ipv6=None):
def firewall_list(): def firewall_list():
''' """
Parse and display firwall.yml Display list of allow port
'''
Keyword arguments:
None
"""
with open ('firewall.yml') as f: with open ('firewall.yml') as f:
firewall = yaml.load(f) firewall = yaml.load(f)
return firewall return firewall
@ -74,11 +95,10 @@ def firewall_list():
def firewall_reload(): def firewall_reload():
''' '''
Clear filter IPTABLE's table Reload iptables configuration
Allow SSH
Parse firewall.yml extract the list of port allowed Keyword arguments:
Allow all port in the list None
Prohibit the rest
''' '''
with open('firewall.yml','r') as f: with open('firewall.yml','r') as f:
firewall = yaml.load(f) firewall = yaml.load(f)
@ -118,9 +138,16 @@ def firewall_reload():
def update_yml(port=None,protocol=None,mode=None,ip=None): def update_yml(port=None,protocol=None,mode=None,ip=None):
''' """
Append port in firewall.yml Update firewall.yml
'''
Keyword arguments:
protocol
port
mode
ipv6
"""
with open('firewall.yml','r') as f: with open('firewall.yml','r') as f:
firewall = yaml.load(f) firewall = yaml.load(f)