Luanti 5.10.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 "threading/thread.h"
9#include "exceptions.h"
10#include <map>
11#include <string>
12#include <mutex>
13
15{
16public:
17 BanManager(const std::string &banfilepath);
19 void load();
20 void save();
21 bool isIpBanned(const std::string &ip);
22 // Supplying ip_or_name = "" lists all bans.
23 std::string getBanDescription(const std::string &ip_or_name);
24 std::string getBanName(const std::string &ip);
25 void add(const std::string &ip, const std::string &name);
26 void remove(const std::string &ip_or_name);
27 bool isModified();
28
29private:
30 std::mutex m_mutex;
31 std::string m_banfilepath = "";
33 bool m_modified = false;
34};
Definition ban.h:15
bool isModified()
Definition ban.cpp:121
std::string getBanDescription(const std::string &ip_or_name)
Definition ban.cpp:77
bool isIpBanned(const std::string &ip)
Definition ban.cpp:71
void save()
Definition ban.cpp:54
StringMap m_ips
Definition ban.h:32
std::mutex m_mutex
Definition ban.h:30
std::string m_banfilepath
Definition ban.h:31
std::string getBanName(const std::string &ip)
Definition ban.cpp:91
void add(const std::string &ip, const std::string &name)
Definition ban.cpp:100
void load()
Definition ban.cpp:32
void remove(const std::string &ip_or_name)
Definition ban.cpp:107
~BanManager()
Definition ban.cpp:27
bool m_modified
Definition ban.h:33
BanManager(const std::string &banfilepath)
Definition ban.cpp:16
std::unordered_map< std::string, std::string > StringMap
Definition string.h:65