Browse Source

Make DNS optional

pull/1/head
Pieter Wuille 13 years ago committed by Pieter Wuille
parent
commit
0835038185
  1. 4
      Makefile
  2. 11
      main.cpp

4
Makefile

@ -1,9 +1,9 @@
dnsseed: dns.o bitcoin.o netbase.o protocol.o db.o main.o dnsseed: dns.o bitcoin.o netbase.o protocol.o db.o main.o
g++ -pthread -lssl -o dnsseed dns.o bitcoin.o netbase.o protocol.o db.o main.o g++ -pthread -lcrypto -o dnsseed dns.o bitcoin.o netbase.o protocol.o db.o main.o
strip -s dnsseed strip -s dnsseed
dnsseed.dbg: dns.o bitcoin.o netbase.o protocol.o db.o main.o dnsseed.dbg: dns.o bitcoin.o netbase.o protocol.o db.o main.o
g++ -pthread -lssl -o dnsseed.dbg dns.o bitcoin.o netbase.o protocol.o db.o main.o g++ -pthread -lcrypto -o dnsseed.dbg dns.o bitcoin.o netbase.o protocol.o db.o main.o
%.o: %.cpp bitcoin.h netbase.h protocol.h db.h serialize.h uint256.h util.h %.o: %.cpp bitcoin.h netbase.h protocol.h db.h serialize.h uint256.h util.h
g++ -pthread -O3 -ggdb3 -march=nocona -Wno-invalid-offsetof -c -o $@ $< g++ -pthread -O3 -ggdb3 -march=nocona -Wno-invalid-offsetof -c -o $@ $<

11
main.cpp

@ -220,11 +220,12 @@ int main(int argc, char **argv) {
setbuf(stdout, NULL); setbuf(stdout, NULL);
CDnsSeedOpts opts; CDnsSeedOpts opts;
opts.ParseCommandLine(argc, argv); opts.ParseCommandLine(argc, argv);
bool fDNS = true;
if (!opts.ns) { if (!opts.ns) {
fprintf(stderr, "No nameserver set. Please use -n.\n"); printf("No nameserver set. Not starting DNS server.\n");
exit(1); fDNS = false;
} }
if (!opts.host) { if (fDNS && !opts.host) {
fprintf(stderr, "No hostname set. Please use -h.\n"); fprintf(stderr, "No hostname set. Please use -h.\n");
exit(1); exit(1);
} }
@ -247,11 +248,13 @@ int main(int argc, char **argv) {
} }
printf("done\n"); printf("done\n");
pthread_create(&threadDump, NULL, ThreadDumper, NULL); pthread_create(&threadDump, NULL, ThreadDumper, NULL);
if (fDNS) {
printf("Starting DNS server for %s on %s (port %i)...", opts.host, opts.ns, opts.nPort); printf("Starting DNS server for %s on %s (port %i)...", opts.host, opts.ns, opts.nPort);
pthread_create(&threadDns, NULL, ThreadDNS, &opts); pthread_create(&threadDns, NULL, ThreadDNS, &opts);
printf("done\n"); printf("done\n");
}
pthread_create(&threadStats, NULL, ThreadStats, NULL); pthread_create(&threadStats, NULL, ThreadStats, NULL);
void* res; void* res;
pthread_join(threadDns, &res); pthread_join(threadDump, &res);
return 0; return 0;
} }

Loading…
Cancel
Save