summaryrefslogtreecommitdiff
path: root/node/Peer.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-04-07 11:56:10 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-04-07 11:56:10 -0700
commit52c3b7c34e52534ab4f3c92b28d65f8713cda299 (patch)
tree6a66f99b253059961a02e1fa07ebc9890ef91a61 /node/Peer.cpp
parent817824b88bce8d2e5659226b80d3f232633c557f (diff)
downloadinfinitytier-52c3b7c34e52534ab4f3c92b28d65f8713cda299.tar.gz
infinitytier-52c3b7c34e52534ab4f3c92b28d65f8713cda299.zip
Implemented empirical determination of external addressing, paritioned per scope.
Diffstat (limited to 'node/Peer.cpp')
-rw-r--r--node/Peer.cpp28
1 files changed, 28 insertions, 0 deletions
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;