| 55 | } |
| 56 | |
| 57 | void LoadIpBanList(RString path, FindArray<uint32_t>& out) |
| 58 | { |
| 59 | out.Clear(); |
| 60 | QIFStream f; |
| 61 | f.open(path); |
| 62 | std::string line; |
| 63 | auto flush = [&]() |
| 64 | { |
| 65 | if (!line.empty()) |
| 66 | { |
| 67 | uint32_t ip; |
| 68 | if (ParseIPv4(line.c_str(), ip)) |
| 69 | out.AddUnique(ip); |
| 70 | line.clear(); |
| 71 | } |
| 72 | }; |
| 73 | while (!f.eof() && !f.fail()) |
| 74 | { |
| 75 | int c = f.get(); |
| 76 | if (f.eof() || f.fail()) |
| 77 | break; |
| 78 | if (c == '\n' || c == '\r') |
| 79 | flush(); |
| 80 | else |
| 81 | line.push_back(static_cast<char>(c)); |
| 82 | } |
| 83 | flush(); |
| 84 | } |
| 85 | |
| 86 | void SaveIpBanList(RString path, const FindArray<uint32_t>& list) |
| 87 | { |