mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Do not fail if protocol is not specified
This commit is contained in:
parent
cddae8b54a
commit
cdc777671d
1 changed files with 13 additions and 7 deletions
20
firewall.py
20
firewall.py
|
@ -35,7 +35,7 @@ except ImportError:
|
||||||
|
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
|
|
||||||
""" Search the ssh port in ssh config file
|
""" Search the ssh port in ssh config file
|
||||||
If we don't find the ssh port we define 22"""
|
If we don't find the ssh port we define 22"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -48,13 +48,13 @@ try:
|
||||||
ssh_port = ssh_port.rstrip('\n\r')
|
ssh_port = ssh_port.rstrip('\n\r')
|
||||||
|
|
||||||
ssh_config_file.close()
|
ssh_config_file.close()
|
||||||
|
|
||||||
if ssh_port == '':
|
if ssh_port == '':
|
||||||
ssh_port = '22'
|
ssh_port = '22'
|
||||||
|
|
||||||
except:
|
except:
|
||||||
ssh_port = '22'
|
ssh_port = '22'
|
||||||
|
|
||||||
ssh_port = int(ssh_port)
|
ssh_port = int(ssh_port)
|
||||||
|
|
||||||
def firewall_allow(port=None, protocol=['TCP'], ipv6=False, no_upnp=False):
|
def firewall_allow(port=None, protocol=['TCP'], ipv6=False, no_upnp=False):
|
||||||
|
@ -70,8 +70,11 @@ def firewall_allow(port=None, protocol=['TCP'], ipv6=False, no_upnp=False):
|
||||||
"""
|
"""
|
||||||
port = int(port)
|
port = int(port)
|
||||||
ipv = "ipv4"
|
ipv = "ipv4"
|
||||||
protocols = protocol
|
if isinstance(protocol, list):
|
||||||
protocol = protocol[0]
|
protocols = protocol
|
||||||
|
else:
|
||||||
|
protocols = [protocol]
|
||||||
|
protocol = protocols[0]
|
||||||
|
|
||||||
firewall = firewall_list(raw=True)
|
firewall = firewall_list(raw=True)
|
||||||
|
|
||||||
|
@ -109,8 +112,11 @@ def firewall_disallow(port=None, protocol=['TCP'], ipv6=False):
|
||||||
"""
|
"""
|
||||||
port = int(port)
|
port = int(port)
|
||||||
ipv = "ipv4"
|
ipv = "ipv4"
|
||||||
protocols = protocol
|
if isinstance(protocol, list):
|
||||||
protocol = protocol[0]
|
protocols = protocol
|
||||||
|
else:
|
||||||
|
protocols = [protocol]
|
||||||
|
protocol = protocols[0]
|
||||||
|
|
||||||
firewall = firewall_list(raw=True)
|
firewall = firewall_list(raw=True)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue