Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
ban.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "util/string.h"
8#include <string>
9#include <mutex>
10
12{
13public:
14 BanManager(const std::string &banfilepath);
16 void load();
17 void save();
18 bool isIpBanned(const std::string &ip) const;
19 // Supplying ip_or_name = "" lists all bans.
20 std::string getBanDescription(const std::string &ip_or_name) const;
21 std::string getBanName(const std::string &ip) const;
22 void add(const std::string &ip, const std::string &name);
23 void remove(const std::string &ip_or_name);
24 bool isModified() const;
25
26private:
27 mutable std::mutex m_mutex;
28 std::string m_banfilepath = "";
30 bool m_modified = false;
31};
Definition ban.h:12
void save()
Definition ban.cpp:54
StringMap m_ips
Definition ban.h:29
std::mutex m_mutex
Definition ban.h:27
std::string getBanName(const std::string &ip) const
Definition ban.cpp:91
std::string m_banfilepath
Definition ban.h:28
std::string getBanDescription(const std::string &ip_or_name) const
Definition ban.cpp:77
void add(const std::string &ip, const std::string &name)
Definition ban.cpp:100
bool isIpBanned(const std::string &ip) const
Definition ban.cpp:71
void load()
Definition ban.cpp:32
void remove(const std::string &ip_or_name)
Definition ban.cpp:107
bool isModified() const
Definition ban.cpp:121
~BanManager()
Definition ban.cpp:27
bool m_modified
Definition ban.h:30
BanManager(const std::string &banfilepath)
Definition ban.cpp:16
std::unordered_map< std::string, std::string > StringMap
Definition string.h:66