38 int *nThreads = (
int *)data;
40 std::vector<CServiceResult>
ips;
45 5000 + std::rand() % (500 * *nThreads)));
49 std::vector<CAddress> addr;
50 for (
size_t i = 0; i <
ips.size(); i++) {
57 bool getaddr =
res.ourLastSuccess + 86400 < now;
66 res.nClientV =
node.GetClientVersion();
67 res.strClientV =
node.GetClientSubVersion();
68 res.nHeight =
node.GetStartingHeight();
69 res.services =
node.GetServices();
70 res.checkpointVerified =
node.IsCheckpointVerified();
74 }
catch (std::ios_base::failure &
e) {
121 std::set<CNetAddr>
ips;
128 for (
auto &ip :
ips) {
131 if (ip.GetInAddr(&addr)) {
137 }
else if (ip.GetIn6Addr(&
addr6)) {
230 if (
a.uptime[4] ==
b.uptime[4]) {
231 if (
a.uptime[3] ==
b.uptime[3]) {
232 return a.clientVersion >
b.clientVersion;
234 return a.uptime[3] >
b.uptime[3];
237 return a.uptime[4] >
b.uptime[4];
243 const auto dumpInterval(*(
const std::chrono::seconds *)data);
250 std::vector<CAddrReport> v =
db.
GetAll();
258 rename(
"dnsseed.dat.new",
"dnsseed.dat");
260 std::ofstream d{
"dnsseed.dump"};
263 "lastSuccess %%(2h) %%(8h) %%(1d) %%(7d) "
264 "%%(30d) blocks svcs version\n");
265 double stat[5] = {0, 0, 0, 0, 0};
270 " %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6i %08" PRIx64
274 rep.lastSuccess, 100.0 *
rep.uptime[0],
275 100.0 *
rep.uptime[1], 100.0 *
rep.uptime[2],
276 100.0 *
rep.uptime[3], 100.0 *
rep.uptime[4],
rep.blocks,
277 rep.services,
rep.clientVersion,
rep.clientSubVersion);
284 std::ofstream
ff{
"dnsstats.log", std::ios_base::app};
301 strftime(
c, 256,
"[%y-%m-%d %H:%M:%S]", tmp);
313 for (
unsigned int i = 0; i <
dnsThread.size(); i++) {
319 "%s %i/%i available (%i tried in %is, %i new, %i active), %i "
320 "banned; %llu DNS requests, %llu db queries\n",
324 (
unsigned long long)queries);
335 std::vector<CNetAddr>
ips;
337 for (
auto &ip :
ips) {
361 tfm::format(std::cout,
"Supporting whitelisted filters: ");
367 tfm::format(std::cout,
"0x%lx", (
unsigned long)*it);
370 if (!opts.
tor.empty()) {
396 if (opts.
ns.empty()) {
397 tfm::format(std::cout,
"No nameserver set. Not starting DNS server.\n");
401 tfm::format(std::cerr,
"No hostname set. Please use -h.\n");
405 tfm::format(std::cerr,
"No e-mail address set. Please use -m.\n");
426 "Starting %i DNS threads for %s on %s (port %i)...",
444 for (
int i = 0; i < opts.
nThreads; i++) {
const CChainParams & Params()
Return the currently selected parameters.
std::string GetChainName() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
void Add(const CAddress &addr, bool fForce=false)
void GetMany(std::vector< CServiceResult > &ips, int max)
void ResultMany(const std::vector< CServiceResult > &ips)
void GetStats(CAddrDbStats &stats) const
std::vector< CAddrReport > GetAll()
void GetIPs(std::set< CNetAddr > &ips, uint64_t requestedFlags, uint32_t max, const bool *nets)
std::map< CService, int64_t > banned
A CService with information about it as peer.
std::atomic< uint64_t > dbQueries
std::set< uint64_t > filterWhitelist
std::map< uint64_t, FlagSpecificData > perflag
CDnsThread(seeder::CDnsSeedOpts *opts, int idIn)
void cacheHit(uint64_t requestedFlags, bool force=false)
A combination of a network address (CNetAddr) and a (TCP) port.
std::string ToStringIPPort() const
std::chrono::seconds dumpInterval
int ParseCommandLine(int argc, const char **argv)
std::set< uint64_t > filter_whitelist
static constexpr int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
int dnsserver(dns_opt_t *opt)
const std::vector< std::string > GetRandomizedDNSSeeds(const CChainParams ¶ms)
Return the list of hostnames to look up for DNS seeds.
BCLog::Logger & LogInstance()
FILE * fopen(const fs::path &p, const char *mode)
static const int CONTINUE_EXECUTION
@ NET_MAX
Dummy value to indicate the number of NET_* constants.
@ NET_ONION
TOR (v2 or v3)
CService LookupNumeric(const std::string &name, uint16_t portDefault, DNSLookupFn dns_lookup_function)
Resolve a service string with a numeric IP to its first corresponding service.
bool LookupHost(const std::string &name, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
Resolve a host string to its corresponding network addresses.
bool SetProxy(enum Network net, const proxyType &addrProxy)
ServiceFlags
nServices flags.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
static uint16_t GetDefaultPort()
int StatCompare(const CAddrReport &a, const CAddrReport &b)
void * ThreadDNS(void *arg)
const std::function< std::string(const char *)> G_TRANSLATION_FUN
Translate string to current locale using Qt.
void * ThreadDumper(void *data)
std::vector< CDnsThread * > dnsThread
void * ThreadStats(void *)
uint32_t GetIPList(void *thread, char *requestedHostname, addr_t *addr, uint32_t max, uint32_t ipv4, uint32_t ipv6)
static const unsigned int MAX_HOSTS_PER_SEED
void * ThreadSeeder(void *)
void * ThreadCrawler(void *data)
std::vector< addr_t > cache
uint32_t(* cb)(void *opt, char *requested_hostname, addr_t *addr, uint32_t max, uint32_t ipv4, uint32_t ipv6)
void UninterruptibleSleep(const std::chrono::microseconds &n)
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.