MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / FindGroupForIP

Function FindGroupForIP

src/ipgroups.cpp:45–61  ·  view source on GitHub ↗

Returns the empty/default group if the IP does not belong to any group.

Source from the content-addressed store, hash-verified

43
44// Returns the empty/default group if the IP does not belong to any group.
45CIPGroupData FindGroupForIP(CNetAddr ip) {
46 LOCK(*cs_groups);
47 if (!ip.IsValid()) {
48 LogPrintf("IP is not valid: %s\n", ip.ToString());
49 return CIPGroupData(); // Default.
50 }
51
52 BOOST_FOREACH(CIPGroup &group, groups)
53 {
54 BOOST_FOREACH(const CSubNet &subNet, group.subnets)
55 {
56 if (subNet.Match(ip))
57 return group.header;
58 }
59 }
60 return CIPGroupData();
61}
62
63vector<CSubNet> ParseIPData(string input) {
64 vector<string> lines;

Callers 4

AssignIPGroupSlotFunction · 0.85
BOOST_FOREACHFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 3

CIPGroupDataClass · 0.85
IsValidMethod · 0.45
ToStringMethod · 0.45

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68