Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/ban.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include "database.h"
#include "databasetasks.h"

const std::optional<BanInfo> IOBan::getAccountBanInfo(uint32_t accountId)
namespace IOBan {

const std::optional<BanInfo> getAccountBanInfo(uint32_t accountId)
{
Database& db = Database::getInstance();

Expand Down Expand Up @@ -43,7 +45,7 @@ const std::optional<BanInfo> IOBan::getAccountBanInfo(uint32_t accountId)
return banInfo;
}

const std::optional<BanInfo> IOBan::getIpBanInfo(const Connection::Address& clientIP)
const std::optional<BanInfo> getIpBanInfo(const Connection::Address& clientIP)
{
if (clientIP.is_unspecified()) {
return std::nullopt;
Expand Down Expand Up @@ -77,9 +79,11 @@ const std::optional<BanInfo> IOBan::getIpBanInfo(const Connection::Address& clie
return banInfo;
}

bool IOBan::isPlayerNamelocked(uint32_t playerId)
bool isPlayerNamelocked(uint32_t playerId)
{
return Database::getInstance()
.storeQuery(fmt::format("SELECT 1 FROM `player_namelocks` WHERE `player_id` = {:d}", playerId))
.get();
}

} // namespace IOBan
14 changes: 7 additions & 7 deletions src/ban.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

#include "connection.h"

namespace IOBan {

struct BanInfo
{
std::string bannedBy;
std::string reason;
time_t expiresAt;
};

class IOBan
{
public:
static const std::optional<BanInfo> getAccountBanInfo(uint32_t accountId);
static const std::optional<BanInfo> getIpBanInfo(const Connection::Address& clientIP);
static bool isPlayerNamelocked(uint32_t playerId);
};
const std::optional<BanInfo> getAccountBanInfo(uint32_t accountId);
const std::optional<BanInfo> getIpBanInfo(const Connection::Address& clientIP);
bool isPlayerNamelocked(uint32_t playerId);

}; // namespace IOBan

#endif // FS_BAN_H