Browse Source

Little fix to NAT-t alg

Adam Ierymenko 9 years ago
parent
commit
eadafd8de7
1 changed files with 4 additions and 4 deletions
  1. 4 4
      node/Switch.cpp

+ 4 - 4
node/Switch.cpp

@@ -490,10 +490,10 @@ unsigned long Switch::doTimerTasks(uint64_t now)
 						// Strategies 1-3: try escalating ports for symmetric NATs that remap sequentially
 						InetAddress tmpaddr(qi->inaddr);
 						int p = (int)qi->inaddr.port() + qi->strategyIteration;
-						if (p < 0xffff) {
-							tmpaddr.setPort((unsigned int)p);
-							qi->peer->sendHELLO(qi->localAddr,tmpaddr,now);
-						} else qi->strategyIteration = 5;
+						if (p > 65535)
+							p -= 64511;
+						tmpaddr.setPort((unsigned int)p);
+						qi->peer->sendHELLO(qi->localAddr,tmpaddr,now);
 					} else {
 						// All strategies tried, expire entry
 						_contactQueue.erase(qi++);