summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-07-06 16:32:34 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-07-06 16:32:34 -0700
commita87cd2d0941d5cf6b88f630159946ae66d3e464e (patch)
tree7593c2f2a6a08fb709b9510806f1356e0f24cd1a /node
parent235f4762b700174c795b28de7d4fe2f70cddbcd8 (diff)
downloadinfinitytier-a87cd2d0941d5cf6b88f630159946ae66d3e464e.tar.gz
infinitytier-a87cd2d0941d5cf6b88f630159946ae66d3e464e.zip
Unix side of local interface address awareness for GitHub issue #180.
Diffstat (limited to 'node')
-rw-r--r--node/InetAddress.cpp8
-rw-r--r--node/Peer.cpp1
2 files changed, 7 insertions, 2 deletions
diff --git a/node/InetAddress.cpp b/node/InetAddress.cpp
index 83de36d4..91bfbed6 100644
--- a/node/InetAddress.cpp
+++ b/node/InetAddress.cpp
@@ -91,7 +91,13 @@ InetAddress::IpScope InetAddress::ipScope() const
const unsigned char *ip = reinterpret_cast<const unsigned char *>(reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr);
if ((ip[0] & 0xf0) == 0xf0) {
if (ip[0] == 0xff) return IP_SCOPE_MULTICAST; // ff00::/8
- if ((ip[0] == 0xfe)&&((ip[1] & 0xc0) == 0x80)) return IP_SCOPE_LINK_LOCAL; // fe80::/10
+ if ((ip[0] == 0xfe)&&((ip[1] & 0xc0) == 0x80)) {
+ unsigned int k = 2;
+ while ((!ip[k])&&(k < 15)) ++k;
+ if ((k == 15)&&(ip[15] == 0x01))
+ return IP_SCOPE_LOOPBACK; // fe80::1/128
+ else return IP_SCOPE_LINK_LOCAL; // fe80::/10
+ }
if ((ip[0] & 0xfe) == 0xfc) return IP_SCOPE_PRIVATE; // fc00::/7
}
unsigned int k = 0;
diff --git a/node/Peer.cpp b/node/Peer.cpp
index 225fbdef..f5fdf7dd 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -214,7 +214,6 @@ void Peer::pushDirectPaths(const RuntimeEnvironment *RR,const std::vector<Path>
_lastDirectPathPush = now;
TRACE("pushing %u direct paths to %s",(unsigned int)dps.size(),_id.address().toString().c_str());
- printf("pushing %u direct paths to %s",(unsigned int)dps.size(),_id.address().toString().c_str());
std::vector<Path>::const_iterator p(dps.begin());
while (p != dps.end()) {