diff options
Diffstat (limited to 'protocols/Tox/src/tox_network.cpp')
-rw-r--r-- | protocols/Tox/src/tox_network.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp index 66cc86ad37..63db87cb5c 100644 --- a/protocols/Tox/src/tox_network.cpp +++ b/protocols/Tox/src/tox_network.cpp @@ -140,13 +140,23 @@ void CToxProto::UpdateNodes() {
HttpRequest request(REQUEST_GET, "https://nodes.tox.chat/json");
NLHR_PTR response(request.Send(m_hNetlibUser));
-
if (response->resultCode != HTTP_CODE_OK || !response->pData)
{
debugLogA(__FUNCTION__": failed to dowload tox.json");
return;
}
+ JSONNode root = JSONNode::parse(response->pData);
+ if (root.empty())
+ {
+ debugLogA(__FUNCTION__": failed to dowload tox.json");
+ return;
+ }
+
+ long lastUpdate = root.at("last_scan").as_int();
+ if (lastUpdate <= getDword("NodesUpdate", 0))
+ return;
+
ptrT path(mir_tstrdup((TCHAR*)VARST(_T(TOX_JSON_PATH))));
if (!IsFileExists(path))
{
@@ -170,6 +180,8 @@ void CToxProto::UpdateNodes() debugLogA(__FUNCTION__": failed to write tox.json");
fclose(hFile);
+
+ setDword("NodesUpdate", lastUpdate);
}
void CToxProto::TryConnect()
|