From 52c3b7c34e52534ab4f3c92b28d65f8713cda299 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 7 Apr 2015 11:56:10 -0700 Subject: Implemented empirical determination of external addressing, paritioned per scope. --- node/Peer.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'node/Peer.cpp') diff --git a/node/Peer.cpp b/node/Peer.cpp index debb4533..beaa9d3b 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -192,6 +192,34 @@ void Peer::clearPaths(bool fixedToo) } } +void Peer::resetWithinScope(const RuntimeEnvironment *RR,InetAddress::IpScope scope,uint64_t now) +{ + unsigned int np = _numPaths; + unsigned int x = 0; + unsigned int y = 0; + while (x < np) { + if (_paths[x].address().ipScope() == scope) { + if (_paths[x].fixed()) { + Packet outp(_id.address(),RR->identity.address(),Packet::VERB_NOP); + outp.armor(_key,false); + RR->node->putPacket(_paths[x].address(),outp.data(),outp.size(),_paths[x].desperation(now)); + _paths[y++] = _paths[x]; // keep fixed paths + } + } else { + _paths[y++] = _paths[x]; // keep paths not in this scope + } + ++x; + } + _numPaths = y; + + if ((y < np)&&(alive(now))) { + // Try to re-establish direct connectivity to this peer if it's alive + // and we have forgotten paths to it. + Packet outp(_id.address(),RR->identity.address(),Packet::VERB_NOP); + RR->sw->send(outp,true); + } +} + void Peer::getBestActiveAddresses(uint64_t now,InetAddress &v4,InetAddress &v6) const { uint64_t bestV4 = 0,bestV6 = 0; -- cgit v1.2.3