mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Also add a timeout for the actual NAT-PMP port mapping step.
This commit is contained in:
parent
838fdf4d11
commit
3d66492828
1 changed files with 3 additions and 0 deletions
|
@ -124,6 +124,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
sendnewportmappingrequest(&natpmp,NATPMP_PROTOCOL_UDP,localPort,tryPort,(ZT_PORTMAPPER_REFRESH_DELAY * 2) / 1000);
|
sendnewportmappingrequest(&natpmp,NATPMP_PROTOCOL_UDP,localPort,tryPort,(ZT_PORTMAPPER_REFRESH_DELAY * 2) / 1000);
|
||||||
|
myTimeout = OSUtils::now() + 10000;
|
||||||
do {
|
do {
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
|
@ -132,6 +133,8 @@ public:
|
||||||
getnatpmprequesttimeout(&natpmp, &timeout);
|
getnatpmprequesttimeout(&natpmp, &timeout);
|
||||||
select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
|
select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
|
||||||
r = readnatpmpresponseorretry(&natpmp, &response);
|
r = readnatpmpresponseorretry(&natpmp, &response);
|
||||||
|
if (OSUtils::now() >= myTimeout)
|
||||||
|
break;
|
||||||
} while (r == NATPMP_TRYAGAIN);
|
} while (r == NATPMP_TRYAGAIN);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
publicAddress.setPort(response.pnu.newportmapping.mappedpublicport);
|
publicAddress.setPort(response.pnu.newportmapping.mappedpublicport);
|
||||||
|
|
Loading…
Add table
Reference in a new issue