Important fixes for zonebuilder & filter servers on protocol
This commit is contained in:
parent
197fe51a64
commit
0d222e30cf
@ -342,12 +342,12 @@ namespace Components
|
|||||||
for (const auto& nodeListData : nodeListReponseMessages)
|
for (const auto& nodeListData : nodeListReponseMessages)
|
||||||
{
|
{
|
||||||
Scheduler::Once([=]
|
Scheduler::Once([=]
|
||||||
{
|
{
|
||||||
#ifdef NODE_SYSTEM_DEBUG
|
#ifdef NODE_SYSTEM_DEBUG
|
||||||
Logger::Debug("Sending {} nodeListResponse length to {}\n", nodeListData.length(), address.getCString());
|
Logger::Debug("Sending {} nodeListResponse length to {}\n", nodeListData.length(), address.getCString());
|
||||||
#endif
|
#endif
|
||||||
Session::Send(address, "nodeListResponse", nodeListData);
|
Session::Send(address, "nodeListResponse", nodeListData);
|
||||||
}, Scheduler::Pipeline::MAIN, NODE_SEND_RATE * i++);
|
}, Scheduler::Pipeline::MAIN, NODE_SEND_RATE * i++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,48 +397,54 @@ namespace Components
|
|||||||
|
|
||||||
Node::Node()
|
Node::Node()
|
||||||
{
|
{
|
||||||
|
if (ZoneBuilder::IsEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
net_natFix = Game::Dvar_RegisterBool("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([]
|
Scheduler::Loop([]
|
||||||
{
|
{
|
||||||
StoreNodes(false);
|
StoreNodes(false);
|
||||||
}, Scheduler::Pipeline::ASYNC, 5min);
|
}, Scheduler::Pipeline::ASYNC, 5min);
|
||||||
|
|
||||||
Scheduler::Loop(RunFrame, Scheduler::Pipeline::MAIN);
|
Scheduler::Loop(RunFrame, Scheduler::Pipeline::MAIN);
|
||||||
|
|
||||||
Session::Handle("nodeListResponse", HandleResponse);
|
|
||||||
Session::Handle("nodeListRequest", [](const Network::Address& address, [[maybe_unused]] const std::string& data)
|
|
||||||
{
|
|
||||||
SendList(address);
|
|
||||||
});
|
|
||||||
|
|
||||||
Scheduler::OnGameInitialized([]
|
Scheduler::OnGameInitialized([]
|
||||||
{
|
{
|
||||||
Migrate();
|
|
||||||
LoadNodePreset();
|
Session::Handle("nodeListResponse", HandleResponse);
|
||||||
LoadNodes();
|
Session::Handle("nodeListRequest", [](const Network::Address& address, [[maybe_unused]] const std::string& data)
|
||||||
}, Scheduler::Pipeline::MAIN);
|
{
|
||||||
|
SendList(address);
|
||||||
|
});
|
||||||
|
|
||||||
|
Migrate();
|
||||||
|
LoadNodePreset();
|
||||||
|
LoadNodes();
|
||||||
|
}, Scheduler::Pipeline::MAIN);
|
||||||
|
|
||||||
Command::Add("listNodes", [](const Command::Params*)
|
Command::Add("listNodes", [](const Command::Params*)
|
||||||
{
|
|
||||||
Logger::Print("Nodes: {}\n", Nodes.size());
|
|
||||||
|
|
||||||
std::lock_guard _(Mutex);
|
|
||||||
for (const auto& node : Nodes)
|
|
||||||
{
|
{
|
||||||
Logger::Print("{}\t({})\n", node.address.getString(), node.isValid() ? "Valid" : "Invalid");
|
Logger::Print("Nodes: {}\n", Nodes.size());
|
||||||
}
|
|
||||||
});
|
std::lock_guard _(Mutex);
|
||||||
|
for (const auto& node : Nodes)
|
||||||
|
{
|
||||||
|
Logger::Print("{}\t({})\n", node.address.getString(), node.isValid() ? "Valid" : "Invalid");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Command::Add("addNode", [](const Command::Params* params)
|
Command::Add("addNode", [](const Command::Params* params)
|
||||||
{
|
|
||||||
if (params->size() < 2) return;
|
|
||||||
auto address = Network::Address{ params->get(1) };
|
|
||||||
if (address.isValid())
|
|
||||||
{
|
{
|
||||||
Add(address);
|
if (params->size() < 2) return;
|
||||||
}
|
auto address = Network::Address{ params->get(1) };
|
||||||
});
|
if (address.isValid())
|
||||||
|
{
|
||||||
|
Add(address);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::preDestroy()
|
void Node::preDestroy()
|
||||||
|
@ -322,6 +322,19 @@ namespace Components
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!entry.HasMember("ip") || !entry["protocol"].IsInt())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto protocol = entry["protocol"].GetInt();
|
||||||
|
|
||||||
|
if (protocol != PROTOCOL)
|
||||||
|
{
|
||||||
|
// We can't connect to it anyway
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Using VA because it's faster
|
// Using VA because it's faster
|
||||||
Network::Address server(Utils::String::VA("%s:%u", entry["ip"].GetString(), entry["port"].GetInt()));
|
Network::Address server(Utils::String::VA("%s:%u", entry["ip"].GetString(), entry["port"].GetInt()));
|
||||||
server.setType(Game::NA_IP); // Just making sure...
|
server.setType(Game::NA_IP); // Just making sure...
|
||||||
@ -371,7 +384,7 @@ namespace Components
|
|||||||
|
|
||||||
Toast::Show("cardicon_headshot", "Server Browser", "Fetching servers...", 3000);
|
Toast::Show("cardicon_headshot", "Server Browser", "Fetching servers...", 3000);
|
||||||
|
|
||||||
const auto* url = "http://iw4x.plutools.pw/v1/servers/iw4x";
|
const auto url = std::format("http://iw4x.plutools.pw/v1/servers/iw4x?protocol={}", PROTOCOL);
|
||||||
const auto reply = Utils::WebIO("IW4x", url).setTimeout(5000)->get();
|
const auto reply = Utils::WebIO("IW4x", url).setTimeout(5000)->get();
|
||||||
if (reply.empty())
|
if (reply.empty())
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,7 @@ namespace Components
|
|||||||
int ping;
|
int ping;
|
||||||
int matchType;
|
int matchType;
|
||||||
int securityLevel;
|
int securityLevel;
|
||||||
|
int protocol;
|
||||||
bool hardcore;
|
bool hardcore;
|
||||||
bool svRunning;
|
bool svRunning;
|
||||||
bool aimassist;
|
bool aimassist;
|
||||||
|
Loading…
Reference in New Issue
Block a user