mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 22:17:31 +00:00
replace white and blacklist (#1530)
This commit is contained in:
parent
24de0e5fdb
commit
b340d7c8f9
@ -103,7 +103,7 @@ make_directory(${CMAKE_BINARY_DIR}/resServer)
|
|||||||
make_directory(${CMAKE_BINARY_DIR}/logs)
|
make_directory(${CMAKE_BINARY_DIR}/logs)
|
||||||
|
|
||||||
# Copy resource files on first build
|
# Copy resource files on first build
|
||||||
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blacklist.dcf")
|
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blocklist.dcf")
|
||||||
message(STATUS "Checking resource file integrity")
|
message(STATUS "Checking resource file integrity")
|
||||||
|
|
||||||
include(Utils)
|
include(Utils)
|
||||||
|
@ -27,8 +27,8 @@ dChatFilter::dChatFilter(const std::string& filepath, bool dontGenerateDCF) {
|
|||||||
ExportWordlistToDCF(filepath + ".dcf", true);
|
ExportWordlistToDCF(filepath + ".dcf", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BinaryIO::DoesFileExist("blacklist.dcf")) {
|
if (BinaryIO::DoesFileExist("blocklist.dcf")) {
|
||||||
ReadWordlistDCF("blacklist.dcf", false);
|
ReadWordlistDCF("blocklist.dcf", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Read player names that are ok as well:
|
//Read player names that are ok as well:
|
||||||
@ -44,20 +44,20 @@ dChatFilter::~dChatFilter() {
|
|||||||
m_DeniedWords.clear();
|
m_DeniedWords.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dChatFilter::ReadWordlistPlaintext(const std::string& filepath, bool whiteList) {
|
void dChatFilter::ReadWordlistPlaintext(const std::string& filepath, bool allowList) {
|
||||||
std::ifstream file(filepath);
|
std::ifstream file(filepath);
|
||||||
if (file) {
|
if (file) {
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(file, line)) {
|
while (std::getline(file, line)) {
|
||||||
line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
|
line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
|
||||||
std::transform(line.begin(), line.end(), line.begin(), ::tolower); //Transform to lowercase
|
std::transform(line.begin(), line.end(), line.begin(), ::tolower); //Transform to lowercase
|
||||||
if (whiteList) m_ApprovedWords.push_back(CalculateHash(line));
|
if (allowList) m_ApprovedWords.push_back(CalculateHash(line));
|
||||||
else m_DeniedWords.push_back(CalculateHash(line));
|
else m_DeniedWords.push_back(CalculateHash(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool whiteList) {
|
bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool allowList) {
|
||||||
std::ifstream file(filepath, std::ios::binary);
|
std::ifstream file(filepath, std::ios::binary);
|
||||||
if (file) {
|
if (file) {
|
||||||
fileHeader hdr;
|
fileHeader hdr;
|
||||||
@ -70,13 +70,13 @@ bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool whiteList) {
|
|||||||
if (hdr.formatVersion == formatVersion) {
|
if (hdr.formatVersion == formatVersion) {
|
||||||
size_t wordsToRead = 0;
|
size_t wordsToRead = 0;
|
||||||
BinaryIO::BinaryRead(file, wordsToRead);
|
BinaryIO::BinaryRead(file, wordsToRead);
|
||||||
if (whiteList) m_ApprovedWords.reserve(wordsToRead);
|
if (allowList) m_ApprovedWords.reserve(wordsToRead);
|
||||||
else m_DeniedWords.reserve(wordsToRead);
|
else m_DeniedWords.reserve(wordsToRead);
|
||||||
|
|
||||||
size_t word = 0;
|
size_t word = 0;
|
||||||
for (size_t i = 0; i < wordsToRead; ++i) {
|
for (size_t i = 0; i < wordsToRead; ++i) {
|
||||||
BinaryIO::BinaryRead(file, word);
|
BinaryIO::BinaryRead(file, word);
|
||||||
if (whiteList) m_ApprovedWords.push_back(word);
|
if (allowList) m_ApprovedWords.push_back(word);
|
||||||
else m_DeniedWords.push_back(word);
|
else m_DeniedWords.push_back(word);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,14 +90,14 @@ bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool whiteList) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dChatFilter::ExportWordlistToDCF(const std::string& filepath, bool whiteList) {
|
void dChatFilter::ExportWordlistToDCF(const std::string& filepath, bool allowList) {
|
||||||
std::ofstream file(filepath, std::ios::binary | std::ios_base::out);
|
std::ofstream file(filepath, std::ios::binary | std::ios_base::out);
|
||||||
if (file) {
|
if (file) {
|
||||||
BinaryIO::BinaryWrite(file, uint32_t(dChatFilterDCF::header));
|
BinaryIO::BinaryWrite(file, uint32_t(dChatFilterDCF::header));
|
||||||
BinaryIO::BinaryWrite(file, uint32_t(dChatFilterDCF::formatVersion));
|
BinaryIO::BinaryWrite(file, uint32_t(dChatFilterDCF::formatVersion));
|
||||||
BinaryIO::BinaryWrite(file, size_t(whiteList ? m_ApprovedWords.size() : m_DeniedWords.size()));
|
BinaryIO::BinaryWrite(file, size_t(allowList ? m_ApprovedWords.size() : m_DeniedWords.size()));
|
||||||
|
|
||||||
for (size_t word : whiteList ? m_ApprovedWords : m_DeniedWords) {
|
for (size_t word : allowList ? m_ApprovedWords : m_DeniedWords) {
|
||||||
BinaryIO::BinaryWrite(file, word);
|
BinaryIO::BinaryWrite(file, word);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,10 +105,10 @@ void dChatFilter::ExportWordlistToDCF(const std::string& filepath, bool whiteLis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<uint8_t, uint8_t>> dChatFilter::IsSentenceOkay(const std::string& message, eGameMasterLevel gmLevel, bool whiteList) {
|
std::vector<std::pair<uint8_t, uint8_t>> dChatFilter::IsSentenceOkay(const std::string& message, eGameMasterLevel gmLevel, bool allowList) {
|
||||||
if (gmLevel > eGameMasterLevel::FORUM_MODERATOR) return { }; //If anything but a forum mod, return true.
|
if (gmLevel > eGameMasterLevel::FORUM_MODERATOR) return { }; //If anything but a forum mod, return true.
|
||||||
if (message.empty()) return { };
|
if (message.empty()) return { };
|
||||||
if (!whiteList && m_DeniedWords.empty()) return { { 0, message.length() } };
|
if (!allowList && m_DeniedWords.empty()) return { { 0, message.length() } };
|
||||||
|
|
||||||
std::stringstream sMessage(message);
|
std::stringstream sMessage(message);
|
||||||
std::string segment;
|
std::string segment;
|
||||||
@ -126,16 +126,16 @@ std::vector<std::pair<uint8_t, uint8_t>> dChatFilter::IsSentenceOkay(const std::
|
|||||||
|
|
||||||
size_t hash = CalculateHash(segment);
|
size_t hash = CalculateHash(segment);
|
||||||
|
|
||||||
if (std::find(m_UserUnapprovedWordCache.begin(), m_UserUnapprovedWordCache.end(), hash) != m_UserUnapprovedWordCache.end() && whiteList) {
|
if (std::find(m_UserUnapprovedWordCache.begin(), m_UserUnapprovedWordCache.end(), hash) != m_UserUnapprovedWordCache.end() && allowList) {
|
||||||
listOfBadSegments.emplace_back(position, originalSegment.length());
|
listOfBadSegments.emplace_back(position, originalSegment.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find(m_ApprovedWords.begin(), m_ApprovedWords.end(), hash) == m_ApprovedWords.end() && whiteList) {
|
if (std::find(m_ApprovedWords.begin(), m_ApprovedWords.end(), hash) == m_ApprovedWords.end() && allowList) {
|
||||||
m_UserUnapprovedWordCache.push_back(hash);
|
m_UserUnapprovedWordCache.push_back(hash);
|
||||||
listOfBadSegments.emplace_back(position, originalSegment.length());
|
listOfBadSegments.emplace_back(position, originalSegment.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find(m_DeniedWords.begin(), m_DeniedWords.end(), hash) != m_DeniedWords.end() && !whiteList) {
|
if (std::find(m_DeniedWords.begin(), m_DeniedWords.end(), hash) != m_DeniedWords.end() && !allowList) {
|
||||||
m_UserUnapprovedWordCache.push_back(hash);
|
m_UserUnapprovedWordCache.push_back(hash);
|
||||||
listOfBadSegments.emplace_back(position, originalSegment.length());
|
listOfBadSegments.emplace_back(position, originalSegment.length());
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ public:
|
|||||||
dChatFilter(const std::string& filepath, bool dontGenerateDCF);
|
dChatFilter(const std::string& filepath, bool dontGenerateDCF);
|
||||||
~dChatFilter();
|
~dChatFilter();
|
||||||
|
|
||||||
void ReadWordlistPlaintext(const std::string& filepath, bool whiteList);
|
void ReadWordlistPlaintext(const std::string& filepath, bool allowList);
|
||||||
bool ReadWordlistDCF(const std::string& filepath, bool whiteList);
|
bool ReadWordlistDCF(const std::string& filepath, bool allowList);
|
||||||
void ExportWordlistToDCF(const std::string& filepath, bool whiteList);
|
void ExportWordlistToDCF(const std::string& filepath, bool allowList);
|
||||||
std::vector<std::pair<uint8_t, uint8_t>> IsSentenceOkay(const std::string& message, eGameMasterLevel gmLevel, bool whiteList = true);
|
std::vector<std::pair<uint8_t, uint8_t>> IsSentenceOkay(const std::string& message, eGameMasterLevel gmLevel, bool allowList = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_DontGenerateDCF;
|
bool m_DontGenerateDCF;
|
||||||
|
@ -29,8 +29,8 @@ enum class eWorldMessageType : uint32_t {
|
|||||||
ROUTE_PACKET, // Social?
|
ROUTE_PACKET, // Social?
|
||||||
POSITION_UPDATE,
|
POSITION_UPDATE,
|
||||||
MAIL,
|
MAIL,
|
||||||
WORD_CHECK, // Whitelist word check
|
WORD_CHECK, // AllowList word check
|
||||||
STRING_CHECK, // Whitelist string check
|
STRING_CHECK, // AllowList string check
|
||||||
GET_PLAYERS_IN_ZONE,
|
GET_PLAYERS_IN_ZONE,
|
||||||
REQUEST_UGC_MANIFEST_INFO,
|
REQUEST_UGC_MANIFEST_INFO,
|
||||||
BLUEPRINT_GET_ALL_DATA_REQUEST,
|
BLUEPRINT_GET_ALL_DATA_REQUEST,
|
||||||
|
@ -83,7 +83,7 @@ void UserManager::Initialize() {
|
|||||||
auto chatListStream = Game::assetManager->GetFile("chatplus_en_us.txt");
|
auto chatListStream = Game::assetManager->GetFile("chatplus_en_us.txt");
|
||||||
if (!chatListStream) {
|
if (!chatListStream) {
|
||||||
LOG("Failed to load %s", (Game::assetManager->GetResPath() / "chatplus_en_us.txt").string().c_str());
|
LOG("Failed to load %s", (Game::assetManager->GetResPath() / "chatplus_en_us.txt").string().c_str());
|
||||||
throw std::runtime_error("Aborting initialization due to missing chat whitelist file.");
|
throw std::runtime_error("Aborting initialization due to missing chat allowlist file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (std::getline(chatListStream, line, '\n')) {
|
while (std::getline(chatListStream, line, '\n')) {
|
||||||
|
@ -352,16 +352,11 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
|||||||
|
|
||||||
auto* spawner = Game::zoneManager->GetSpawner(spawnerId);
|
auto* spawner = Game::zoneManager->GetSpawner(spawnerId);
|
||||||
|
|
||||||
auto ldfModelBehavior = new LDFData<LWOOBJID>(u"modelBehaviors", 0);
|
info.nodes[0]->config.push_back(new LDFData<LWOOBJID>(u"modelBehaviors", 0));
|
||||||
auto userModelID = new LDFData<LWOOBJID>(u"userModelID", info.spawnerID);
|
info.nodes[0]->config.push_back(new LDFData<LWOOBJID>(u"userModelID", info.spawnerID));
|
||||||
auto modelType = new LDFData<int>(u"modelType", 2);
|
info.nodes[0]->config.push_back(new LDFData<int>(u"modelType", 2));
|
||||||
auto propertyObjectID = new LDFData<bool>(u"propertyObjectID", true);
|
info.nodes[0]->config.push_back(new LDFData<bool>(u"propertyObjectID", true));
|
||||||
auto componentWhitelist = new LDFData<int>(u"componentWhitelist", 1);
|
info.nodes[0]->config.push_back(new LDFData<int>(u"componentWhitelist", 1));
|
||||||
info.nodes[0]->config.push_back(componentWhitelist);
|
|
||||||
info.nodes[0]->config.push_back(ldfModelBehavior);
|
|
||||||
info.nodes[0]->config.push_back(modelType);
|
|
||||||
info.nodes[0]->config.push_back(propertyObjectID);
|
|
||||||
info.nodes[0]->config.push_back(userModelID);
|
|
||||||
|
|
||||||
auto* model = spawner->Spawn();
|
auto* model = spawner->Spawn();
|
||||||
|
|
||||||
@ -585,29 +580,17 @@ void PropertyManagementComponent::Load() {
|
|||||||
GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER);
|
GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER);
|
||||||
GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT);
|
GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT);
|
||||||
|
|
||||||
LDFBaseData* ldfBlueprintID = new LDFData<LWOOBJID>(u"blueprintid", blueprintID);
|
settings.push_back(new LDFData<LWOOBJID>(u"blueprintid", blueprintID));
|
||||||
LDFBaseData* componentWhitelist = new LDFData<int>(u"componentWhitelist", 1);
|
settings.push_back(new LDFData<int>(u"componentWhitelist", 1));
|
||||||
LDFBaseData* modelType = new LDFData<int>(u"modelType", 2);
|
settings.push_back(new LDFData<int>(u"modelType", 2));
|
||||||
LDFBaseData* propertyObjectID = new LDFData<bool>(u"propertyObjectID", true);
|
settings.push_back(new LDFData<bool>(u"propertyObjectID", true));
|
||||||
LDFBaseData* userModelID = new LDFData<LWOOBJID>(u"userModelID", databaseModel.id);
|
settings.push_back(new LDFData<LWOOBJID>(u"userModelID", databaseModel.id));
|
||||||
|
|
||||||
settings.push_back(ldfBlueprintID);
|
|
||||||
settings.push_back(componentWhitelist);
|
|
||||||
settings.push_back(modelType);
|
|
||||||
settings.push_back(propertyObjectID);
|
|
||||||
settings.push_back(userModelID);
|
|
||||||
} else {
|
} else {
|
||||||
auto modelType = new LDFData<int>(u"modelType", 2);
|
settings.push_back(new LDFData<int>(u"modelType", 2));
|
||||||
auto userModelID = new LDFData<LWOOBJID>(u"userModelID", databaseModel.id);
|
settings.push_back(new LDFData<LWOOBJID>(u"userModelID", databaseModel.id));
|
||||||
auto ldfModelBehavior = new LDFData<LWOOBJID>(u"modelBehaviors", 0);
|
settings.push_back(new LDFData<LWOOBJID>(u"modelBehaviors", 0));
|
||||||
auto propertyObjectID = new LDFData<bool>(u"propertyObjectID", true);
|
settings.push_back(new LDFData<bool>(u"propertyObjectID", true));
|
||||||
auto componentWhitelist = new LDFData<int>(u"componentWhitelist", 1);
|
settings.push_back(new LDFData<int>(u"componentWhitelist", 1));
|
||||||
|
|
||||||
settings.push_back(componentWhitelist);
|
|
||||||
settings.push_back(ldfModelBehavior);
|
|
||||||
settings.push_back(modelType);
|
|
||||||
settings.push_back(propertyObjectID);
|
|
||||||
settings.push_back(userModelID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node->config = settings;
|
node->config = settings;
|
||||||
|
@ -2663,17 +2663,11 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream& inStream, Entity* ent
|
|||||||
info.spawnerID = entity->GetObjectID();
|
info.spawnerID = entity->GetObjectID();
|
||||||
info.spawnerNodeID = 0;
|
info.spawnerNodeID = 0;
|
||||||
|
|
||||||
LDFBaseData* ldfBlueprintID = new LDFData<LWOOBJID>(u"blueprintid", blueprintID);
|
info.settings.push_back(new LDFData<LWOOBJID>(u"blueprintid", blueprintID));
|
||||||
LDFBaseData* componentWhitelist = new LDFData<int>(u"componentWhitelist", 1);
|
info.settings.push_back(new LDFData<int>(u"componentWhitelist", 1));
|
||||||
LDFBaseData* modelType = new LDFData<int>(u"modelType", 2);
|
info.settings.push_back(new LDFData<int>(u"modelType", 2));
|
||||||
LDFBaseData* propertyObjectID = new LDFData<bool>(u"propertyObjectID", true);
|
info.settings.push_back(new LDFData<bool>(u"propertyObjectID", true));
|
||||||
LDFBaseData* userModelID = new LDFData<LWOOBJID>(u"userModelID", newIDL);
|
info.settings.push_back(new LDFData<LWOOBJID>(u"userModelID", newIDL));
|
||||||
|
|
||||||
info.settings.push_back(ldfBlueprintID);
|
|
||||||
info.settings.push_back(componentWhitelist);
|
|
||||||
info.settings.push_back(modelType);
|
|
||||||
info.settings.push_back(propertyObjectID);
|
|
||||||
info.settings.push_back(userModelID);
|
|
||||||
|
|
||||||
Entity* newEntity = Game::entityManager->CreateEntity(info, nullptr);
|
Entity* newEntity = Game::entityManager->CreateEntity(info, nullptr);
|
||||||
if (newEntity) {
|
if (newEntity) {
|
||||||
|
Loading…
Reference in New Issue
Block a user