Fix to GitHub issue #140 -- network preferred relays. Also go ahead and allow RENDEZVOUS from regular peers.

This commit is contained in:
Adam Ierymenko 2015-06-01 19:05:27 -07:00
parent 960ceb4791
commit 5341e32729
6 changed files with 84 additions and 99 deletions

View file

@ -741,9 +741,11 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid)
if (nconf) {
unsigned int latency = ~((unsigned int)0);
for(std::vector< std::pair<Address,InetAddress> >::const_iterator r(nconf->relays().begin());r!=nconf->relays().end();++r) {
SharedPtr<Peer> rp(RR->topology->getPeer(r->first));
if ((rp->hasActiveDirectPath(now))&&(rp->latency() <= latency))
rp.swap(relay);
if (r->first != peer->address()) {
SharedPtr<Peer> rp(RR->topology->getPeer(r->first));
if ((rp)&&(rp->hasActiveDirectPath(now))&&(rp->latency() <= latency))
rp.swap(relay);
}
}
}
}