mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
comments, docs
This commit is contained in:
parent
3790ebe77a
commit
43780742b0
2 changed files with 4 additions and 0 deletions
|
@ -156,6 +156,8 @@ public:
|
||||||
*/
|
*/
|
||||||
inline unsigned int preferenceRank() const
|
inline unsigned int preferenceRank() const
|
||||||
{
|
{
|
||||||
|
// This causes us to rank paths in order of IP scope rank (see InetAdddress.hpp) but
|
||||||
|
// within each IP scope class to prefer IPv6 over IPv4.
|
||||||
return ( ((unsigned int)_ipScope << 1) | (unsigned int)(_addr.ss_family == AF_INET6) );
|
return ( ((unsigned int)_ipScope << 1) | (unsigned int)(_addr.ss_family == AF_INET6) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,7 @@ void Peer::received(
|
||||||
if (verb == Packet::VERB_OK) {
|
if (verb == Packet::VERB_OK) {
|
||||||
Mutex::Lock _l(_paths_m);
|
Mutex::Lock _l(_paths_m);
|
||||||
|
|
||||||
|
// Since this is a new path, figure out where to put it (possibly replacing an old/dead one)
|
||||||
unsigned int slot;
|
unsigned int slot;
|
||||||
if (_numPaths < ZT_MAX_PEER_NETWORK_PATHS) {
|
if (_numPaths < ZT_MAX_PEER_NETWORK_PATHS) {
|
||||||
slot = _numPaths++;
|
slot = _numPaths++;
|
||||||
|
@ -157,6 +158,7 @@ void Peer::received(
|
||||||
if (worstSlot >= 0) {
|
if (worstSlot >= 0) {
|
||||||
slot = (unsigned int)worstSlot;
|
slot = (unsigned int)worstSlot;
|
||||||
} else {
|
} else {
|
||||||
|
// If we can't find one with the same family, replace the worst of any family
|
||||||
slot = ZT_MAX_PEER_NETWORK_PATHS - 1;
|
slot = ZT_MAX_PEER_NETWORK_PATHS - 1;
|
||||||
for(unsigned int p=0;p<_numPaths;++p) {
|
for(unsigned int p=0;p<_numPaths;++p) {
|
||||||
const uint64_t s = _pathScore(p);
|
const uint64_t s = _pathScore(p);
|
||||||
|
|
Loading…
Add table
Reference in a new issue