fix get_next_mapping

This commit is contained in:
Jack Robison 2018-11-08 10:34:20 -05:00
parent 3e26a6c2c7
commit b203a5bdc8
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -1,5 +1,4 @@
import os import os
import socket
import logging import logging
import json import json
import asyncio import asyncio
@ -157,6 +156,7 @@ class UPnP:
if protocol not in ["UDP", "TCP"]: if protocol not in ["UDP", "TCP"]:
raise UPnPError("unsupported protocol: {}".format(protocol)) raise UPnPError("unsupported protocol: {}".format(protocol))
internal_port = int(internal_port or port) internal_port = int(internal_port or port)
requested_port = int(internal_port)
redirect_tups = [] redirect_tups = []
cnt = 0 cnt = 0
port = int(port) port = int(port)
@ -172,11 +172,10 @@ class UPnP:
} }
while (port, protocol) in redirects: while (port, protocol) in redirects:
int_host, int_port, _ = redirects[(port, protocol)] int_host, int_port, desc = redirects[(port, protocol)]
if int_host == self.lan_address and int_port == internal_port: if int_host == self.lan_address and int_port == requested_port and desc == description:
return int_port return port
port += 1 port += 1
await self.add_port_mapping( # set one up await self.add_port_mapping( # set one up
port, protocol, internal_port, self.lan_address, description port, protocol, internal_port, self.lan_address, description
) )