MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / IsLocal

Method IsLocal

src/netaddress.cpp:398–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396}
397
398bool CNetAddr::IsLocal() const
399{
400 // IPv4 loopback (127.0.0.0/8 or 0.0.0.0/8)
401 if (IsIPv4() && (m_addr[0] == 127 || m_addr[0] == 0)) {
402 return true;
403 }
404
405 // IPv6 loopback (::1/128)
406 static const unsigned char pchLocal[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
407 if (IsIPv6() && memcmp(m_addr.data(), pchLocal, sizeof(pchLocal)) == 0) {
408 return true;
409 }
410
411 return false;
412}
413
414/**
415 * @returns Whether or not this network address is a valid address that @a could

Callers 6

GetGroupMethod · 0.80
AddPeerMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
FUZZ_TARGETFunction · 0.80

Calls 3

IsIPv4Function · 0.85
IsIPv6Function · 0.85
dataMethod · 0.45

Tested by 3

AddPeerMethod · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
FUZZ_TARGETFunction · 0.64