Add IP Whitelist for rcon, add msg to gsc meth (#804)
This commit is contained in:
parent
3a3cf77b06
commit
68157481be
@ -94,8 +94,8 @@ namespace Components
|
||||
template <>
|
||||
struct std::hash<Components::Network::Address>
|
||||
{
|
||||
std::size_t operator()(const Components::Network::Address& k) const noexcept
|
||||
std::size_t operator()(const Components::Network::Address& x) const noexcept
|
||||
{
|
||||
return std::hash<std::string>()(k.getString());
|
||||
return std::hash<std::uint32_t>()(*reinterpret_cast<const std::uint32_t*>(&x.getIP().bytes[0])) ^ std::hash<std::uint16_t>()(x.getPort());
|
||||
}
|
||||
};
|
||||
|
@ -115,23 +115,8 @@ namespace Components
|
||||
|
||||
// Do not bounce if BGBounces is 0
|
||||
jle noBounce
|
||||
|
||||
push eax
|
||||
|
||||
mov eax, BGBouncesAllAngles
|
||||
mov eax, dword ptr [eax + 0x10]
|
||||
test eax, eax
|
||||
|
||||
pop eax
|
||||
|
||||
// Do not apply all angles patch if BGBouncesAllAngles is 0
|
||||
jle regularBounce
|
||||
|
||||
push 0x4B1B7D
|
||||
ret
|
||||
|
||||
|
||||
// Bounce
|
||||
regularBounce:
|
||||
push 0x4B1B34
|
||||
ret
|
||||
|
||||
|
@ -8,6 +8,8 @@ namespace Components
|
||||
{
|
||||
std::unordered_map<std::uint32_t, int> RCon::RateLimit;
|
||||
|
||||
std::vector<std::size_t> RCon::RconAddresses;
|
||||
|
||||
RCon::Container RCon::RconContainer;
|
||||
Utils::Cryptography::ECC::Key RCon::RconKey;
|
||||
|
||||
@ -76,6 +78,24 @@ namespace Components
|
||||
Network::SendCommand(target, "rconRequest");
|
||||
}
|
||||
});
|
||||
|
||||
Command::AddSV("RconWhitelistAdd", [](Command::Params* params)
|
||||
{
|
||||
if (params->size() < 2)
|
||||
{
|
||||
Logger::Print("Usage: %s <ip-address>\n", params->get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
Network::Address address(params->get(1));
|
||||
std::hash<Network::Address> hashFn;
|
||||
const auto hash = hashFn(address);
|
||||
|
||||
if (address.isValid() && std::ranges::find(RconAddresses, hash) == RconAddresses.end())
|
||||
{
|
||||
RconAddresses.push_back(hash);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool RCon::IsRateLimitCheckDisabled()
|
||||
@ -180,6 +200,13 @@ namespace Components
|
||||
|
||||
Network::OnClientPacket("rcon", [](const Network::Address& address, [[maybe_unused]] const std::string& data)
|
||||
{
|
||||
std::hash<Network::Address> hashFn;
|
||||
const auto hash = hashFn(address);
|
||||
if (!RconAddresses.empty() && std::ranges::find(RconAddresses, hash) != RconAddresses.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto time = Game::Sys_Milliseconds();
|
||||
if (!IsRateLimitCheckDisabled() && !RateLimitCheck(address, time))
|
||||
{
|
||||
|
@ -31,6 +31,8 @@ namespace Components
|
||||
|
||||
static std::unordered_map<std::uint32_t, int> RateLimit;
|
||||
|
||||
static std::vector<std::size_t> RconAddresses;
|
||||
|
||||
static Container RconContainer;
|
||||
static Utils::Cryptography::ECC::Key RconKey;
|
||||
|
||||
|
@ -557,6 +557,7 @@ namespace Components
|
||||
auto* ps = &ent->client->ps;
|
||||
if (!Game::BG_IsWeaponValid(ps, index))
|
||||
{
|
||||
Game::Scr_Error(Utils::String::VA("invalid InitialWeaponRaise: %s", weapon));
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user