diff --git a/doc/release-notes.md b/doc/release-notes.md
--- a/doc/release-notes.md
+++ b/doc/release-notes.md
@@ -3,3 +3,8 @@
This release includes the following features and fixes:
+ - `bitcoin-seeder` no longer takes single letter parameter names. Please use
+ the full length parameter names. See `bitcoin-seeder -?` for more
+ information.
+ - If the `-?`, `-h`, or `-help` options are used, `bitcoin-seeder` will now
+ output its help message and then cease operation.
diff --git a/src/seeder/README.md b/src/seeder/README.md
--- a/src/seeder/README.md
+++ b/src/seeder/README.md
@@ -33,10 +33,10 @@
On the system vps.example.com, you can now run dnsseed:
-./bitcoin-seeder -h dnsseed.example.com -n vps.example.com
+./bitcoin-seeder -host=dnsseed.example.com -ns=vps.example.com
If you want the DNS server to report SOA records, please provide an
-e-mail address (with the @ part replaced by .) using -m.
+e-mail address (with the @ part replaced by .) using -mbox.
RUNNING AS NON-ROOT
@@ -50,7 +50,7 @@
$ iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-port 5353
If properly configured, this will allow you to run dnsseed in userspace, using
-the -p 5353 option.
+the -port=5353 option.
Generate Seed Lists
-------------------
diff --git a/src/seeder/main.cpp b/src/seeder/main.cpp
--- a/src/seeder/main.cpp
+++ b/src/seeder/main.cpp
@@ -6,6 +6,7 @@
#include
#include
#include
+#include
#include
#include
@@ -13,7 +14,6 @@
#include
#include
#include
-#include
#include
const std::function G_TRANSLATION_FUN = nullptr;
@@ -36,9 +36,9 @@
int nThreads;
int nPort;
int nDnsThreads;
- int fUseTestNet;
- int fWipeBan;
- int fWipeIgnore;
+ bool fUseTestNet;
+ bool fWipeBan;
+ bool fWipeIgnore;
std::string mbox;
std::string ns;
std::string host;
@@ -56,119 +56,48 @@
ipv6_proxy(DEFAULT_IPV6_PROXY) {}
void ParseCommandLine(int argc, char **argv) {
- static const char *help =
- "Bitcoin-cash-seeder\n"
- "Usage: %s -h -n [-m ] [-t ] [-p "
- "]\n"
- "\n"
- "Options:\n"
- "-h Hostname of the DNS seed\n"
- "-n Hostname of the nameserver\n"
- "-m E-Mail address reported in SOA records\n"
- "-t Number of crawlers to run in parallel (default "
- "96)\n"
- "-d Number of DNS server threads (default 4)\n"
- "-p UDP port to listen on (default 53)\n"
- "-o Tor proxy IP/Port\n"
- "-i IPV4 SOCKS5 proxy IP/Port\n"
- "-k IPV6 SOCKS5 proxy IP/Port\n"
- "-w f1,f2,... Allow these flag combinations as filters\n"
- "--testnet Use testnet\n"
- "--wipeban Wipe list of banned nodes\n"
- "--wipeignore Wipe list of ignored nodes\n"
- "-?, --help Show this text\n"
- "\n";
- bool showHelp = false;
-
- while (1) {
- static struct option long_options[] = {
- {"host", required_argument, 0, 'h'},
- {"ns", required_argument, 0, 'n'},
- {"mbox", required_argument, 0, 'm'},
- {"threads", required_argument, 0, 't'},
- {"dnsthreads", required_argument, 0, 'd'},
- {"port", required_argument, 0, 'p'},
- {"onion", required_argument, 0, 'o'},
- {"proxyipv4", required_argument, 0, 'i'},
- {"proxyipv6", required_argument, 0, 'k'},
- {"filter", required_argument, 0, 'w'},
- {"testnet", no_argument, &fUseTestNet, 1},
- {"wipeban", no_argument, &fWipeBan, 1},
- {"wipeignore", no_argument, &fWipeIgnore, 1},
- {"help", no_argument, 0, 'h'},
- {0, 0, 0, 0}};
- int option_index = 0;
- int c =
- getopt_long(argc, argv, "h:n:m:t:p:d:o:i:k:w:", long_options,
- &option_index);
- if (c == -1) break;
- switch (c) {
- case 'h': {
- host = std::string(optarg);
- break;
- }
-
- case 'm': {
- mbox = std::string(optarg);
- break;
- }
-
- case 'n': {
- ns = std::string(optarg);
- break;
- }
-
- case 't': {
- int n = strtol(optarg, nullptr, 10);
- if (n > 0 && n < 1000) nThreads = n;
- break;
- }
-
- case 'd': {
- int n = strtol(optarg, nullptr, 10);
- if (n > 0 && n < 1000) nDnsThreads = n;
- break;
- }
-
- case 'p': {
- int p = strtol(optarg, nullptr, 10);
- if (p > 0 && p < 65536) nPort = p;
- break;
- }
-
- case 'o': {
- tor = std::string(optarg);
- break;
- }
-
- case 'i': {
- ipv4_proxy = std::string(optarg);
- break;
- }
-
- case 'k': {
- ipv6_proxy = std::string(optarg);
- break;
- }
-
- case 'w': {
- char *ptr = optarg;
- while (*ptr != 0) {
- unsigned long l = strtoul(ptr, &ptr, 0);
- if (*ptr == ',') {
- ptr++;
- } else if (*ptr != 0) {
- break;
- }
- filter_whitelist.insert(l);
- }
- break;
- }
+ std::string error;
+ if (!gArgs.ParseParameters(argc, argv, error)) {
+ fprintf(stderr, "Error parsing command line arguments: %s\n",
+ error.c_str());
+ exit(1);
+ }
+ if (HelpRequested(gArgs)) {
+ std::string strUsage = "Bitcoin-cash-seeder\nUsage: bitcoin-seeder "
+ "-host= -ns= [-mbox=] "
+ "[-threads=] [-port=]\n\n" +
+ gArgs.GetHelpMessage();
+
+ fprintf(stdout, "%s", strUsage.c_str());
+ exit(0);
+ }
- case '?': {
- showHelp = true;
+ nThreads = gArgs.GetArg("-threads", DEFAULT_NUM_THREADS);
+ nPort = gArgs.GetArg("-port", DEFAULT_PORT);
+ nDnsThreads = gArgs.GetArg("-dnsthreads", DEFAULT_NUM_DNS_THREADS);
+ fUseTestNet = gArgs.GetBoolArg("-testnet", DEFAULT_TESTNET);
+ fWipeBan = gArgs.GetBoolArg("-wipeban", DEFAULT_WIPE_BAN);
+ fWipeIgnore = gArgs.GetBoolArg("-wipeignore", DEFAULT_WIPE_IGNORE);
+ mbox = gArgs.GetArg("-mbox", DEFAULT_EMAIL);
+ ns = gArgs.GetArg("-ns", DEFAULT_NAMESERVER);
+ host = gArgs.GetArg("-host", DEFAULT_HOST);
+ tor = gArgs.GetArg("-onion", DEFAULT_TOR_PROXY);
+ ipv4_proxy = gArgs.GetArg("-proxyipv4", DEFAULT_IPV4_PROXY);
+ ipv6_proxy = gArgs.GetArg("-proxyipv6", DEFAULT_IPV6_PROXY);
+
+ if (gArgs.IsArgSet("-filter")) {
+ // Parse whitelist additions
+ std::string flags = gArgs.GetArg("-filter", "");
+ size_t flagstartpos = 0;
+ while (flagstartpos < flags.size()) {
+ size_t flagendpos = flags.find_first_of(",", flagstartpos);
+ uint64_t flag = atoi64(
+ flags.substr(flagstartpos, (flagendpos - flagstartpos)));
+ filter_whitelist.insert(flag);
+ if (flagendpos == std::string::npos) {
break;
}
+ flagstartpos = flagendpos + 1;
}
}
if (filter_whitelist.empty()) {
@@ -177,8 +106,6 @@
filter_whitelist.insert(NODE_NETWORK | NODE_XTHIN);
filter_whitelist.insert(NODE_NETWORK | NODE_BLOOM | NODE_XTHIN);
}
- if (!host.empty() && ns.empty()) showHelp = true;
- if (showHelp) fprintf(stderr, help, argv[0]);
}
};
@@ -487,6 +414,43 @@
return nullptr;
}
+static void SetupSeederArgs() {
+ gArgs.AddArg("-?", _("Print this help message and exit"), false,
+ OptionsCategory::OPTIONS);
+ gArgs.AddArg("-host=", _("Hostname of the DNS seed"), false,
+ OptionsCategory::OPTIONS);
+ gArgs.AddArg("-ns=", _("Hostname of the nameserver"), false,
+ OptionsCategory::OPTIONS);
+ gArgs.AddArg("-mbox=", _("E-Mail address reported in SOA records"),
+ false, OptionsCategory::OPTIONS);
+ gArgs.AddArg("-threads=",
+ _("Number of crawlers to run in parallel (default 96)"), false,
+ OptionsCategory::OPTIONS);
+ gArgs.AddArg("-dnsthreads=",
+ _("Number of DNS server threads (default 4)"), false,
+ OptionsCategory::OPTIONS);
+ gArgs.AddArg("-port=", _("UDP port to listen on (default 53)"), false,
+ OptionsCategory::CONNECTION);
+ gArgs.AddArg("-onion=", _("Tor proxy IP/Port"), false,
+ OptionsCategory::CONNECTION);
+ gArgs.AddArg("-proxyipv4=", _("IPV4 SOCKS5 proxy IP/Port"), false,
+ OptionsCategory::CONNECTION);
+ gArgs.AddArg("-proxyipv6=", _("IPV6 SOCKS5 proxy IP/Port"), false,
+ OptionsCategory::CONNECTION);
+ gArgs.AddArg("-filter=",
+ _("Allow these flag combinations as filters"), false,
+ OptionsCategory::OPTIONS);
+ gArgs.AddArg("-testnet", _("Use testnet"), false,
+ OptionsCategory::CHAINPARAMS);
+ gArgs.AddArg("-wipeban", _("Wipe list of banned nodes"), false,
+ OptionsCategory::CONNECTION);
+ gArgs.AddArg("-wipeignore", _("Wipe list of ignored nodes"), false,
+ OptionsCategory::CONNECTION);
+
+ gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN);
+ gArgs.AddArg("-h", "", false, OptionsCategory::HIDDEN);
+}
+
int main(int argc, char **argv) {
// The logger dump everything on the console by default.
GetLogger().m_print_to_console = true;
@@ -494,6 +458,7 @@
signal(SIGPIPE, SIG_IGN);
setbuf(stdout, nullptr);
CDnsSeedOpts opts;
+ SetupSeederArgs();
opts.ParseCommandLine(argc, argv);
fprintf(stdout, "Supporting whitelisted filters: ");
for (std::set::const_iterator it = opts.filter_whitelist.begin();