mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Get rid of random port strategy -- research does not support.
This commit is contained in:
parent
5f351f2f6b
commit
be4683a96d
1 changed files with 4 additions and 14 deletions
|
@ -467,9 +467,8 @@ unsigned long Switch::doTimerTasks()
|
||||||
// Second strategy: shotgun method up: try a few ports above
|
// Second strategy: shotgun method up: try a few ports above
|
||||||
++qi->strategyIteration;
|
++qi->strategyIteration;
|
||||||
int p = (int)qi->inaddr.port();
|
int p = (int)qi->inaddr.port();
|
||||||
for(int i=0;i<6;++i) {
|
for(int i=0;i<9;++i) {
|
||||||
if (++p > 0xffff)
|
if (++p > 0xffff) break;
|
||||||
break;
|
|
||||||
InetAddress tmpaddr(qi->inaddr);
|
InetAddress tmpaddr(qi->inaddr);
|
||||||
tmpaddr.setPort((unsigned int)p);
|
tmpaddr.setPort((unsigned int)p);
|
||||||
RR->node->putPacket(tmpaddr,outp.data(),outp.size(),qi->currentDesperation);
|
RR->node->putPacket(tmpaddr,outp.data(),outp.size(),qi->currentDesperation);
|
||||||
|
@ -480,20 +479,11 @@ unsigned long Switch::doTimerTasks()
|
||||||
++qi->strategyIteration;
|
++qi->strategyIteration;
|
||||||
int p = (int)qi->inaddr.port();
|
int p = (int)qi->inaddr.port();
|
||||||
for(int i=0;i<3;++i) {
|
for(int i=0;i<3;++i) {
|
||||||
if (--p < 1024)
|
if (--p < 1024) break;
|
||||||
break;
|
|
||||||
InetAddress tmpaddr(qi->inaddr);
|
InetAddress tmpaddr(qi->inaddr);
|
||||||
tmpaddr.setPort((unsigned int)p);
|
tmpaddr.setPort((unsigned int)p);
|
||||||
RR->node->putPacket(tmpaddr,outp.data(),outp.size(),qi->currentDesperation);
|
RR->node->putPacket(tmpaddr,outp.data(),outp.size(),qi->currentDesperation);
|
||||||
}
|
}
|
||||||
} break;
|
|
||||||
case 3:
|
|
||||||
// Fourth strategy: sawed-off shotgun: try random non-privileged ports
|
|
||||||
for(int i=0;i<16;++i) {
|
|
||||||
InetAddress tmpaddr(qi->inaddr);
|
|
||||||
tmpaddr.setPort((unsigned int)(1024 + (RR->prng->next32() % (65536 - 1024))));
|
|
||||||
RR->node->putPacket(tmpaddr,outp.data(),outp.size(),qi->currentDesperation);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Escalate link desperation after all strategies attempted
|
// Escalate link desperation after all strategies attempted
|
||||||
++qi->currentDesperation;
|
++qi->currentDesperation;
|
||||||
|
@ -505,7 +495,7 @@ unsigned long Switch::doTimerTasks()
|
||||||
// Otherwise restart at new link desperation level (e.g. try a tougher transport)
|
// Otherwise restart at new link desperation level (e.g. try a tougher transport)
|
||||||
qi->strategyIteration = 0;
|
qi->strategyIteration = 0;
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
qi->fireAtTime = now + ZT_NAT_T_TACTICAL_ESCALATION_DELAY;
|
qi->fireAtTime = now + ZT_NAT_T_TACTICAL_ESCALATION_DELAY;
|
||||||
|
|
Loading…
Add table
Reference in a new issue