Skip to content

Commit

Permalink
options: fix handling of wildcard (allproto) address.
Browse files Browse the repository at this point in the history
We treated ':' as an empty DNS name in EXPERIMENTAL, which is wrong.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and m-schmoock committed Dec 5, 2021
1 parent ff556fe commit b45544c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions common/wireaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions common/wireaddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
1 change: 0 additions & 1 deletion tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b45544c

Please sign in to comment.