Browse Source

opts: Declare --port to be an early arg

There is an interaction between --ipaddr and --port, namely that the
default port is used when parsing --ipaddr if --port comes after the
--ipaddr, and --port is used if it comes before it. Adding a port to
--ipaddr still trumps everything else, but this way we correctly set
port in the address.

Reported-by: Wladimir J. van der Laan @laanwj
Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
92ce3d5e8d
  1. 15
      lightningd/options.c

15
lightningd/options.c

@ -116,10 +116,12 @@ static char *opt_add_ipaddr(const char *arg, struct lightningd *ld)
tal_resize(&ld->wireaddrs, n+1);
if (parse_wireaddr(arg, &ld->wireaddrs[n], ld->portnum))
return NULL;
if (!parse_wireaddr(arg, &ld->wireaddrs[n], ld->portnum)) {
return tal_fmt(NULL, "Unable to parse IP address '%s'", arg);
}
return NULL;
return tal_fmt(NULL, "Unable to parse IP address '%s'", arg);
}
static void opt_show_u32(char buf[OPT_SHOW_LEN], const u32 *u)
@ -533,8 +535,11 @@ void register_opts(struct lightningd *ld)
opt_register_early_noarg("--test-daemons-only",
test_daemons_and_exit,
ld, opt_hidden);
opt_register_arg("--port", opt_set_u16, opt_show_u16, &ld->portnum,
"Port to bind to (0 means don't listen)");
/* --port needs to be an early arg to force it being parsed
* before --ipaddr which may depend on it */
opt_register_early_arg("--port", opt_set_u16, opt_show_u16, &ld->portnum,
"Port to bind to (0 means don't listen)");
opt_register_arg("--bitcoin-datadir", opt_set_talstr, NULL,
&ld->topology->bitcoind->datadir,
"-datadir arg for bitcoin-cli");

Loading…
Cancel
Save