maint(utils): clean up RSA code

This commit is contained in:
Diavolo
2023-06-21 21:50:41 +02:00
parent e26eed4c11
commit da34ecbba7
5 changed files with 67 additions and 18 deletions

View File

@ -15,6 +15,8 @@ namespace Components
bool Node::WasIngame = false;
const Game::dvar_t* Node::net_natFix;
bool Node::Entry::isValid() const
{
return (this->lastResponse.has_value() && !this->lastResponse->elapsed(NODE_HALFLIFE * 2));
@ -349,9 +351,9 @@ namespace Components
}
}
unsigned short Node::GetPort()
std::uint16_t Node::GetPort()
{
if (Dvar::Var("net_natFix").get<bool>()) return 0;
if (net_natFix->current.enabled) return 0;
return Network::GetPort();
}
@ -395,7 +397,7 @@ namespace Components
Node::Node()
{
Dvar::Register<bool>("net_natFix", false, 0, "Fix node registration for certain firewalls/routers");
net_natFix = Game::Dvar_RegisterBool("net_natFix", false, 0, "Fix node registration for certain firewalls/routers");
Scheduler::Loop([]
{

View File

@ -12,7 +12,7 @@ namespace Components
class Data
{
public:
uint64_t protocol;
std::uint64_t protocol;
};
class Entry
@ -46,6 +46,8 @@ namespace Components
static std::vector<Entry> Nodes;
static bool WasIngame;
static const Game::dvar_t* net_natFix;
static void HandleResponse(const Network::Address& address, const std::string& data);
static void SendList(const Network::Address& address);
@ -54,7 +56,7 @@ namespace Components
static void LoadNodes();
static void StoreNodes(bool force);
static unsigned short GetPort();
static std::uint16_t GetPort();
static void Migrate();
};

View File

@ -127,10 +127,10 @@ namespace Components
{
Utils::InfoString info;
info.set("admin", Dvar::Var("_Admin").get<const char*>());
info.set("website", Dvar::Var("_Website").get<const char*>());
info.set("email", Dvar::Var("_Email").get<const char*>());
info.set("location", Dvar::Var("_Location").get<const char*>());
info.set("admin", Dvar::Var("_Admin").get<std::string>());
info.set("website", Dvar::Var("_Website").get<std::string>());
info.set("email", Dvar::Var("_Email").get<std::string>());
info.set("location", Dvar::Var("_Location").get<std::string>());
return info;
}