From b45544c6596c4e57b6987182f8e31f10456c66ac Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 2 Dec 2021 17:38:48 +1030 Subject: [PATCH] options: fix handling of wildcard (allproto) address. We treated ':' as an empty DNS name in EXPERIMENTAL, which is wrong. Signed-off-by: Rusty Russell --- common/wireaddr.c | 9 +++++++-- common/wireaddr.h | 2 ++ lightningd/options.c | 5 ++++- tests/test_connection.py | 1 - 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common/wireaddr.c b/common/wireaddr.c index 8130fee5d..48a1b3c37 100644 --- a/common/wireaddr.c +++ b/common/wireaddr.c @@ -361,6 +361,11 @@ bool is_toraddr(const char *arg) return true; } +bool is_wildcardaddr(const char *arg) +{ + return streq(arg, ""); +} + /* Rules: * * - not longer than 255 @@ -374,7 +379,7 @@ bool is_dnsaddr(const char *arg) size_t i, arglen; int lastdot; - if (is_ipaddr(arg) || is_toraddr(arg)) + if (is_ipaddr(arg) || is_toraddr(arg) || is_wildcardaddr(arg)) return false; /* now that its not IP or TOR, check its a DNS name */ @@ -684,7 +689,7 @@ bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr, /* An empty string means IPv4 and IPv6 (which under Linux by default * means just IPv6, and IPv4 gets autobound). */ - if (wildcard_ok && streq(ip, "")) { + if (wildcard_ok && is_wildcardaddr(ip)) { addr->itype = ADDR_INTERNAL_ALLPROTO; addr->u.port = splitport; return true; diff --git a/common/wireaddr.h b/common/wireaddr.h index 8b8b79904..ed83194d1 100644 --- a/common/wireaddr.h +++ b/common/wireaddr.h @@ -162,6 +162,8 @@ bool is_ipaddr(const char *arg); bool is_toraddr(const char *arg); +bool is_wildcardaddr(const char *arg); + bool is_dnsaddr(const char *arg); bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr, diff --git a/lightningd/options.c b/lightningd/options.c index 4e79efeb3..9fb1eac0f 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -198,7 +198,10 @@ static char *opt_add_addr_withtype(const char *arg, if (!separate_address_and_port(tmpctx, arg, &address, &port)) return tal_fmt(NULL, "Unable to parse address:port '%s'", arg); - if (is_ipaddr(address) || is_toraddr(address) || ala != ADDR_ANNOUNCE) { + if (is_ipaddr(address) + || is_toraddr(address) + || is_wildcardaddr(address) + || ala != ADDR_ANNOUNCE) { if (!parse_wireaddr_internal(arg, &wi, ld->portnum, wildcard_ok, dns_ok, false, deprecated_apis, &err_msg)) { diff --git a/tests/test_connection.py b/tests/test_connection.py index 93c4ce3c2..eb62b1b93 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -3746,7 +3746,6 @@ def test_old_feerate(node_factory): l1.pay(l2, 1000) -@pytest.mark.skip('Broken') @pytest.mark.developer("needs --dev-allow-localhost") def test_websocket(node_factory): ws_port = reserve()