MCPcopy Create free account
hub / github.com/ElementsProject/elements / IsLocal

Method IsLocal

src/netaddress.cpp:425–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423bool CNetAddr::IsCJDNS() const { return m_net == NET_CJDNS; }
424
425bool CNetAddr::IsLocal() const
426{
427 // IPv4 loopback (127.0.0.0/8 or 0.0.0.0/8)
428 if (IsIPv4() && (m_addr[0] == 127 || m_addr[0] == 0)) {
429 return true;
430 }
431
432 // IPv6 loopback (::1/128)
433 static const unsigned char pchLocal[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
434 if (IsIPv6() && memcmp(m_addr.data(), pchLocal, sizeof(pchLocal)) == 0) {
435 return true;
436 }
437
438 return false;
439}
440
441/**
442 * @returns Whether or not this network address is a valid address that @a could

Callers 4

BOOST_AUTO_TEST_CASEFunction · 0.80
FUZZ_TARGETFunction · 0.80

Calls 1

dataMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.64
FUZZ_TARGETFunction · 0.64