aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-04-30 14:51:21 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-04-30 14:57:04 +0200
commitf026ab606d7bc317a725888296921df961d26208 (patch)
treeb65ed2dcf5b5c4cf26bf04fb0d73339f4b30268c /src/net.cpp
parentda38dc696c86aeb7394768ab34eb9a6e46bb614c (diff)
parent739d6155d3bbdeca38bb19daf70e6ff0af022455 (diff)
downloadbitcoin-f026ab606d7bc317a725888296921df961d26208.tar.xz
Merge pull request #6059
739d615 chainparams: use SeedSpec6's rather than CAddress's for fixed seeds (Cory Fields)
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 45a06a105f..731c810935 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -142,6 +142,27 @@ bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
return nBestScore >= 0;
}
+//! Convert the pnSeeds6 array into usable address objects.
+static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn)
+{
+ // It'll only connect to one or two seed nodes because once it connects,
+ // it'll get a pile of addresses with newer timestamps.
+ // Seed nodes are given a random 'last seen time' of between one and two
+ // weeks ago.
+ const int64_t nOneWeek = 7*24*60*60;
+ std::vector<CAddress> vSeedsOut;
+ vSeedsOut.reserve(vSeedsIn.size());
+ for (std::vector<SeedSpec6>::const_iterator i(vSeedsIn.begin()); i != vSeedsIn.end(); ++i)
+ {
+ struct in6_addr ip;
+ memcpy(&ip, i->addr, sizeof(ip));
+ CAddress addr(CService(ip, i->port));
+ addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
+ vSeedsOut.push_back(addr);
+ }
+ return vSeedsOut;
+}
+
// get best local address for a particular peer as a CAddress
// Otherwise, return the unroutable 0.0.0.0 but filled in with
// the normal parameters, since the IP may be changed to a useful
@@ -1195,7 +1216,7 @@ void ThreadOpenConnections()
static bool done = false;
if (!done) {
LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n");
- addrman.Add(Params().FixedSeeds(), CNetAddr("127.0.0.1"));
+ addrman.Add(convertSeed6(Params().FixedSeeds()), CNetAddr("127.0.0.1"));
done = true;
}
}