Bitcoin ABC  0.22.13
P2P Digital Currency
main.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017-2020 The Bitcoin developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <chainparams.h>
6 #include <clientversion.h>
7 #include <fs.h>
8 #include <logging.h>
9 #include <protocol.h>
10 #include <seeder/bitcoin.h>
11 #include <seeder/db.h>
12 #include <seeder/dns.h>
13 #include <streams.h>
14 #include <util/strencodings.h>
15 #include <util/system.h>
16 #include <util/time.h>
17 #include <util/translation.h>
18 
19 #include <algorithm>
20 #include <atomic>
21 #include <cinttypes>
22 #include <csignal>
23 #include <cstdlib>
24 #include <functional>
25 #include <pthread.h>
26 
27 const std::function<std::string(const char *)> G_TRANSLATION_FUN = nullptr;
28 
29 static const int CONTINUE_EXECUTION = -1;
30 
31 static const int DEFAULT_NUM_THREADS = 96;
32 static const int DEFAULT_PORT = 53;
33 static const int DEFAULT_NUM_DNS_THREADS = 4;
34 static const bool DEFAULT_WIPE_BAN = false;
35 static const bool DEFAULT_WIPE_IGNORE = false;
36 static const std::string DEFAULT_EMAIL = "";
37 static const std::string DEFAULT_NAMESERVER = "";
38 static const std::string DEFAULT_HOST = "";
39 static const std::string DEFAULT_TOR_PROXY = "";
40 static const std::string DEFAULT_IPV4_PROXY = "";
41 static const std::string DEFAULT_IPV6_PROXY = "";
42 
43 class CDnsSeedOpts {
44 public:
45  int nThreads;
46  int nPort;
48  bool fWipeBan;
50  std::string mbox;
51  std::string ns;
52  std::string host;
53  std::string tor;
54  std::string ipv4_proxy;
55  std::string ipv6_proxy;
56  std::set<uint64_t> filter_whitelist;
57 
59  : nThreads(DEFAULT_NUM_THREADS), nPort(DEFAULT_PORT),
60  nDnsThreads(DEFAULT_NUM_DNS_THREADS), fWipeBan(DEFAULT_WIPE_BAN),
61  fWipeIgnore(DEFAULT_WIPE_IGNORE), mbox(DEFAULT_EMAIL),
63  ipv4_proxy(DEFAULT_IPV4_PROXY), ipv6_proxy(DEFAULT_IPV6_PROXY) {}
64 
65  int ParseCommandLine(int argc, char **argv) {
67  std::string error;
68  if (!gArgs.ParseParameters(argc, argv, error)) {
69  tfm::format(std::cerr, "Error parsing command line arguments: %s\n",
70  error);
71  return EXIT_FAILURE;
72  }
73  if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
74  std::string strUsage =
75  PACKAGE_NAME " Seeder " + FormatFullVersion() + "\n";
76  if (HelpRequested(gArgs)) {
77  strUsage +=
78  "\nUsage: bitcoin-seeder -host=<host> -ns=<ns> "
79  "[-mbox=<mbox>] [-threads=<threads>] [-port=<port>]\n\n" +
81  }
82 
83  tfm::format(std::cout, "%s", strUsage);
84  return EXIT_SUCCESS;
85  }
86 
87  nThreads = gArgs.GetArg("-threads", DEFAULT_NUM_THREADS);
88  nPort = gArgs.GetArg("-port", DEFAULT_PORT);
89  nDnsThreads = gArgs.GetArg("-dnsthreads", DEFAULT_NUM_DNS_THREADS);
90  fWipeBan = gArgs.GetBoolArg("-wipeban", DEFAULT_WIPE_BAN);
91  fWipeIgnore = gArgs.GetBoolArg("-wipeignore", DEFAULT_WIPE_IGNORE);
92  mbox = gArgs.GetArg("-mbox", DEFAULT_EMAIL);
93  ns = gArgs.GetArg("-ns", DEFAULT_NAMESERVER);
94  host = gArgs.GetArg("-host", DEFAULT_HOST);
95  tor = gArgs.GetArg("-onion", DEFAULT_TOR_PROXY);
96  ipv4_proxy = gArgs.GetArg("-proxyipv4", DEFAULT_IPV4_PROXY);
97  ipv6_proxy = gArgs.GetArg("-proxyipv6", DEFAULT_IPV6_PROXY);
99 
100  if (gArgs.IsArgSet("-filter")) {
101  // Parse whitelist additions
102  std::string flagString = gArgs.GetArg("-filter", "");
103  size_t flagstartpos = 0;
104  while (flagstartpos < flagString.size()) {
105  size_t flagendpos = flagString.find_first_of(',', flagstartpos);
106  uint64_t flag = atoi64(flagString.substr(
107  flagstartpos, (flagendpos - flagstartpos)));
108  filter_whitelist.insert(flag);
109  if (flagendpos == std::string::npos) {
110  break;
111  }
112  flagstartpos = flagendpos + 1;
113  }
114  }
115  if (filter_whitelist.empty()) {
116  filter_whitelist.insert(NODE_NETWORK);
117  filter_whitelist.insert(NODE_NETWORK | NODE_BLOOM);
118  }
119  return CONTINUE_EXECUTION;
120  }
121 
122 private:
123  void SetupSeederArgs(ArgsManager &argsman) {
124  SetupHelpOptions(argsman);
125  argsman.AddArg("-help-debug",
126  "Show all debugging options (usage: --help -help-debug)",
128 
130 
131  argsman.AddArg("-version", "Print version and exit",
133  argsman.AddArg("-host=<host>", "Hostname of the DNS seed",
135  argsman.AddArg("-ns=<ns>", "Hostname of the nameserver",
137  argsman.AddArg("-mbox=<mbox>", "E-Mail address reported in SOA records",
139  argsman.AddArg("-threads=<threads>",
140  "Number of crawlers to run in parallel (default 96)",
142  argsman.AddArg("-dnsthreads=<threads>",
143  "Number of DNS server threads (default 4)",
145  argsman.AddArg("-port=<port>", "UDP port to listen on (default 53)",
147  argsman.AddArg("-onion=<ip:port>", "Tor proxy IP/Port",
149  argsman.AddArg("-proxyipv4=<ip:port>", "IPV4 SOCKS5 proxy IP/Port",
151  argsman.AddArg("-proxyipv6=<ip:port>", "IPV6 SOCKS5 proxy IP/Port",
153  argsman.AddArg("-filter=<f1,f2,...>",
154  "Allow these flag combinations as filters",
156  argsman.AddArg("-wipeban", "Wipe list of banned nodes",
158  argsman.AddArg("-wipeignore", "Wipe list of ignored nodes",
160  }
161 };
162 
163 extern "C" {
164 #include <seeder/dns.h>
165 }
166 
168 
169 extern "C" void *ThreadCrawler(void *data) {
170  int *nThreads = (int *)data;
171  do {
172  std::vector<CServiceResult> ips;
173  int wait = 5;
174  db.GetMany(ips, 16, wait);
175  int64_t now = GetTime();
176  if (ips.empty()) {
177  wait *= 1000;
178  wait += rand() % (500 * *nThreads);
179  Sleep(wait);
180  continue;
181  }
182 
183  std::vector<CAddress> addr;
184  for (size_t i = 0; i < ips.size(); i++) {
185  CServiceResult &res = ips[i];
186  res.nBanTime = 0;
187  res.nClientV = 0;
188  res.nHeight = 0;
189  res.strClientV = "";
190  bool getaddr = res.ourLastSuccess + 86400 < now;
191  try {
192  CSeederNode node(res.service, getaddr ? &addr : nullptr);
193  bool ret = node.Run();
194  if (!ret) {
195  res.nBanTime = node.GetBan();
196  } else {
197  res.nBanTime = 0;
198  }
199  res.nClientV = node.GetClientVersion();
200  res.strClientV = node.GetClientSubVersion();
201  res.nHeight = node.GetStartingHeight();
202  // tfm::format(std::cout, "%s: %s!!!\n", cip.ToString(),
203  // ret ? "GOOD" : "BAD");
204  res.fGood = ret;
205  } catch (std::ios_base::failure &e) {
206  res.nBanTime = 0;
207  res.fGood = false;
208  }
209  }
210 
211  db.ResultMany(ips);
212  db.Add(addr);
213  } while (1);
214  return nullptr;
215 }
216 
217 extern "C" uint32_t GetIPList(void *thread, char *requestedHostname,
218  addr_t *addr, uint32_t max, uint32_t ipv4,
219  uint32_t ipv6);
220 
221 class CDnsThread {
222 public:
224  int nIPv4, nIPv6;
225  std::vector<addr_t> cache;
226  time_t cacheTime;
227  unsigned int cacheHits;
228  FlagSpecificData() : nIPv4(0), nIPv6(0), cacheTime(0), cacheHits(0) {}
229  };
230 
231  dns_opt_t dns_opt; // must be first
232  const int id;
233  std::map<uint64_t, FlagSpecificData> perflag;
234  std::atomic<uint64_t> dbQueries;
235  std::set<uint64_t> filterWhitelist;
236 
237  void cacheHit(uint64_t requestedFlags, bool force = false) {
238  static bool nets[NET_MAX] = {};
239  if (!nets[NET_IPV4]) {
240  nets[NET_IPV4] = true;
241  nets[NET_IPV6] = true;
242  }
243  int64_t now = GetTime();
244  FlagSpecificData &thisflag = perflag[requestedFlags];
245  thisflag.cacheHits++;
246  if (force ||
247  thisflag.cacheHits * 400 >
248  (thisflag.cache.size() * thisflag.cache.size()) ||
249  (thisflag.cacheHits * thisflag.cacheHits * 20 >
250  thisflag.cache.size() &&
251  (now - thisflag.cacheTime > 5))) {
252  std::set<CNetAddr> ips;
253  db.GetIPs(ips, requestedFlags, 1000, nets);
254  dbQueries++;
255  thisflag.cache.clear();
256  thisflag.nIPv4 = 0;
257  thisflag.nIPv6 = 0;
258  thisflag.cache.reserve(ips.size());
259  for (auto &ip : ips) {
260  struct in_addr addr;
261  struct in6_addr addr6;
262  if (ip.GetInAddr(&addr)) {
263  addr_t a;
264  a.v = 4;
265  memcpy(&a.data.v4, &addr, 4);
266  thisflag.cache.push_back(a);
267  thisflag.nIPv4++;
268  } else if (ip.GetIn6Addr(&addr6)) {
269  addr_t a;
270  a.v = 6;
271  memcpy(&a.data.v6, &addr6, 16);
272  thisflag.cache.push_back(a);
273  thisflag.nIPv6++;
274  }
275  }
276  thisflag.cacheHits = 0;
277  thisflag.cacheTime = now;
278  }
279  }
280 
281  CDnsThread(CDnsSeedOpts *opts, int idIn) : id(idIn) {
282  dns_opt.host = opts->host.c_str();
283  dns_opt.ns = opts->ns.c_str();
284  dns_opt.mbox = opts->mbox.c_str();
285  dns_opt.datattl = 3600;
286  dns_opt.nsttl = 40000;
287  dns_opt.cb = GetIPList;
288  dns_opt.port = opts->nPort;
289  dns_opt.nRequests = 0;
290  dbQueries = 0;
291  perflag.clear();
292  filterWhitelist = opts->filter_whitelist;
293  }
294 
295  void run() { dnsserver(&dns_opt); }
296 };
297 
298 extern "C" uint32_t GetIPList(void *data, char *requestedHostname, addr_t *addr,
299  uint32_t max, uint32_t ipv4, uint32_t ipv6) {
300  CDnsThread *thread = (CDnsThread *)data;
301 
302  uint64_t requestedFlags = 0;
303  int hostlen = strlen(requestedHostname);
304  if (hostlen > 1 && requestedHostname[0] == 'x' &&
305  requestedHostname[1] != '0') {
306  char *pEnd;
307  uint64_t flags = (uint64_t)strtoull(requestedHostname + 1, &pEnd, 16);
308  if (*pEnd == '.' && pEnd <= requestedHostname + 17 &&
309  std::find(thread->filterWhitelist.begin(),
310  thread->filterWhitelist.end(),
311  flags) != thread->filterWhitelist.end()) {
312  requestedFlags = flags;
313  } else {
314  return 0;
315  }
316  } else if (strcasecmp(requestedHostname, thread->dns_opt.host)) {
317  return 0;
318  }
319  thread->cacheHit(requestedFlags);
320  auto &thisflag = thread->perflag[requestedFlags];
321  uint32_t size = thisflag.cache.size();
322  uint32_t maxmax = (ipv4 ? thisflag.nIPv4 : 0) + (ipv6 ? thisflag.nIPv6 : 0);
323  if (max > size) {
324  max = size;
325  }
326  if (max > maxmax) {
327  max = maxmax;
328  }
329  uint32_t i = 0;
330  while (i < max) {
331  uint32_t j = i + (rand() % (size - i));
332  do {
333  bool ok = (ipv4 && thisflag.cache[j].v == 4) ||
334  (ipv6 && thisflag.cache[j].v == 6);
335  if (ok) {
336  break;
337  }
338  j++;
339  if (j == size) {
340  j = i;
341  }
342  } while (1);
343  addr[i] = thisflag.cache[j];
344  thisflag.cache[j] = thisflag.cache[i];
345  thisflag.cache[i] = addr[i];
346  i++;
347  }
348  return max;
349 }
350 
351 std::vector<CDnsThread *> dnsThread;
352 
353 extern "C" void *ThreadDNS(void *arg) {
354  CDnsThread *thread = (CDnsThread *)arg;
355  thread->run();
356  return nullptr;
357 }
358 
359 int StatCompare(const CAddrReport &a, const CAddrReport &b) {
360  if (a.uptime[4] == b.uptime[4]) {
361  if (a.uptime[3] == b.uptime[3]) {
362  return a.clientVersion > b.clientVersion;
363  } else {
364  return a.uptime[3] > b.uptime[3];
365  }
366  } else {
367  return a.uptime[4] > b.uptime[4];
368  }
369 }
370 
371 extern "C" void *ThreadDumper(void *) {
372  int count = 0;
373  do {
374  // First 100s, than 200s, 400s, 800s, 1600s, and then 3200s forever
375  Sleep(100000 << count);
376  if (count < 5) {
377  count++;
378  }
379 
380  {
381  std::vector<CAddrReport> v = db.GetAll();
382  sort(v.begin(), v.end(), StatCompare);
383  FILE *f = fsbridge::fopen("dnsseed.dat.new", "w+");
384  if (f) {
385  {
387  cf << db;
388  }
389  rename("dnsseed.dat.new", "dnsseed.dat");
390  }
391  fsbridge::ofstream d{"dnsseed.dump"};
392  tfm::format(
393  d, "# address good "
394  "lastSuccess %%(2h) %%(8h) %%(1d) %%(7d) "
395  "%%(30d) blocks svcs version\n");
396  double stat[5] = {0, 0, 0, 0, 0};
397  for (CAddrReport rep : v) {
398  tfm::format(
399  d,
400  "%-47s %4d %11" PRId64
401  " %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6i %08" PRIx64
402  " %5i \"%s\"\n",
403  rep.ip.ToString(), (int)rep.fGood, rep.lastSuccess,
404  100.0 * rep.uptime[0], 100.0 * rep.uptime[1],
405  100.0 * rep.uptime[2], 100.0 * rep.uptime[3],
406  100.0 * rep.uptime[4], rep.blocks, rep.services,
407  rep.clientVersion, rep.clientSubVersion);
408  stat[0] += rep.uptime[0];
409  stat[1] += rep.uptime[1];
410  stat[2] += rep.uptime[2];
411  stat[3] += rep.uptime[3];
412  stat[4] += rep.uptime[4];
413  }
414  fsbridge::ofstream ff{"dnsstats.log", std::ios_base::app};
415  tfm::format(ff, "%llu %g %g %g %g %g\n", GetTime(), stat[0],
416  stat[1], stat[2], stat[3], stat[4]);
417  }
418  } while (1);
419  return nullptr;
420 }
421 
422 extern "C" void *ThreadStats(void *) {
423  bool first = true;
424  do {
425  char c[256];
426  time_t tim = time(nullptr);
427  struct tm *tmp = localtime(&tim);
428  strftime(c, 256, "[%y-%m-%d %H:%M:%S]", tmp);
429  CAddrDbStats stats;
430  db.GetStats(stats);
431  if (first) {
432  first = false;
433  tfm::format(std::cout, "\n\n\n\x1b[3A");
434  } else {
435  tfm::format(std::cout, "\x1b[2K\x1b[u");
436  }
437  tfm::format(std::cout, "\x1b[s");
438  uint64_t requests = 0;
439  uint64_t queries = 0;
440  for (unsigned int i = 0; i < dnsThread.size(); i++) {
441  requests += dnsThread[i]->dns_opt.nRequests;
442  queries += dnsThread[i]->dbQueries;
443  }
444  tfm::format(
445  std::cout,
446  "%s %i/%i available (%i tried in %is, %i new, %i active), %i "
447  "banned; %llu DNS requests, %llu db queries\n",
448  c, stats.nGood, stats.nAvail, stats.nTracked, stats.nAge,
449  stats.nNew, stats.nAvail - stats.nTracked - stats.nNew,
450  stats.nBanned, (unsigned long long)requests,
451  (unsigned long long)queries);
452  Sleep(1000);
453  } while (1);
454  return nullptr;
455 }
456 
457 const static unsigned int MAX_HOSTS_PER_SEED = 128;
458 
459 extern "C" void *ThreadSeeder(void *) {
460  do {
461  for (const std::string &seed : Params().DNSSeeds()) {
462  std::vector<CNetAddr> ips;
463  LookupHost(seed.c_str(), ips, MAX_HOSTS_PER_SEED, true);
464  for (auto &ip : ips) {
466  true);
467  }
468  }
469  Sleep(1800000);
470  } while (1);
471  return nullptr;
472 }
473 
474 int main(int argc, char **argv) {
475  // The logger dump everything on the console by default.
477 
478  signal(SIGPIPE, SIG_IGN);
479  setbuf(stdout, nullptr);
480  CDnsSeedOpts opts;
481  int parseResults = opts.ParseCommandLine(argc, argv);
482  if (parseResults != CONTINUE_EXECUTION) {
483  return parseResults;
484  }
485 
486  tfm::format(std::cout, "Supporting whitelisted filters: ");
487  for (std::set<uint64_t>::const_iterator it = opts.filter_whitelist.begin();
488  it != opts.filter_whitelist.end(); it++) {
489  if (it != opts.filter_whitelist.begin()) {
490  tfm::format(std::cout, ",");
491  }
492  tfm::format(std::cout, "0x%lx", (unsigned long)*it);
493  }
494  tfm::format(std::cout, "\n");
495  if (!opts.tor.empty()) {
496  CService service(LookupNumeric(opts.tor.c_str(), 9050));
497  if (service.IsValid()) {
498  tfm::format(std::cout, "Using Tor proxy at %s\n",
499  service.ToStringIPPort());
500  SetProxy(NET_ONION, proxyType(service));
501  }
502  }
503  if (!opts.ipv4_proxy.empty()) {
504  CService service(LookupNumeric(opts.ipv4_proxy.c_str(), 9050));
505  if (service.IsValid()) {
506  tfm::format(std::cout, "Using IPv4 proxy at %s\n",
507  service.ToStringIPPort());
508  SetProxy(NET_IPV4, proxyType(service));
509  }
510  }
511  if (!opts.ipv6_proxy.empty()) {
512  CService service(LookupNumeric(opts.ipv6_proxy.c_str(), 9050));
513  if (service.IsValid()) {
514  tfm::format(std::cout, "Using IPv6 proxy at %s\n",
515  service.ToStringIPPort());
516  SetProxy(NET_IPV6, proxyType(service));
517  }
518  }
519  bool fDNS = true;
520  tfm::format(std::cout, "Using %s.\n", gArgs.GetChainName());
521  if (opts.ns.empty()) {
522  tfm::format(std::cout, "No nameserver set. Not starting DNS server.\n");
523  fDNS = false;
524  }
525  if (fDNS && opts.host.empty()) {
526  tfm::format(std::cerr, "No hostname set. Please use -h.\n");
527  return EXIT_FAILURE;
528  }
529  if (fDNS && opts.mbox.empty()) {
530  tfm::format(std::cerr, "No e-mail address set. Please use -m.\n");
531  return EXIT_FAILURE;
532  }
533  FILE *f = fsbridge::fopen("dnsseed.dat", "r");
534  if (f) {
535  tfm::format(std::cout, "Loading dnsseed.dat...");
537  cf >> db;
538  if (opts.fWipeBan) {
539  db.banned.clear();
540  tfm::format(std::cout, "Ban list wiped...");
541  }
542  if (opts.fWipeIgnore) {
543  db.ResetIgnores();
544  tfm::format(std::cout, "Ignore list wiped...");
545  }
546  tfm::format(std::cout, "done\n");
547  }
548  pthread_t threadDns, threadSeed, threadDump, threadStats;
549  if (fDNS) {
550  tfm::format(std::cout,
551  "Starting %i DNS threads for %s on %s (port %i)...",
552  opts.nDnsThreads, opts.host, opts.ns, opts.nPort);
553  dnsThread.clear();
554  for (int i = 0; i < opts.nDnsThreads; i++) {
555  dnsThread.push_back(new CDnsThread(&opts, i));
556  pthread_create(&threadDns, nullptr, ThreadDNS, dnsThread[i]);
557  tfm::format(std::cout, ".");
558  Sleep(20);
559  }
560  tfm::format(std::cout, "done\n");
561  }
562  tfm::format(std::cout, "Starting seeder...");
563  pthread_create(&threadSeed, nullptr, ThreadSeeder, nullptr);
564  tfm::format(std::cout, "done\n");
565  tfm::format(std::cout, "Starting %i crawler threads...", opts.nThreads);
566  pthread_attr_t attr_crawler;
567  pthread_attr_init(&attr_crawler);
568  pthread_attr_setstacksize(&attr_crawler, 0x20000);
569  for (int i = 0; i < opts.nThreads; i++) {
570  pthread_t thread;
571  pthread_create(&thread, &attr_crawler, ThreadCrawler, &opts.nThreads);
572  }
573  pthread_attr_destroy(&attr_crawler);
574  tfm::format(std::cout, "done\n");
575  pthread_create(&threadStats, nullptr, ThreadStats, nullptr);
576  pthread_create(&threadDump, nullptr, ThreadDumper, nullptr);
577  void *res;
578  pthread_join(threadDump, &res);
579  return EXIT_SUCCESS;
580 }
static const int DEFAULT_PORT
Definition: main.cpp:32
bool fGood
Definition: db.h:263
int nHeight
Definition: db.h:265
static unsigned short GetDefaultPort()
Definition: bitcoin.h:15
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
Definition: system.cpp:390
void cacheHit(uint64_t requestedFlags, bool force=false)
Definition: main.cpp:237
void SetupChainParamsBaseOptions(ArgsManager &argsman)
Set the arguments for chainparams.
std::set< uint64_t > filterWhitelist
Definition: main.cpp:235
CService LookupNumeric(const std::string &name, int portDefault)
Resolve a service string with a numeric IP to its first corresponding service.
Definition: netbase.cpp:270
static const unsigned int MAX_HOSTS_PER_SEED
Definition: main.cpp:457
BCLog::Logger & LogInstance()
Definition: logging.cpp:15
ServiceFlags
nServices flags.
Definition: protocol.h:320
uint64_t nRequests
Definition: dns.h:34
int nTracked
Definition: db.h:255
FILE * fopen(const fs::path &p, const char *mode)
Definition: fs.cpp:22
std::map< CService, int64_t > banned
Definition: db.h:317
void * ThreadDumper(void *)
Definition: main.cpp:371
std::vector< CDnsThread * > dnsThread
Definition: main.cpp:351
Definition: dns.h:24
int ParseCommandLine(int argc, char **argv)
Definition: main.cpp:65
int nAvail
Definition: db.h:254
void SetupSeederArgs(ArgsManager &argsman)
Definition: main.cpp:123
bool fWipeIgnore
Definition: main.cpp:49
static const bool DEFAULT_WIPE_BAN
Definition: main.cpp:34
std::string ipv4_proxy
Definition: main.cpp:54
static const std::string DEFAULT_NAMESERVER
Definition: main.cpp:37
double uptime[5]
Definition: db.h:73
bool m_print_to_console
Definition: logging.h:92
NODISCARD bool ParseParameters(int argc, const char *const argv[], std::string &error)
Definition: system.cpp:318
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:498
std::string tor
Definition: main.cpp:53
int nBanned
Definition: db.h:253
const std::function< std::string(const char *)> G_TRANSLATION_FUN
Translate string to current locale using Qt.
Definition: bitcoin-cli.cpp:31
std::string strClientV
Definition: db.h:267
fs::ofstream ofstream
Definition: fs.h:99
int datattl
Definition: dns.h:26
CDnsSeedOpts()
Definition: main.cpp:58
void * ThreadStats(void *)
Definition: main.cpp:422
void * ThreadDNS(void *arg)
Definition: main.cpp:353
CDnsThread(CDnsSeedOpts *opts, int idIn)
Definition: main.cpp:281
static const int DEFAULT_NUM_DNS_THREADS
Definition: main.cpp:33
CService service
Definition: db.h:262
std::string GetHelpMessage() const
Get the help string.
Definition: system.cpp:579
static const std::string DEFAULT_IPV6_PROXY
Definition: main.cpp:41
std::string ipv6_proxy
Definition: main.cpp:55
bool IsValid() const
Definition: netaddress.cpp:244
int v
Definition: dns.h:17
int nDnsThreads
Definition: main.cpp:47
void ResultMany(const std::vector< CServiceResult > &ips)
Definition: db.h:440
void GetIPs(std::set< CNetAddr > &ips, uint64_t requestedFlags, uint32_t max, const bool *nets)
Definition: db.h:452
union addr_t::@20 data
int nClientV
Definition: db.h:266
int nGood
Definition: db.h:257
static const int DEFAULT_NUM_THREADS
Definition: main.cpp:31
static const std::string DEFAULT_HOST
Definition: main.cpp:38
int nsttl
Definition: dns.h:27
int clientVersion
Definition: db.h:71
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given BIP70 chain name.
bool Run()
Definition: bitcoin.cpp:185
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:179
void format(std::ostream &out, const char *fmt, const Args &... args)
Format list of arguments to the stream according to given format string.
Definition: tinyformat.h:1111
int nNew
Definition: db.h:256
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:546
bool HelpRequested(const ArgsManager &args)
Definition: system.cpp:652
int nAge
Definition: db.h:258
A CService with information about it as peer.
Definition: protocol.h:427
Definition: db.h:68
static const int CONTINUE_EXECUTION
Definition: main.cpp:29
const int id
Definition: main.cpp:232
static const std::string DEFAULT_IPV4_PROXY
Definition: main.cpp:40
uint8_t v6[16]
Definition: dns.h:20
const char * host
Definition: dns.h:28
static const std::string DEFAULT_TOR_PROXY
Definition: main.cpp:39
std::string GetClientSubVersion()
Definition: bitcoin.h:76
std::string FormatFullVersion()
bool SetProxy(enum Network net, const proxyType &addrProxy)
Definition: netbase.cpp:772
int64_t ourLastSuccess
Definition: db.h:268
std::atomic< uint64_t > dbQueries
Definition: main.cpp:234
std::string host
Definition: main.cpp:52
int flags
Definition: bitcoin-tx.cpp:529
static const std::string DEFAULT_EMAIL
Definition: main.cpp:36
int GetClientVersion()
Definition: bitcoin.h:74
seen nodes / \ (a) banned nodes available nodes-----------— / | \ tracked n...
Definition: db.h:280
bool LookupHost(const std::string &name, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup)
Resolve a host string to its corresponding network addresses.
Definition: netbase.cpp:164
bool fWipeBan
Definition: main.cpp:48
int nPort
Definition: main.cpp:46
int64_t atoi64(const char *psz)
Definition: dns.h:16
int port
Definition: dns.h:25
int GetStartingHeight()
Definition: bitcoin.h:78
int StatCompare(const CAddrReport &a, const CAddrReport &b)
Definition: main.cpp:359
static constexpr int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
Definition: clientversion.h:44
std::string mbox
Definition: main.cpp:50
std::vector< CAddrReport > GetAll()
Definition: db.h:340
const CChainParams & Params()
Return the currently selected parameters.
std::vector< addr_t > cache
Definition: main.cpp:225
const char * ns
Definition: dns.h:29
void Add(const CAddress &addr, bool fForce=false)
Definition: db.h:416
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:479
std::string ToStringIPPort() const
Definition: netaddress.cpp:772
void * ThreadCrawler(void *data)
Definition: main.cpp:169
void run()
Definition: main.cpp:295
std::map< uint64_t, FlagSpecificData > perflag
Definition: main.cpp:233
ArgsManager gArgs
Definition: system.cpp:76
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
Definition: system.cpp:657
std::string ns
Definition: main.cpp:51
int main(int argc, char *argv[])
Definition: main.cpp:20
int GetBan()
Definition: bitcoin.h:72
static int count
Definition: tests.c:35
const char * mbox
Definition: dns.h:30
uint32_t(* cb)(void *opt, char *requested_hostname, addr_t *addr, uint32_t max, uint32_t ipv4, uint32_t ipv6)
Definition: dns.h:31
std::string GetChainName() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
Definition: system.cpp:1014
std::set< uint64_t > filter_whitelist
Definition: main.cpp:56
int dnsserver(dns_opt_t *opt)
Definition: dns.cpp:596
uint32_t GetIPList(void *thread, char *requestedHostname, addr_t *addr, uint32_t max, uint32_t ipv4, uint32_t ipv6)
Definition: main.cpp:298
void * ThreadSeeder(void *)
Definition: main.cpp:459
uint8_t v4[4]
Definition: dns.h:19
int64_t GetTime()
Return system time (or mocked time, if set)
Definition: time.cpp:27
static void Sleep(int nMilliSec)
Definition: util.h:13
void GetMany(std::vector< CServiceResult > &ips, int max, int &wait)
Definition: db.h:428
bool error(const char *fmt, const Args &... args)
Definition: system.h:47
int nThreads
Definition: main.cpp:45
unsigned int cacheHits
Definition: main.cpp:227
void GetStats(CAddrDbStats &stats) const
Definition: db.h:319
dns_opt_t dns_opt
Definition: main.cpp:231
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:580
static const bool DEFAULT_WIPE_IGNORE
Definition: main.cpp:35
CAddrDb db
Definition: main.cpp:167
int nBanTime
Definition: db.h:264