From 4fb8c29d6c63ac6c08f66cef0e5201fd419916ea Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 9 Mar 2022 13:12:12 +0800 Subject: [PATCH] bugfix --- appPublic/across_nat.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/appPublic/across_nat.py b/appPublic/across_nat.py index 4b5ff25..5d83da2 100644 --- a/appPublic/across_nat.py +++ b/appPublic/across_nat.py @@ -64,16 +64,19 @@ class AcrossNat(object): protocol=protocol): external_port += 1 continue - self.upnp.AddPortMapping(NewRemoteHost='', - NewExternalPort=external_port, - NewProtocol=protocol, - NewInternalPort=inner_port, - NewInternalClient=ip, - NewEnabled=1, - NewPortMappingDescription=desc, - NewLeaseDuration=0 - ) - return external_port + try: + self.upnp.AddPortMapping(NewRemoteHost='', + NewExternalPort=external_port, + NewProtocol=protocol, + NewInternalPort=inner_port, + NewInternalClient=ip, + NewEnabled=1, + NewPortMappingDescription=desc, + NewLeaseDuration=0 + ) + return external_port + except: + return None return None def is_port_mapped(self, external_port, protocol='TCP'):