From d4e78a09a50e02fdc38b21e1c1a4c79fd6ad8fb0 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 15 Nov 2016 16:40:15 +0100 Subject: [PATCH] [Node] Fallback client implementation --- src/Components/Modules/News.cpp | 2 ++ src/Components/Modules/Node.cpp | 14 ++++++++++++++ src/Components/Modules/Node.hpp | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index d8a81c27..7a1079c7 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -173,6 +173,8 @@ namespace Components if (!Loader::PerformingUnitTests()) { + Node::LoadNodeRemotePreset(); + while (!News::Terminate) { News::CheckForUpdate(); diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index 3fee9757..4c80ca8e 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -8,6 +8,20 @@ namespace Components std::vector Node::Nodes; std::vector Node::Sessions; + void Node::LoadNodeRemotePreset() + { + std::string nodes = Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/nodex.txt").SetTimeout(5000)->Get(); + if (nodes.empty()) return; + + auto nodeList = Utils::String::Explode(nodes, '\n'); + for (auto node : nodeList) + { + Utils::String::Replace(node, "\r", ""); + node = Utils::String::Trim(node); + Node::AddNode(node); + } + } + void Node::LoadNodePreset() { Proto::Node::List list; diff --git a/src/Components/Modules/Node.hpp b/src/Components/Modules/Node.hpp index 105e2e36..567b746f 100644 --- a/src/Components/Modules/Node.hpp +++ b/src/Components/Modules/Node.hpp @@ -28,6 +28,8 @@ namespace Components static unsigned int GetValidNodeCount(); + static void LoadNodeRemotePreset(); + private: enum EntryState {