|
@@ -120,16 +120,46 @@ void Peer::received(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- bool attemptToContact = false;
|
|
|
|
- if ((!havePath)&&(RR->node->shouldUsePathForZeroTierTraffic(tPtr,_id.address(),path->localSocket(),path->address()))) {
|
|
|
|
- Mutex::Lock _l(_paths_m);
|
|
|
|
|
|
+ if ( (!havePath) && RR->node->shouldUsePathForZeroTierTraffic(tPtr,_id.address(),path->localSocket(),path->address()) ) {
|
|
|
|
+ if (verb == Packet::VERB_OK) {
|
|
|
|
+ Mutex::Lock _l(_paths_m);
|
|
|
|
|
|
|
|
+ unsigned int replacePath = ZT_MAX_PEER_NETWORK_PATHS;
|
|
|
|
+ long replacePathQuality = 0;
|
|
|
|
+ for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
|
|
|
|
+ if (_paths[i].p) {
|
|
|
|
+ const long q = _paths[i].p->quality(now);
|
|
|
|
+ if (q > replacePathQuality) {
|
|
|
|
+ replacePathQuality = q;
|
|
|
|
+ replacePath = i;
|
|
|
|
+ if ( (!_paths[i].p->alive(now)) || _paths[i].p->address().ipsEqual(path->address()) )
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ replacePath = i;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (replacePath != ZT_MAX_PEER_NETWORK_PATHS) {
|
|
|
|
+ RR->t->peerLearnedNewPath(tPtr, networkId, *this, path, packetId);
|
|
|
|
+ _paths[replacePath].lr = now;
|
|
|
|
+ _paths[replacePath].p = path;
|
|
|
|
+ _paths[replacePath].priority = 1;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ attemptToContactAt(tPtr,path->localSocket(),path->address(),now,true);
|
|
|
|
+ path->sent(now);
|
|
|
|
+ RR->t->peerConfirmingUnknownPath(tPtr,networkId,*this,path,packetId,verb);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+/*
|
|
// Paths are redunant if they duplicate an alive path to the same IP or
|
|
// Paths are redunant if they duplicate an alive path to the same IP or
|
|
// with the same local socket and address family.
|
|
// with the same local socket and address family.
|
|
bool redundant = false;
|
|
bool redundant = false;
|
|
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
|
|
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
|
|
if (_paths[i].p) {
|
|
if (_paths[i].p) {
|
|
- if ( (_paths[i].p->alive(now)) && ( ((_paths[i].p->localSocket() == path->localSocket())&&(_paths[i].p->address().ss_family == path->address().ss_family)) || (_paths[i].p->address().ipsEqual2(path->address())) ) ) {
|
|
|
|
|
|
+ if ( _paths[i].p->alive(now) && (_paths[i].p->localSocket() == path->localSocket()) && _paths[i].p->address().ipsEqual(path->address()) ) {
|
|
redundant = true;
|
|
redundant = true;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -166,12 +196,7 @@ void Peer::received(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- if (attemptToContact) {
|
|
|
|
- attemptToContactAt(tPtr,path->localSocket(),path->address(),now,true);
|
|
|
|
- path->sent(now);
|
|
|
|
- RR->t->peerConfirmingUnknownPath(tPtr,networkId,*this,path,packetId,verb);
|
|
|
|
|
|
+*/
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|