#sdasdad
6 messages · Page 1 of 1 (latest)
Not quite. Its
Magic String
Banned Usernames
Banned IPs
An empty list would be
CitraRoom-BanList-1
(Note the empty line)
A list with users and IPs would be
CitraRoom-BanList-1
user123
user456
user789
192.168.1.10
10.0.0.5
The IPs and users dont need to overlap, you can have name bans AND IP bans
static Network::Room::BanList LoadBanList(const std::string& path) {
std::ifstream file;
OpenFStream(file, path, std::ios_base::in);
if (!file || file.eof()) {
std::cout << "Could not open ban list!\n\n";
return {};
}
std::string magic;
std::getline(file, magic);
if (magic != BanListMagic) {
std::cout << "Ban list is not valid!\n\n";
return {};
}
// false = username ban list, true = ip ban list
bool ban_list_type = false;
Network::Room::UsernameBanList username_ban_list;
Network::Room::IPBanList ip_ban_list;
while (!file.eof()) {
std::string line;
std::getline(file, line);
line.erase(std::remove(line.begin(), line.end(), '\0'), line.end());
line = Common::StripSpaces(line);
if (line.empty()) {
// An empty line marks start of the IP ban list
ban_list_type = true;
continue;
}
if (ban_list_type) {
ip_ban_list.emplace_back(line);
} else {
username_ban_list.emplace_back(line);
}
}
return {username_ban_list, ip_ban_list};
}