Tons of refactoring, change to desperation algorithm to use max of core or link, porting over core loop code from old Node.cpp to new CAPI version, etc.
This commit is contained in:
parent
9e55f882d3
commit
49f031ccb4
14 changed files with 277 additions and 254 deletions
|
@ -187,6 +187,24 @@ void Peer::attemptToContactAt(const RuntimeEnvironment *RR,const InetAddress &at
|
|||
RR->node->putPacket(atAddress,outp.data(),outp.size(),linkDesperation);
|
||||
}
|
||||
|
||||
void Peer::doPingAndKeepalive(const RuntimeEnvironment *RR,uint64_t now)
|
||||
{
|
||||
Path *const bestPath = getBestPath(now);
|
||||
if ((bestPath)&&(bestPath->active(now))) {
|
||||
if ((now - bestPath->lastReceived()) >= ZT_PEER_DIRECT_PING_DELAY) {
|
||||
attemptToContactAt(RR,bestPath->address(),bestPath->desperation(now),now);
|
||||
bestPath->sent(now);
|
||||
} else if ((now - bestPath->lastSend()) >= ZT_NAT_KEEPALIVE_DELAY) {
|
||||
// We only do keepalive if desperation is zero right now, since higher
|
||||
// desperation paths involve things like tunneling that do not need it.
|
||||
if (bestPath->desperation() == 0) {
|
||||
RR->node->putPacket(_paths[p].address(),"",0,0);
|
||||
bestPath->sent(now);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Peer::addPath(const Path &newp)
|
||||
{
|
||||
unsigned int np = _numPaths;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue