2021-05-29 07:31:33 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "ConfigUtil.hpp"
|
|
|
|
#include "Util.hpp"
|
2021-09-13 14:24:50 -05:00
|
|
|
#include "CommandControl.hpp"
|
2021-05-29 07:31:33 -05:00
|
|
|
|
2021-09-13 14:24:50 -05:00
|
|
|
namespace CommandControl
|
2021-05-29 07:31:33 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
bool FreemiumManager::_isFreemiumUser = false;
|
|
|
|
std::vector<std::string> FreemiumManager::FreemiumDenyList;
|
|
|
|
std::string FreemiumManager::FreemiumDenyListString;
|
|
|
|
|
|
|
|
FreemiumManager::FreemiumManager() {}
|
|
|
|
|
|
|
|
void FreemiumManager::generateDenyList()
|
|
|
|
{
|
|
|
|
#ifdef ENABLE_FREEMIUM
|
|
|
|
|
|
|
|
FreemiumDenyListString = config::getString("freemium.disabled_commands", "");
|
|
|
|
Util::trim(FreemiumDenyListString);
|
|
|
|
StringVector commandList = Util::tokenize(FreemiumDenyListString);
|
|
|
|
|
|
|
|
std::string command;
|
|
|
|
for (std::size_t i = 0; i < commandList.size(); i++)
|
|
|
|
{
|
|
|
|
// just an extra check to make sure any whitespace does not sniff in command
|
|
|
|
// or else command will not be recognized
|
|
|
|
command = Util::trim_whitespace(commandList[i]);
|
|
|
|
if(!command.empty())
|
|
|
|
{
|
|
|
|
FreemiumDenyList.emplace_back(command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector<std::string>& FreemiumManager::getFreemiumDenyList()
|
|
|
|
{
|
|
|
|
if (FreemiumDenyList.empty())
|
|
|
|
generateDenyList();
|
|
|
|
|
|
|
|
return FreemiumDenyList;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string FreemiumManager::getFreemiumDenyListString()
|
|
|
|
{
|
|
|
|
if (FreemiumDenyListString.empty())
|
|
|
|
generateDenyList();
|
|
|
|
|
|
|
|
return FreemiumDenyListString;
|
|
|
|
}
|
2021-09-13 14:24:50 -05:00
|
|
|
} // namespace CommandControl
|
2021-05-29 07:31:33 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|