mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-08-25 18:20:37 +00:00
don't try same reseed twice
Build Debian packages / bookworm (push) Failing after 13s
Build Debian packages / bullseye (push) Failing after 13s
Build Debian packages / trixie (push) Failing after 11s
Build on FreeBSD / with UPnP (push) Failing after 18m34s
Build on Ubuntu / Make with USE_UPNP=no (push) Failing after 3h14m20s
Build on Ubuntu / Make with USE_UPNP=yes (push) Failing after 3h0m50s
Build containers / Building container for linux/arm64 (push) Failing after 31s
Build containers / Building container for linux/arm/v7 (push) Failing after 30s
Build containers / Building container for linux/386 (push) Failing after 26s
Build containers / Pushing merged manifest (push) Has been skipped
Build on OSX / Build on ARM64 (push) Has been cancelled
Build on OSX / Build on Intel x86_64 (push) Has been cancelled
Build on Windows / i686 (push) Has been cancelled
Build on Windows / ucrt-x86_64 (push) Has been cancelled
Build on Windows / x86_64 (push) Has been cancelled
Build on Windows / CMake clang-x86_64 (push) Has been cancelled
Build on Windows / CMake i686 (push) Has been cancelled
Build on Windows / CMake x86_64 (push) Has been cancelled
Build on Windows / clang-x86_64 (push) Has been cancelled
Build on Windows / XP (push) Has been cancelled
Build containers / Building container for linux/amd64 (push) Failing after 32s
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Failing after 3h14m19s
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Failing after 3h0m49s
Build on Windows / CMake ucrt-x86_64 (push) Has been cancelled
Build Debian packages / bookworm (push) Failing after 13s
Build Debian packages / bullseye (push) Failing after 13s
Build Debian packages / trixie (push) Failing after 11s
Build on FreeBSD / with UPnP (push) Failing after 18m34s
Build on Ubuntu / Make with USE_UPNP=no (push) Failing after 3h14m20s
Build on Ubuntu / Make with USE_UPNP=yes (push) Failing after 3h0m50s
Build containers / Building container for linux/arm64 (push) Failing after 31s
Build containers / Building container for linux/arm/v7 (push) Failing after 30s
Build containers / Building container for linux/386 (push) Failing after 26s
Build containers / Pushing merged manifest (push) Has been skipped
Build on OSX / Build on ARM64 (push) Has been cancelled
Build on OSX / Build on Intel x86_64 (push) Has been cancelled
Build on Windows / i686 (push) Has been cancelled
Build on Windows / ucrt-x86_64 (push) Has been cancelled
Build on Windows / x86_64 (push) Has been cancelled
Build on Windows / CMake clang-x86_64 (push) Has been cancelled
Build on Windows / CMake i686 (push) Has been cancelled
Build on Windows / CMake x86_64 (push) Has been cancelled
Build on Windows / clang-x86_64 (push) Has been cancelled
Build on Windows / XP (push) Has been cancelled
Build containers / Building container for linux/amd64 (push) Failing after 32s
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Failing after 3h14m19s
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Failing after 3h0m49s
Build on Windows / CMake ucrt-x86_64 (push) Has been cancelled
This commit is contained in:
+23
-11
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <random>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <boost/asio.hpp>
|
||||
@@ -113,19 +114,30 @@ namespace data
|
||||
return 0;
|
||||
}
|
||||
|
||||
int reseedRetries = 0;
|
||||
while (reseedRetries < 10)
|
||||
int numReseeds = httpsReseedHostList.size () + yggReseedHostList.size ();
|
||||
int reseedAttempts = std::min (numReseeds, MAX_NUM_RESEED_ATTEMPTS);
|
||||
if (reseedAttempts)
|
||||
{
|
||||
auto ind = rand () % (httpsReseedHostList.size () + yggReseedHostList.size ());
|
||||
bool isHttps = ind < httpsReseedHostList.size ();
|
||||
std::string reseedUrl = isHttps ? httpsReseedHostList[ind] :
|
||||
yggReseedHostList[ind - httpsReseedHostList.size ()];
|
||||
reseedUrl += "i2pseeds.su3";
|
||||
auto num = ReseedFromSU3Url (reseedUrl, isHttps);
|
||||
if (num > 0) return num; // success
|
||||
reseedRetries++;
|
||||
std::mt19937 rng(i2p::util::GetMonotonicMicroseconds () % 1000000LL);
|
||||
for (int i = 0; i < reseedAttempts; i++)
|
||||
{
|
||||
auto ind = rng () % numReseeds;
|
||||
bool isHttps = ind < httpsReseedHostList.size ();
|
||||
std::string reseedUrl = isHttps ? httpsReseedHostList[ind] :
|
||||
yggReseedHostList[ind - httpsReseedHostList.size ()];
|
||||
reseedUrl += "i2pseeds.su3";
|
||||
auto num = ReseedFromSU3Url (reseedUrl, isHttps);
|
||||
if (num > 0) return num; // success
|
||||
|
||||
if (isHttps)
|
||||
httpsReseedHostList.erase (httpsReseedHostList.begin() + ind);
|
||||
else
|
||||
yggReseedHostList.erase (yggReseedHostList.begin() + (ind - httpsReseedHostList.size ()));
|
||||
numReseeds--;
|
||||
if (!numReseeds) break;
|
||||
}
|
||||
}
|
||||
LogPrint (eLogWarning, "Reseed: Failed to reseed from servers after 10 attempts");
|
||||
LogPrint (eLogWarning, "Reseed: Failed to reseed from ", numReseeds, " servers after ", reseedAttempts, " attempts");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2020, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2025, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
@@ -20,6 +20,7 @@ namespace i2p
|
||||
{
|
||||
namespace data
|
||||
{
|
||||
constexpr int MAX_NUM_RESEED_ATTEMPTS = 10;
|
||||
|
||||
class Reseeder
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user