Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/main.cpp
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | |||||
#include "dns.h" | #include "dns.h" | ||||
} | } | ||||
CAddrDb db; | CAddrDb db; | ||||
extern "C" void *ThreadCrawler(void *data) { | extern "C" void *ThreadCrawler(void *data) { | ||||
int *nThreads = (int *)data; | int *nThreads = (int *)data; | ||||
do { | do { | ||||
std::vector<CSeederServiceResult> ips; | std::vector<CServiceResult> ips; | ||||
int wait = 5; | int wait = 5; | ||||
db.GetMany(ips, 16, wait); | db.GetMany(ips, 16, wait); | ||||
int64_t now = time(nullptr); | int64_t now = time(nullptr); | ||||
if (ips.empty()) { | if (ips.empty()) { | ||||
wait *= 1000; | wait *= 1000; | ||||
wait += rand() % (500 * *nThreads); | wait += rand() % (500 * *nThreads); | ||||
Sleep(wait); | Sleep(wait); | ||||
continue; | continue; | ||||
} | } | ||||
std::vector<CSeederAddress> addr; | std::vector<CSeederAddress> addr; | ||||
for (size_t i = 0; i < ips.size(); i++) { | for (size_t i = 0; i < ips.size(); i++) { | ||||
CSeederServiceResult &res = ips[i]; | CServiceResult &res = ips[i]; | ||||
res.nBanTime = 0; | res.nBanTime = 0; | ||||
res.nClientV = 0; | res.nClientV = 0; | ||||
res.nHeight = 0; | res.nHeight = 0; | ||||
res.strClientV = ""; | res.strClientV = ""; | ||||
bool getaddr = res.ourLastSuccess + 86400 < now; | bool getaddr = res.ourLastSuccess + 86400 < now; | ||||
res.fGood = TestNode(res.service, res.nBanTime, res.nClientV, | res.fGood = TestNode(res.service, res.nBanTime, res.nClientV, | ||||
res.strClientV, res.nHeight, | res.strClientV, res.nHeight, | ||||
getaddr ? &addr : nullptr); | getaddr ? &addr : nullptr); | ||||
▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | static const std::string mainnet_seeds[] = { | ||||
"seed.bitcoinabc.org", "seed-abc.bitcoinforks.org", "seed.bitprim.org", | "seed.bitcoinabc.org", "seed-abc.bitcoinforks.org", "seed.bitprim.org", | ||||
"seed.deadalnix.me", "seeder.criptolayer.net", ""}; | "seed.deadalnix.me", "seeder.criptolayer.net", ""}; | ||||
static const std::string testnet_seeds[] = { | static const std::string testnet_seeds[] = { | ||||
"testnet-seed.bitcoinabc.org", "testnet-seed-abc.bitcoinforks.org", | "testnet-seed.bitcoinabc.org", "testnet-seed-abc.bitcoinforks.org", | ||||
"testnet-seed.bitprim.org", "testnet-seed.deadalnix.me", | "testnet-seed.bitprim.org", "testnet-seed.deadalnix.me", | ||||
"testnet-seeder.criptolayer.net", ""}; | "testnet-seeder.criptolayer.net", ""}; | ||||
static const std::string *seeds = mainnet_seeds; | static const std::string *seeds = mainnet_seeds; | ||||
const static unsigned int MAX_HOSTS_PER_SEED = 128; | |||||
extern "C" void *ThreadSeeder(void *) { | extern "C" void *ThreadSeeder(void *) { | ||||
if (!fTestNet) { | |||||
db.Add(CSeederService("kjy2eqzk4zwi5zd3.onion", 8333), true); | |||||
} | |||||
do { | do { | ||||
for (int i = 0; seeds[i] != ""; i++) { | for (int i = 0; seeds[i] != ""; i++) { | ||||
std::vector<CNetAddr> ips; | std::vector<CNetAddr> ips; | ||||
LookupHost(seeds[i].c_str(), ips); | LookupHost(seeds[i].c_str(), ips, MAX_HOSTS_PER_SEED, true); | ||||
for (auto &ip : ips) { | for (auto &ip : ips) { | ||||
db.Add(CSeederService(ip, GetDefaultPort()), true); | db.Add(CSeederAddress(CService(ip, GetDefaultPort())), true); | ||||
} | } | ||||
} | } | ||||
Sleep(1800000); | Sleep(1800000); | ||||
} while (1); | } while (1); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
int main(int argc, char **argv) { | int main(int argc, char **argv) { | ||||
signal(SIGPIPE, SIG_IGN); | signal(SIGPIPE, SIG_IGN); | ||||
setbuf(stdout, nullptr); | setbuf(stdout, nullptr); | ||||
CDnsSeedOpts opts; | CDnsSeedOpts opts; | ||||
opts.ParseCommandLine(argc, argv); | opts.ParseCommandLine(argc, argv); | ||||
printf("Supporting whitelisted filters: "); | printf("Supporting whitelisted filters: "); | ||||
for (std::set<uint64_t>::const_iterator it = opts.filter_whitelist.begin(); | for (std::set<uint64_t>::const_iterator it = opts.filter_whitelist.begin(); | ||||
it != opts.filter_whitelist.end(); it++) { | it != opts.filter_whitelist.end(); it++) { | ||||
if (it != opts.filter_whitelist.begin()) { | if (it != opts.filter_whitelist.begin()) { | ||||
printf(","); | printf(","); | ||||
} | } | ||||
printf("0x%lx", (unsigned long)*it); | printf("0x%lx", (unsigned long)*it); | ||||
} | } | ||||
printf("\n"); | printf("\n"); | ||||
if (opts.tor) { | if (opts.tor) { | ||||
CSeederService service(opts.tor, 9050); | CService service(LookupNumeric(opts.tor, 9050)); | ||||
if (service.IsValid()) { | if (service.IsValid()) { | ||||
printf("Using Tor proxy at %s\n", service.ToStringIPPort().c_str()); | printf("Using Tor proxy at %s\n", service.ToStringIPPort().c_str()); | ||||
SetProxy(NET_TOR, service); | SetProxy(NET_TOR, service); | ||||
} | } | ||||
} | } | ||||
if (opts.ipv4_proxy) { | if (opts.ipv4_proxy) { | ||||
CSeederService service(opts.ipv4_proxy, 9050); | CService service(LookupNumeric(opts.ipv4_proxy, 9050)); | ||||
if (service.IsValid()) { | if (service.IsValid()) { | ||||
printf("Using IPv4 proxy at %s\n", | printf("Using IPv4 proxy at %s\n", | ||||
service.ToStringIPPort().c_str()); | service.ToStringIPPort().c_str()); | ||||
SetProxy(NET_IPV4, service); | SetProxy(NET_IPV4, service); | ||||
} | } | ||||
} | } | ||||
if (opts.ipv6_proxy) { | if (opts.ipv6_proxy) { | ||||
CSeederService service(opts.ipv6_proxy, 9050); | CService service(LookupNumeric(opts.ipv6_proxy, 9050)); | ||||
if (service.IsValid()) { | if (service.IsValid()) { | ||||
printf("Using IPv6 proxy at %s\n", | printf("Using IPv6 proxy at %s\n", | ||||
service.ToStringIPPort().c_str()); | service.ToStringIPPort().c_str()); | ||||
SetProxy(NET_IPV6, service); | SetProxy(NET_IPV6, service); | ||||
} | } | ||||
} | } | ||||
bool fDNS = true; | bool fDNS = true; | ||||
if (opts.fUseTestNet) { | if (opts.fUseTestNet) { | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |