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

Method Match

src/netaddress.cpp:1150–1176  ·  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

1148 * the specified address belongs in this subnet.
1149 */
1150bool CSubNet::Match(const CNetAddr &addr) const
1151{
1152 if (!valid || !addr.IsValid() || network.m_net != addr.m_net)
1153 return false;
1154
1155 switch (network.m_net) {
1156 case NET_IPV4:
1157 case NET_IPV6:
1158 break;
1159 case NET_ONION:
1160 case NET_I2P:
1161 case NET_CJDNS:
1162 case NET_INTERNAL:
1163 return addr == network;
1164 case NET_UNROUTABLE:
1165 case NET_MAX:
1166 return false;
1167 }
1168
1169 assert(network.m_addr.size() == addr.m_addr.size());
1170 for (size_t x = 0; x < addr.m_addr.size(); ++x) {
1171 if ((addr.m_addr[x] & netmask[x]) != network.m_addr[x]) {
1172 return false;
1173 }
1174 }
1175 return true;
1176}
1177
1178std::string CSubNet::ToString() const
1179{

Callers 5

ClientAllowedFunction · 0.45
IsBannedMethod · 0.45
FindNodeMethod · 0.45
DisconnectNodeMethod · 0.45

Calls 2

IsValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected