MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / LoadIpBanList

Function LoadIpBanList

engine/Poseidon/Network/IpBan.cpp:57–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void 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
86void SaveIpBanList(RString path, const FindArray<uint32_t>& list)
87{

Callers 3

NetworkServerMethod · 0.85
OnMessageMethod · 0.85

Calls 9

ParseIPv4Function · 0.85
clearMethod · 0.80
ClearMethod · 0.45
openMethod · 0.45
emptyMethod · 0.45
AddUniqueMethod · 0.45
eofMethod · 0.45
failMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected