mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
options: refuse two --announce-addr of the same type.
Gossipd will ignore the second one, but doing it in the front end gives an explicit error message. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
f67182ff20
commit
c46f373205
@@ -181,7 +181,36 @@ static char *opt_add_bind_addr(const char *arg, struct lightningd *ld)
|
||||
|
||||
static char *opt_add_announce_addr(const char *arg, struct lightningd *ld)
|
||||
{
|
||||
return opt_add_addr_withtype(arg, ld, ADDR_ANNOUNCE, false);
|
||||
const struct wireaddr *wn;
|
||||
size_t n = tal_count(ld->proposed_wireaddr);
|
||||
char *err = opt_add_addr_withtype(arg, ld, ADDR_ANNOUNCE, false);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Can't announce anything that's not a normal wireaddr. */
|
||||
if (ld->proposed_wireaddr[n].itype != ADDR_INTERNAL_WIREADDR)
|
||||
return tal_fmt(NULL, "address '%s' is not announcable",
|
||||
arg);
|
||||
|
||||
/* gossipd will refuse to announce the second one, sure, but it's
|
||||
* better to check and fail now if they've explicitly asked for it. */
|
||||
wn = &ld->proposed_wireaddr[n].u.wireaddr;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
const struct wireaddr *wi;
|
||||
|
||||
if (ld->proposed_listen_announce[i] != ADDR_ANNOUNCE)
|
||||
continue;
|
||||
assert(ld->proposed_wireaddr[i].itype == ADDR_INTERNAL_WIREADDR);
|
||||
wi = &ld->proposed_wireaddr[i].u.wireaddr;
|
||||
|
||||
if (wn->type != wi->type)
|
||||
continue;
|
||||
return tal_fmt(NULL, "Cannot announce address %s;"
|
||||
" already have %s which is the same type",
|
||||
type_to_string(tmpctx, struct wireaddr, wn),
|
||||
type_to_string(tmpctx, struct wireaddr, wi));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *opt_add_ipaddr(const char *arg, struct lightningd *ld)
|
||||
|
||||
Reference in New Issue
Block a user