本文整理汇总了C++中CDnsSeedOpts::ParseCommandLine方法的典型用法代码示例。如果您正苦于以下问题:C++ CDnsSeedOpts::ParseCommandLine方法的具体用法?C++ CDnsSeedOpts::ParseCommandLine怎么用?C++ CDnsSeedOpts::ParseCommandLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDnsSeedOpts
的用法示例。
在下文中一共展示了CDnsSeedOpts::ParseCommandLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
signal(SIGPIPE, SIG_IGN);
setbuf(stdout, NULL);
CDnsSeedOpts opts;
opts.ParseCommandLine(argc, argv);
if (opts.tor) {
CService service(opts.tor, 9050);
if (service.IsValid()) {
printf("Using Tor proxy at %s\n", service.ToStringIPPort().c_str());
SetProxy(NET_TOR, service);
}
}
bool fDNS = true;
if (opts.fUseTestNet) {
printf("Using testnet.\n");
pchMessageStart[0] = 0xfc;
pchMessageStart[1] = 0xc1;
pchMessageStart[2] = 0xb7;
pchMessageStart[3] = 0xdc;
seeds = testnet_seeds;
fTestNet = true;
}
if (!opts.ns) {
printf("No nameserver set. Not starting DNS server.\n");
fDNS = false;
}
if (fDNS && !opts.host) {
fprintf(stderr, "No hostname set. Please use -h.\n");
exit(1);
}
FILE *f = fopen("dnsseed.dat","r");
if (f) {
printf("Loading dnsseed.dat...");
CAutoFile cf(f);
cf >> db;
if (opts.fWipeBan)
db.banned.clear();
if (opts.fWipeIgnore)
db.ResetIgnores();
printf("done\n");
}
pthread_t threadDns, threadSeed, threadDump, threadStats;
if (fDNS) {
printf("Starting %i DNS threads for %s on %s (port %i)...", opts.nDnsThreads, opts.host, opts.ns, opts.nPort);
dnsThread.clear();
for (int i=0; i<opts.nDnsThreads; i++) {
dnsThread.push_back(new CDnsThread(&opts, i));
pthread_create(&threadDns, NULL, ThreadDNS, dnsThread[i]);
printf(".");
Sleep(20);
}
printf("done\n");
}
printf("Starting seeder...");
pthread_create(&threadSeed, NULL, ThreadSeeder, NULL);
printf("done\n");
printf("Starting %i crawler threads...", opts.nThreads);
pthread_attr_t attr_crawler;
pthread_attr_init(&attr_crawler);
pthread_attr_setstacksize(&attr_crawler, 0x20000);
for (int i=0; i<opts.nThreads; i++) {
pthread_t thread;
pthread_create(&thread, &attr_crawler, ThreadCrawler, &opts.nThreads);
}
pthread_attr_destroy(&attr_crawler);
printf("done\n");
pthread_create(&threadStats, NULL, ThreadStats, NULL);
pthread_create(&threadDump, NULL, ThreadDumper, NULL);
void* res;
pthread_join(threadDump, &res);
return 0;
}
示例2: main
int main(int argc, char **argv) {
signal(SIGPIPE, SIG_IGN);
setbuf(stdout, NULL);
CDnsSeedOpts opts;
opts.ParseCommandLine(argc, argv);
printf("Supporting whitelisted filters: ");
for (std::set<uint64_t>::const_iterator it = opts.filter_whitelist.begin(); it != opts.filter_whitelist.end(); it++) {
if (it != opts.filter_whitelist.begin()) {
printf(",");
}
printf("0x%lx", (unsigned long)*it);
}
printf("\n");
if (opts.tor) {
CService service(opts.tor, 9050);
if (service.IsValid()) {
printf("Using Tor proxy at %s\n", service.ToStringIPPort().c_str());
SetProxy(NET_TOR, service);
}
}
if (opts.ipv4_proxy) {
CService service(opts.ipv4_proxy, 9050);
if (service.IsValid()) {
printf("Using IPv4 proxy at %s\n", service.ToStringIPPort().c_str());
SetProxy(NET_IPV4, service);
}
}
if (opts.ipv6_proxy) {
CService service(opts.ipv6_proxy, 9050);
if (service.IsValid()) {
printf("Using IPv6 proxy at %s\n", service.ToStringIPPort().c_str());
SetProxy(NET_IPV6, service);
}
}
fSimpleLog = opts.fUseSimpleLog;
bool fDNS = true;
if (opts.fUseTestNet) {
printf("Using testnet.\n");
pchMessageStart[0] = 0xce;
pchMessageStart[1] = 0xe2;
pchMessageStart[2] = 0xca;
pchMessageStart[3] = 0xff;
seeds = testnet_seeds;
fTestNet = true;
}
if (!opts.ns) {
printf("No nameserver set. Not starting DNS server.\n");
fDNS = false;
}
if (fDNS && !opts.host) {
fprintf(stderr, "No hostname set. Please use -h.\n");
exit(1);
}
if (fDNS && !opts.mbox) {
fprintf(stderr, "No e-mail address set. Please use -m.\n");
exit(1);
}
FILE *f = fopen("dnsseed.dat","r");
if (f) {
printf("Loading dnsseed.dat...");
CAutoFile cf(f);
cf >> db;
if (opts.fWipeBan)
db.banned.clear();
if (opts.fWipeIgnore)
db.ResetIgnores();
printf("done\n");
}
pthread_t threadDns, threadSeed, threadDump, threadStats;
if (fDNS) {
printf("Starting %i DNS threads for %s on %s (port %i)...", opts.nDnsThreads, opts.host, opts.ns, opts.nPort);
dnsThread.clear();
for (int i=0; i<opts.nDnsThreads; i++) {
dnsThread.push_back(new CDnsThread(&opts, i));
pthread_create(&threadDns, NULL, ThreadDNS, dnsThread[i]);
printf(".");
Sleep(20);
}
printf("done\n");
}
printf("Starting seeder...");
pthread_create(&threadSeed, NULL, ThreadSeeder, NULL);
printf("done\n");
printf("Starting %i crawler threads...", opts.nThreads);
pthread_attr_t attr_crawler;
pthread_attr_init(&attr_crawler);
pthread_attr_setstacksize(&attr_crawler, 0x20000);
for (int i=0; i<opts.nThreads; i++) {
pthread_t thread;
pthread_create(&thread, &attr_crawler, ThreadCrawler, &opts.nThreads);
}
pthread_attr_destroy(&attr_crawler);
printf("done\n");
pthread_create(&threadStats, NULL, ThreadStats, NULL);
pthread_create(&threadDump, NULL, ThreadDumper, NULL);
void* res;
pthread_join(threadDump, &res);
return 0;
}