mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Merge branch 'dev' of github.com:YunoHost/moulinette into dev
This commit is contained in:
commit
98bbf73004
2 changed files with 33 additions and 28 deletions
11
firewall.yml
11
firewall.yml
|
@ -1,13 +1,12 @@
|
|||
UPNP: false
|
||||
ipv4:
|
||||
UPNP:
|
||||
cron: false
|
||||
ports:
|
||||
TCP: [22, 25, 53, 80, 137, 138, 139, 443, 445, 5222, 5269, 5280, 6767, 7676]
|
||||
UDP: [53, 137, 138]
|
||||
upnp:
|
||||
ipv4:
|
||||
TCP: [22, 25, 53, 80, 137, 138, 139, 443, 445, 5222, 5269, 5280, 6767, 7676]
|
||||
UDP: [53, 137, 138]
|
||||
ipv6:
|
||||
TCP: [22]
|
||||
UDP: [53]
|
||||
upnp:
|
||||
TCP:
|
||||
UDP:
|
||||
|
||||
|
|
|
@ -181,10 +181,11 @@ def update_yml(port=None, protocol=None, mode=None, ipv6=None, upnp=False):
|
|||
if mode == 'a':
|
||||
if port not in firewall[ip][protocol]:
|
||||
firewall[ip][protocol].append(port)
|
||||
|
||||
elif upnp:
|
||||
if port not in firewall[ip]['upnp'][protocol]:
|
||||
firewall[ip]['upnp'][protocol].append(port)
|
||||
if not ipv6 and upnp:
|
||||
firewall['UPNP']['ports'][protocol].append(port)
|
||||
elif not ipv6 and upnp:
|
||||
if port not in firewall['UPNP']['ports'][protocol]:
|
||||
firewall['UPNP']['ports'][protocol].append(port)
|
||||
else:
|
||||
raise YunoHostError(22, _("Port already openned :") + str(port))
|
||||
|
||||
|
@ -192,25 +193,30 @@ def update_yml(port=None, protocol=None, mode=None, ipv6=None, upnp=False):
|
|||
raise YunoHostError(22, _("Port already openned :") + str(port))
|
||||
|
||||
else:
|
||||
if upnp:
|
||||
if port in firewall[ip]['upnp'][protocol]:
|
||||
firewall[ip]['upnp'][protocol].remove(port)
|
||||
if not ipv6 and upnp:
|
||||
if port in firewall['UPNP']['ports'][protocol]:
|
||||
firewall['UPNP']['ports'][protocol].remove(port)
|
||||
|
||||
else:
|
||||
raise YunoHostError(22, _("Upnp redirection already deleted :") + str(port))
|
||||
else:
|
||||
if port in firewall[ip]['upnp'][protocol]:
|
||||
firewall[ip]['upnp'][protocol].remove(port)
|
||||
|
||||
else:
|
||||
raise YunoHostError(22, _("Upnp redirection alreadu deleted :") + str(port))
|
||||
elif not ipv6:
|
||||
if port in firewall['UPNP']['ports'][protocol]:
|
||||
firewall['UPNP']['ports'][protocol].remove(port)
|
||||
|
||||
if port in firewall[ip][protocol]:
|
||||
firewall[ip][protocol].remove(port)
|
||||
|
||||
else:
|
||||
raise YunoHostError(22, _("Port already closed :") + str(port))
|
||||
else:
|
||||
if port in firewall[ip][protocol]:
|
||||
firewall[ip][protocol].remove(port)
|
||||
|
||||
else:
|
||||
raise YunoHostError(22, _("Port already closed :") + str(port))
|
||||
|
||||
firewall[ip][protocol].sort()
|
||||
firewall['UPNP']['ports'][protocol].sort()
|
||||
|
||||
os.system("mv /etc/yunohost/firewall.yml /etc/yunohost/firewall.yml.old")
|
||||
|
||||
|
@ -235,7 +241,7 @@ def add_portmapping(protocol=None, upnp=False, ipv6=None, mode=None,):
|
|||
else:
|
||||
os.system("iptables -P INPUT ACCEPT")
|
||||
|
||||
if upnp and mode == 'a':
|
||||
if upnp and not ipv6 and mode == 'a':
|
||||
remove_portmapping()
|
||||
|
||||
if ipv6:
|
||||
|
@ -250,8 +256,8 @@ def add_portmapping(protocol=None, upnp=False, ipv6=None, mode=None,):
|
|||
os.system("ip6tables -A INPUT -p " + protocol + " -i eth0 --dport " + str(port) + " -j ACCEPT")
|
||||
else:
|
||||
os.system("iptables -A INPUT -p " + protocol + " -i eth0 --dport " + str(port) + " -j ACCEPT")
|
||||
if upnp:
|
||||
if port in firewall[ip]['upnp'][protocol]:
|
||||
if upnp and not ipv6:
|
||||
if port in firewall['UPNP']['ports'][protocol]:
|
||||
upnpc = miniupnpc.UPnP()
|
||||
upnpc.discoverdelay = 200
|
||||
nbigd = upnpc.discover()
|
||||
|
@ -301,7 +307,7 @@ def firewall_installupnp():
|
|||
with open('/etc/yunohost/firewall.yml', 'r') as f:
|
||||
firewall = yaml.load(f)
|
||||
|
||||
firewall['UPNP'] = True
|
||||
firewall['UPNP']['cron'] = True
|
||||
|
||||
os.system("touch /etc/cron.d/yunohost-firewall")
|
||||
os.system("echo '*/50 * * * * root yunohost firewall reload -u>>/dev/null'>/etc/cron.d/yunohost-firewall")
|
||||
|
@ -322,7 +328,7 @@ def firewall_removeupnp():
|
|||
with open('/etc/yunohost/firewall.yml', 'r') as f:
|
||||
firewall = yaml.load(f)
|
||||
|
||||
firewall['UPNP'] = False
|
||||
firewall['UPNP']['cron'] = False
|
||||
|
||||
try:
|
||||
os.remove("/etc/cron.d/yunohost-firewall")
|
||||
|
@ -346,7 +352,7 @@ def firewall_checkupnp():
|
|||
with open('/etc/yunohost/firewall.yml', 'r') as f:
|
||||
firewall = yaml.load(f)
|
||||
|
||||
if firewall['UPNP']:
|
||||
if firewall['UPNP']['cron']:
|
||||
win_msg(_("UPNP is activated"))
|
||||
else:
|
||||
raise YunoHostError(167, _("UPNP not activated!"))
|
||||
|
|
Loading…
Reference in a new issue