summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-19 14:04:36 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-19 14:04:36 -0700
commit584072fa6a86b7cca0a708d7dd4c302aa444f2b6 (patch)
tree436b2c5bd2230b768cae41079c11587954dab1e8
parent3adb183c5f76b69013d052383c4b812e3947041e (diff)
downloadinfinitytier-584072fa6a86b7cca0a708d7dd4c302aa444f2b6.tar.gz
infinitytier-584072fa6a86b7cca0a708d7dd4c302aa444f2b6.zip
Fix for V4/V6 stable addressing.
-rw-r--r--node/Node.cpp32
-rw-r--r--node/Peer.cpp1
2 files changed, 27 insertions, 6 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index 5aa4b7d3..26d5513e 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -197,10 +197,11 @@ public:
if (!stableEndpoint4) {
if (addr.ss_family == AF_INET)
stableEndpoint4 = addr;
- } else if (!stableEndpoint6) {
+ }
+ if (!stableEndpoint6) {
if (addr.ss_family == AF_INET6)
stableEndpoint6 = addr;
- } else break; // have both!
+ }
}
break;
}
@@ -223,10 +224,29 @@ public:
if (upstream) {
// "Upstream" devices are roots and relays and get special treatment -- they stay alive
// forever and we try to keep (if available) both IPv4 and IPv6 channels open to them.
- if ((!p->doPingAndKeepalive(RR,_now,AF_INET))&&(stableEndpoint4))
- p->attemptToContactAt(RR,InetAddress(),stableEndpoint4,_now);
- if ((!p->doPingAndKeepalive(RR,_now,AF_INET6))&&(stableEndpoint6))
- p->attemptToContactAt(RR,InetAddress(),stableEndpoint6,_now);
+ bool needToContactIndirect = true;
+ if (!p->doPingAndKeepalive(RR,_now,AF_INET)) {
+ if (stableEndpoint4) {
+ needToContactIndirect = false;
+ p->attemptToContactAt(RR,InetAddress(),stableEndpoint4,_now);
+ }
+ } else needToContactIndirect = false;
+ if (!p->doPingAndKeepalive(RR,_now,AF_INET6)) {
+ if (stableEndpoint6) {
+ needToContactIndirect = false;
+ p->attemptToContactAt(RR,InetAddress(),stableEndpoint6,_now);
+ }
+ } else needToContactIndirect = false;
+
+ if (needToContactIndirect) {
+ // If this is an upstream and we have no stable endpoint for either IPv4 or IPv6,
+ // send a NOP indirectly if possible to see if we can get to this peer in any
+ // way whatsoever. This will e.g. find network preferred relays that lack
+ // stable endpoints by using root servers.
+ Packet outp(p->address(),RR->identity.address(),Packet::VERB_NOP);
+ RR->sw->send(outp,true,0);
+ }
+
lastReceiveFromUpstream = std::max(p->lastReceive(),lastReceiveFromUpstream);
} else if (p->alive(_now)) {
// Normal nodes get their preferred link kept alive if the node has generated frame traffic recently
diff --git a/node/Peer.cpp b/node/Peer.cpp
index fdc8dca7..a9d2f671 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -205,6 +205,7 @@ bool Peer::doPingAndKeepalive(const RuntimeEnvironment *RR,uint64_t now,int inet
}
return true;
}
+
return false;
}