Changeset View
Changeset View
Standalone View
Standalone View
src/netaddress.cpp
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool CNetAddr::IsTor() const { | bool CNetAddr::IsTor() const { | ||||
return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0); | return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0); | ||||
} | } | ||||
bool CNetAddr::IsLocal() const { | bool CNetAddr::IsLocal() const { | ||||
// IPv4 loopback | // IPv4 loopback | ||||
if (IsIPv4() && (GetByte(3) == 127 || GetByte(3) == 0)) return true; | if (IsIPv4() && (GetByte(3) == 127 || GetByte(3) == 0)) { | ||||
return true; | |||||
} | |||||
// IPv6 loopback (::1/128) | // IPv6 loopback (::1/128) | ||||
static const uint8_t pchLocal[16] = {0, 0, 0, 0, 0, 0, 0, 0, | static const uint8_t pchLocal[16] = {0, 0, 0, 0, 0, 0, 0, 0, | ||||
0, 0, 0, 0, 0, 0, 0, 1}; | 0, 0, 0, 0, 0, 0, 0, 1}; | ||||
if (memcmp(ip, pchLocal, 16) == 0) return true; | if (memcmp(ip, pchLocal, 16) == 0) { | ||||
return true; | |||||
} | |||||
return false; | return false; | ||||
} | } | ||||
bool CNetAddr::IsValid() const { | bool CNetAddr::IsValid() const { | ||||
// Cleanup 3-byte shifted addresses caused by garbage in size field of addr | // Cleanup 3-byte shifted addresses caused by garbage in size field of addr | ||||
// messages from versions before 0.2.9 checksum. | // messages from versions before 0.2.9 checksum. | ||||
// Two consecutive addr messages look like this: | // Two consecutive addr messages look like this: | ||||
▲ Show 20 Lines • Show All 556 Lines • Show Last 20 Lines |