mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Update yunohost_firewall.py
Update comment & return
This commit is contained in:
parent
89373e9c5b
commit
d49edb2e4d
1 changed files with 35 additions and 14 deletions
|
@ -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
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue