From ee70dfe52ea362e3ca0564643c6878fe0b4d70dd Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 8 Aug 2021 17:05:40 +0200 Subject: [PATCH] [fix] firewall.py : upnpc.getspecificportmapping expects an int, can't handle port ranges ? --- src/yunohost/firewall.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/yunohost/firewall.py b/src/yunohost/firewall.py index b800cd42c..d967acd9c 100644 --- a/src/yunohost/firewall.py +++ b/src/yunohost/firewall.py @@ -399,6 +399,12 @@ def firewall_upnp(action="status", no_refresh=False): for protocol in ["TCP", "UDP"]: if protocol + "_TO_CLOSE" in firewall["uPnP"]: for port in firewall["uPnP"][protocol + "_TO_CLOSE"]: + + if not isinstance(port, int): + # FIXME : how should we handle port ranges ? + logger.warning("Can't use UPnP to close '%s'" % port) + continue + # Clean the mapping of this port if upnpc.getspecificportmapping(port, protocol): try: @@ -408,6 +414,12 @@ def firewall_upnp(action="status", no_refresh=False): firewall["uPnP"][protocol + "_TO_CLOSE"] = [] for port in firewall["uPnP"][protocol]: + + if not isinstance(port, int): + # FIXME : how should we handle port ranges ? + logger.warning("Can't use UPnP to open '%s'" % port) + continue + # Clean the mapping of this port if upnpc.getspecificportmapping(port, protocol): try: