summaryrefslogtreecommitdiff
path: root/osdep/PortMapper.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-30 14:17:58 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-30 14:17:58 -0800
commit3d6649282822f79e40a771ea8ecd0cd9410f80f9 (patch)
tree33f4491a4557c43a6a3fe678bfb91b8b35bbff97 /osdep/PortMapper.cpp
parent838fdf4d1142e303ef862b1d26a811ee8389fa33 (diff)
downloadinfinitytier-3d6649282822f79e40a771ea8ecd0cd9410f80f9.tar.gz
infinitytier-3d6649282822f79e40a771ea8ecd0cd9410f80f9.zip
Also add a timeout for the actual NAT-PMP port mapping step.
Diffstat (limited to 'osdep/PortMapper.cpp')
-rw-r--r--osdep/PortMapper.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/osdep/PortMapper.cpp b/osdep/PortMapper.cpp
index fe98a04a..a33bd0e6 100644
--- a/osdep/PortMapper.cpp
+++ b/osdep/PortMapper.cpp
@@ -124,6 +124,7 @@ public:
}
sendnewportmappingrequest(&natpmp,NATPMP_PROTOCOL_UDP,localPort,tryPort,(ZT_PORTMAPPER_REFRESH_DELAY * 2) / 1000);
+ myTimeout = OSUtils::now() + 10000;
do {
fd_set fds;
struct timeval timeout;
@@ -132,6 +133,8 @@ public:
getnatpmprequesttimeout(&natpmp, &timeout);
select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
r = readnatpmpresponseorretry(&natpmp, &response);
+ if (OSUtils::now() >= myTimeout)
+ break;
} while (r == NATPMP_TRYAGAIN);
if (r == 0) {
publicAddress.setPort(response.pnu.newportmapping.mappedpublicport);