mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
chore: use EXPERIMENTAL for BOLT7 DNS #911
Changelog-EXPERIMENTAL: Ability to announce DNS addresses
This commit is contained in:
parent
2b8896a0b5
commit
a3ea9fdc87
3 changed files with 26 additions and 1 deletions
|
@ -928,12 +928,14 @@ static void try_connect_one_addr(struct connecting *connect)
|
||||||
bool use_proxy = connect->daemon->always_use_proxy;
|
bool use_proxy = connect->daemon->always_use_proxy;
|
||||||
const struct wireaddr_internal *addr = &connect->addrs[connect->addrnum];
|
const struct wireaddr_internal *addr = &connect->addrs[connect->addrnum];
|
||||||
struct io_conn *conn;
|
struct io_conn *conn;
|
||||||
|
#if EXPERIMENTAL_FEATURES /* BOLT7 DNS RFC #911 */
|
||||||
bool use_dns = connect->daemon->use_dns;
|
bool use_dns = connect->daemon->use_dns;
|
||||||
struct addrinfo hints, *ais, *aii;
|
struct addrinfo hints, *ais, *aii;
|
||||||
struct wireaddr_internal addrhint;
|
struct wireaddr_internal addrhint;
|
||||||
int gai_err;
|
int gai_err;
|
||||||
struct sockaddr_in *sa4;
|
struct sockaddr_in *sa4;
|
||||||
struct sockaddr_in6 *sa6;
|
struct sockaddr_in6 *sa6;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* In case we fail without a connection, make destroy_io_conn happy */
|
/* In case we fail without a connection, make destroy_io_conn happy */
|
||||||
connect->conn = NULL;
|
connect->conn = NULL;
|
||||||
|
@ -984,6 +986,7 @@ static void try_connect_one_addr(struct connecting *connect)
|
||||||
af = AF_INET6;
|
af = AF_INET6;
|
||||||
break;
|
break;
|
||||||
case ADDR_TYPE_DNS:
|
case ADDR_TYPE_DNS:
|
||||||
|
#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 */
|
||||||
|
@ -1025,6 +1028,7 @@ static void try_connect_one_addr(struct connecting *connect)
|
||||||
addr = &connect->addrs[connect->addrnum];
|
addr = &connect->addrs[connect->addrnum];
|
||||||
}
|
}
|
||||||
freeaddrinfo(ais);
|
freeaddrinfo(ais);
|
||||||
|
#endif
|
||||||
goto next;
|
goto next;
|
||||||
case ADDR_TYPE_WEBSOCKET:
|
case ADDR_TYPE_WEBSOCKET:
|
||||||
af = -1;
|
af = -1;
|
||||||
|
@ -1666,8 +1670,10 @@ static void add_seed_addrs(struct wireaddr_internal **addrs,
|
||||||
NULL, broken_reply, NULL);
|
NULL, broken_reply, NULL);
|
||||||
if (new_addrs) {
|
if (new_addrs) {
|
||||||
for (size_t j = 0; j < tal_count(new_addrs); j++) {
|
for (size_t j = 0; j < tal_count(new_addrs); j++) {
|
||||||
|
#if EXPERIMENTAL_FEATURES /* BOLT7 DNS RFC #911 */
|
||||||
if (new_addrs[j].type == ADDR_TYPE_DNS)
|
if (new_addrs[j].type == ADDR_TYPE_DNS)
|
||||||
continue;
|
continue;
|
||||||
|
#endif
|
||||||
struct wireaddr_internal a;
|
struct wireaddr_internal a;
|
||||||
a.itype = ADDR_INTERNAL_WIREADDR;
|
a.itype = ADDR_INTERNAL_WIREADDR;
|
||||||
a.u.wireaddr = new_addrs[j];
|
a.u.wireaddr = new_addrs[j];
|
||||||
|
|
|
@ -221,6 +221,7 @@ static char *opt_add_addr_withtype(const char *arg,
|
||||||
tal_arr_expand(&ld->proposed_wireaddr, wi);
|
tal_arr_expand(&ld->proposed_wireaddr, wi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if EXPERIMENTAL_FEATURES /* BOLT7 DNS RFC #911 */
|
||||||
/* Add ADDR_TYPE_DNS to announce DNS hostnames */
|
/* Add ADDR_TYPE_DNS to announce DNS hostnames */
|
||||||
if (is_dnsaddr(address) && ala & ADDR_ANNOUNCE) {
|
if (is_dnsaddr(address) && ala & ADDR_ANNOUNCE) {
|
||||||
memset(&wi, 0, sizeof(wi));
|
memset(&wi, 0, sizeof(wi));
|
||||||
|
@ -234,6 +235,7 @@ static char *opt_add_addr_withtype(const char *arg,
|
||||||
tal_arr_expand(&ld->proposed_listen_announce, ADDR_ANNOUNCE);
|
tal_arr_expand(&ld->proposed_listen_announce, ADDR_ANNOUNCE);
|
||||||
tal_arr_expand(&ld->proposed_wireaddr, wi);
|
tal_arr_expand(&ld->proposed_wireaddr, wi);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ from fixtures import * # noqa: F401,F403
|
||||||
from fixtures import TEST_NETWORK
|
from fixtures import TEST_NETWORK
|
||||||
from pyln.client import RpcError, Millisatoshi
|
from pyln.client import RpcError, Millisatoshi
|
||||||
from utils import (
|
from utils import (
|
||||||
DEVELOPER, wait_for, TIMEOUT, only_one, sync_blockheight, expected_node_features, COMPAT
|
DEVELOPER, wait_for, TIMEOUT, only_one, sync_blockheight,
|
||||||
|
expected_node_features, COMPAT, EXPERIMENTAL_FEATURES
|
||||||
)
|
)
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
@ -118,6 +119,13 @@ def test_announce_address(node_factory, bitcoind):
|
||||||
'::'],
|
'::'],
|
||||||
'log-level': 'io',
|
'log-level': 'io',
|
||||||
'dev-allow-localhost': None}
|
'dev-allow-localhost': None}
|
||||||
|
if not EXPERIMENTAL_FEATURES: # BOLT7 DNS RFC #911
|
||||||
|
opts = {'disable-dns': None, 'announce-addr':
|
||||||
|
['4acth47i6kxnvkewtm6q7ib2s3ufpo5sqbsnzjpbi7utijcltosqemad.onion',
|
||||||
|
'1.2.3.4:1234',
|
||||||
|
'::'],
|
||||||
|
'log-level': 'io',
|
||||||
|
'dev-allow-localhost': None}
|
||||||
l1, l2 = node_factory.get_nodes(2, opts=[opts, {}])
|
l1, l2 = node_factory.get_nodes(2, opts=[opts, {}])
|
||||||
|
|
||||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||||
|
@ -127,6 +135,14 @@ def test_announce_address(node_factory, bitcoind):
|
||||||
l1.wait_channel_active(scid)
|
l1.wait_channel_active(scid)
|
||||||
l2.wait_channel_active(scid)
|
l2.wait_channel_active(scid)
|
||||||
|
|
||||||
|
if not EXPERIMENTAL_FEATURES: # BOLT7 DNS RFC #911
|
||||||
|
l1.daemon.wait_for_log(r"\[OUT\] 0101.*47"
|
||||||
|
"010102030404d2"
|
||||||
|
"017f000001...."
|
||||||
|
"02000000000000000000000000000000002607"
|
||||||
|
"04e00533f3e8f2aedaa8969b3d0fa03a96e857bbb28064dca5e147e934244b9ba50230032607")
|
||||||
|
return
|
||||||
|
|
||||||
# We should see it send node announce with all addresses (257 = 0x0101)
|
# We should see it send node announce with all addresses (257 = 0x0101)
|
||||||
# Note: local ephemeral port is masked out.
|
# Note: local ephemeral port is masked out.
|
||||||
# Note: Since we `disable-dns` it should not announce a resolved IPv4
|
# Note: Since we `disable-dns` it should not announce a resolved IPv4
|
||||||
|
@ -154,6 +170,7 @@ def test_announce_address(node_factory, bitcoind):
|
||||||
assert addresses_dns[1]['port'] == 1236
|
assert addresses_dns[1]['port'] == 1236
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "BOLT7 DNS RFC #911")
|
||||||
@pytest.mark.developer("gossip without DEVELOPER=1 is slow")
|
@pytest.mark.developer("gossip without DEVELOPER=1 is slow")
|
||||||
def test_announce_and_connect_via_dns(node_factory, bitcoind):
|
def test_announce_and_connect_via_dns(node_factory, bitcoind):
|
||||||
""" Test that DNS annoucements propagate and can be used when connecting.
|
""" Test that DNS annoucements propagate and can be used when connecting.
|
||||||
|
|
Loading…
Add table
Reference in a new issue