diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-11-02 16:03:28 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-11-02 16:03:28 -0800 |
| commit | 4e9d4304761f93a1764d3ec2d2b0c38140decad8 (patch) | |
| tree | 63bc6275a128ebea4723cbca09e4899de425d522 /node/Switch.cpp | |
| parent | 00dcb0f22c6c4ee9e983510cff783c678afd43fa (diff) | |
| download | infinitytier-4e9d4304761f93a1764d3ec2d2b0c38140decad8.tar.gz infinitytier-4e9d4304761f93a1764d3ec2d2b0c38140decad8.zip | |
Make root and relay selection somewhat more robust.
Diffstat (limited to 'node/Switch.cpp')
| -rw-r--r-- | node/Switch.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp index 120ce7a4..b7a9c522 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -741,12 +741,15 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid) if (!viaPath) { // See if this network has a preferred relay (if packet has an associated network) if (nconf) { - unsigned int latency = ~((unsigned int)0); + unsigned int bestq = ~((unsigned int)0); for(std::vector< std::pair<Address,InetAddress> >::const_iterator r(nconf->relays().begin());r!=nconf->relays().end();++r) { if (r->first != peer->address()) { SharedPtr<Peer> rp(RR->topology->getPeer(r->first)); - if ((rp)&&(rp->hasActiveDirectPath(now))&&(rp->latency() <= latency)) + const unsigned int q = rp->relayQuality(now); + if ((rp)&&(q < bestq)) { // SUBTILE: < == don't use these if they are nil quality (unsigned int max), instead use a root + bestq = q; rp.swap(relay); + } } } } |
