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

Function LoadIPGroupsFromFile

src/ipgroups.cpp:218–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218static bool LoadIPGroupsFromFile(const boost::filesystem::path &path, const string &group_name, int priority) {
219 boost::filesystem::ifstream stream(path);
220 if (!stream.good()) {
221 LogPrintf("IP Priority: Unable to read specified IP priority source file %s\n", path.string());
222 return false;
223 }
224
225 stringstream buf;
226 buf << stream.rdbuf();
227
228 CIPGroup group;
229 group.header.name = group_name;
230 group.header.priority = priority;
231
232 group.subnets = ParseIPData(buf.str());
233 if (group.subnets.size() == 0) {
234 LogPrintf("IP Priority: File empty or unable to understand the contents of %s\n", path.string());
235 return false;
236 }
237
238 AddOrReplace(group);
239 return true;
240}
241
242void InitIPGroupsFromCommandLine() {
243 // Allow IP groups to be loaded from a file passed in via the command line.

Callers 1

BOOST_FOREACHFunction · 0.85

Calls 5

ParseIPDataFunction · 0.85
AddOrReplaceFunction · 0.85
rdbufMethod · 0.80
strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected