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

Method Match

src/netaddress.cpp:1019–1045  ·  view source on GitHub ↗

* @returns True if this subnet is valid, the specified address is valid, and * the specified address belongs in this subnet. */

Source from the content-addressed store, hash-verified

1017 * the specified address belongs in this subnet.
1018 */
1019bool CSubNet::Match(const CNetAddr &addr) const
1020{
1021 if (!valid || !addr.IsValid() || network.m_net != addr.m_net)
1022 return false;
1023
1024 switch (network.m_net) {
1025 case NET_IPV4:
1026 case NET_IPV6:
1027 break;
1028 case NET_ONION:
1029 case NET_I2P:
1030 case NET_CJDNS:
1031 case NET_INTERNAL:
1032 return addr == network;
1033 case NET_UNROUTABLE:
1034 case NET_MAX:
1035 return false;
1036 }
1037
1038 assert(network.m_addr.size() == addr.m_addr.size());
1039 for (size_t x = 0; x < addr.m_addr.size(); ++x) {
1040 if ((addr.m_addr[x] & netmask[x]) != network.m_addr[x]) {
1041 return false;
1042 }
1043 }
1044 return true;
1045}
1046
1047std::string CSubNet::ToString() const
1048{

Callers 4

ClientAllowedFunction · 0.45
IsBannedMethod · 0.45
DisconnectNodeMethod · 0.45

Calls 2

IsValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected