From b203a5bdc8a3e29ba40929d3b558f9eac3f6618b Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 8 Nov 2018 10:34:20 -0500 Subject: [PATCH] fix get_next_mapping --- aioupnp/upnp.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/aioupnp/upnp.py b/aioupnp/upnp.py index 608733e..e184a36 100644 --- a/aioupnp/upnp.py +++ b/aioupnp/upnp.py @@ -1,5 +1,4 @@ import os -import socket import logging import json import asyncio @@ -157,6 +156,7 @@ class UPnP: if protocol not in ["UDP", "TCP"]: raise UPnPError("unsupported protocol: {}".format(protocol)) internal_port = int(internal_port or port) + requested_port = int(internal_port) redirect_tups = [] cnt = 0 port = int(port) @@ -172,11 +172,10 @@ class UPnP: } while (port, protocol) in redirects: - int_host, int_port, _ = redirects[(port, protocol)] - if int_host == self.lan_address and int_port == internal_port: - return int_port + int_host, int_port, desc = redirects[(port, protocol)] + if int_host == self.lan_address and int_port == requested_port and desc == description: + return port port += 1 - await self.add_port_mapping( # set one up port, protocol, internal_port, self.lan_address, description )