| 216 | } |
| 217 | |
| 218 | static 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 | |
| 242 | void InitIPGroupsFromCommandLine() { |
| 243 | // Allow IP groups to be loaded from a file passed in via the command line. |
no test coverage detected