options: fix handling of wildcard (allproto) address.

We treated ':' as an empty DNS name in EXPERIMENTAL, which is wrong.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-12-02 17:38:48 +10:30 committed by Michael Schmoock
parent ff556fefc6
commit b45544c659
4 changed files with 13 additions and 4 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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)) {

View File

@ -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()