connectd: fix empty error message
1. Adds the missing DNS error massages so they can be handled by connect_control. 2. Prepends a 'All addresses failed' to code 401 message, so we always have at least some error message to the user. Changelog-None
This commit is contained in:
parent
d5f2b1126c
commit
c2d2cc1274
|
@ -948,7 +948,8 @@ static void try_connect_one_addr(struct connecting *connect)
|
||||||
connect_failed(connect->daemon, &connect->id,
|
connect_failed(connect->daemon, &connect->id,
|
||||||
connect->seconds_waited,
|
connect->seconds_waited,
|
||||||
connect->addrhint, CONNECT_ALL_ADDRESSES_FAILED,
|
connect->addrhint, CONNECT_ALL_ADDRESSES_FAILED,
|
||||||
"%s", connect->errors);
|
"All addresses failed: %s",
|
||||||
|
connect->errors);
|
||||||
tal_free(connect);
|
tal_free(connect);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -992,8 +993,14 @@ static void try_connect_one_addr(struct connecting *connect)
|
||||||
#if EXPERIMENTAL_FEATURES /* BOLT7 DNS RFC #911 */
|
#if EXPERIMENTAL_FEATURES /* BOLT7 DNS RFC #911 */
|
||||||
if (use_proxy) /* hand it to the proxy */
|
if (use_proxy) /* hand it to the proxy */
|
||||||
break;
|
break;
|
||||||
if (!use_dns) /* ignore DNS when we can't use it */
|
if (!use_dns) { /* ignore DNS when we can't use it */
|
||||||
|
tal_append_fmt(&connect->errors,
|
||||||
|
"%s: dns disabled. ",
|
||||||
|
type_to_string(tmpctx,
|
||||||
|
struct wireaddr_internal,
|
||||||
|
addr));
|
||||||
goto next;
|
goto next;
|
||||||
|
}
|
||||||
/* Resolve with getaddrinfo */
|
/* Resolve with getaddrinfo */
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
@ -1005,8 +1012,12 @@ static void try_connect_one_addr(struct connecting *connect)
|
||||||
addr->u.wireaddr.port),
|
addr->u.wireaddr.port),
|
||||||
&hints, &ais);
|
&hints, &ais);
|
||||||
if (gai_err != 0) {
|
if (gai_err != 0) {
|
||||||
status_debug("DNS with getaddrinfo gave: %s",
|
tal_append_fmt(&connect->errors,
|
||||||
gai_strerror(gai_err));
|
"%s: getaddrinfo error '%s'. ",
|
||||||
|
type_to_string(tmpctx,
|
||||||
|
struct wireaddr_internal,
|
||||||
|
addr),
|
||||||
|
gai_strerror(gai_err));
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
/* create new addrhints on-the-fly per result ... */
|
/* create new addrhints on-the-fly per result ... */
|
||||||
|
@ -1032,6 +1043,11 @@ static void try_connect_one_addr(struct connecting *connect)
|
||||||
}
|
}
|
||||||
freeaddrinfo(ais);
|
freeaddrinfo(ais);
|
||||||
#endif
|
#endif
|
||||||
|
tal_append_fmt(&connect->errors,
|
||||||
|
"%s: EXPERIMENTAL_FEATURES needed. ",
|
||||||
|
type_to_string(tmpctx,
|
||||||
|
struct wireaddr_internal,
|
||||||
|
addr));
|
||||||
goto next;
|
goto next;
|
||||||
case ADDR_TYPE_WEBSOCKET:
|
case ADDR_TYPE_WEBSOCKET:
|
||||||
af = -1;
|
af = -1;
|
||||||
|
|
|
@ -232,7 +232,7 @@ def test_announce_and_connect_via_dns(node_factory, bitcoind):
|
||||||
|
|
||||||
# l4 however must not be able to connect because he used '--disable-dns'
|
# l4 however must not be able to connect because he used '--disable-dns'
|
||||||
# This raises RpcError code 401, currently with an empty error message.
|
# This raises RpcError code 401, currently with an empty error message.
|
||||||
with pytest.raises(RpcError, match=r"401"):
|
with pytest.raises(RpcError, match=r"401.*dns disabled"):
|
||||||
l4.rpc.connect(l1.info['id'])
|
l4.rpc.connect(l1.info['id'])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue