Skip to content

Commit bb3fcf3

Browse files
committed
chore: use EXPERIMENTAL for BOLT7 DNS #911
Changelog-EXPERIMENTAL: Ability to announce DNS addresses
1 parent 9c04a30 commit bb3fcf3

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

connectd/connectd.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,10 @@ static struct io_plan *conn_init(struct io_conn *conn,
874874
"Can't connect to forproxy address");
875875
break;
876876
case ADDR_INTERNAL_WIREADDR:
877+
#if EXPERIMENTAL_FEATURES /* BOLT7 DNS RFC #911 */
877878
/* DNS should have been resolved before */
878879
assert(addr->u.wireaddr.type != ADDR_TYPE_DNS);
880+
#endif
879881
/* If it was a Tor address, we wouldn't be here. */
880882
assert(!is_toraddr((char*)addr->u.wireaddr.addr));
881883
ai = wireaddr_to_addrinfo(tmpctx, &addr->u.wireaddr);
@@ -928,11 +930,13 @@ static void try_connect_one_addr(struct connecting *connect)
928930
bool use_proxy = connect->daemon->always_use_proxy;
929931
const struct wireaddr_internal *addr = &connect->addrs[connect->addrnum];
930932
struct io_conn *conn;
933+
#if EXPERIMENTAL_FEATURES /* BOLT7 DNS RFC #911 */
931934
struct addrinfo hints, *ais, *aii;
932935
struct wireaddr_internal addrhint;
933936
int gai_err;
934937
struct sockaddr_in *sa4;
935938
struct sockaddr_in6 *sa6;
939+
#endif
936940

937941
/* In case we fail without a connection, make destroy_io_conn happy */
938942
connect->conn = NULL;
@@ -983,6 +987,7 @@ static void try_connect_one_addr(struct connecting *connect)
983987
af = AF_INET6;
984988
break;
985989
case ADDR_TYPE_DNS:
990+
#if EXPERIMENTAL_FEATURES /* BOLT7 DNS RFC #911 */
986991
/* Resolve with getaddrinfo */
987992
memset(&hints, 0, sizeof(hints));
988993
hints.ai_socktype = SOCK_STREAM;
@@ -1019,6 +1024,7 @@ static void try_connect_one_addr(struct connecting *connect)
10191024
addr = &connect->addrs[connect->addrnum];
10201025
}
10211026
freeaddrinfo(ais);
1027+
#endif
10221028
goto next;
10231029
case ADDR_TYPE_WEBSOCKET:
10241030
af = -1;
@@ -1660,8 +1666,10 @@ static void add_seed_addrs(struct wireaddr_internal **addrs,
16601666
NULL, broken_reply, NULL);
16611667
if (new_addrs) {
16621668
for (size_t j = 0; j < tal_count(new_addrs); j++) {
1669+
#if EXPERIMENTAL_FEATURES /* BOLT7 DNS RFC #911 */
16631670
if (new_addrs[j].type == ADDR_TYPE_DNS)
16641671
continue;
1672+
#endif
16651673
struct wireaddr_internal a;
16661674
a.itype = ADDR_INTERNAL_WIREADDR;
16671675
a.u.wireaddr = new_addrs[j];

lightningd/options.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ static char *opt_add_addr_withtype(const char *arg,
221221
tal_arr_expand(&ld->proposed_wireaddr, wi);
222222
}
223223

224+
#if EXPERIMENTAL_FEATURES /* BOLT7 DNS RFC #911 */
224225
/* Add ADDR_TYPE_DNS to announce DNS hostnames */
225226
if (is_dnsaddr(address) && ala & ADDR_ANNOUNCE) {
226227
memset(&wi, 0, sizeof(wi));
@@ -234,6 +235,7 @@ static char *opt_add_addr_withtype(const char *arg,
234235
tal_arr_expand(&ld->proposed_listen_announce, ADDR_ANNOUNCE);
235236
tal_arr_expand(&ld->proposed_wireaddr, wi);
236237
}
238+
#endif
237239

238240
return NULL;
239241

tests/test_gossip.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from fixtures import TEST_NETWORK
55
from pyln.client import RpcError, Millisatoshi
66
from utils import (
7-
DEVELOPER, wait_for, TIMEOUT, only_one, sync_blockheight, expected_node_features, COMPAT
7+
DEVELOPER, wait_for, TIMEOUT, only_one, sync_blockheight,
8+
expected_node_features, COMPAT, EXPERIMENTAL_FEATURES
89
)
910

1011
import json
@@ -117,6 +118,13 @@ def test_announce_address(node_factory, bitcoind):
117118
'::'],
118119
'log-level': 'io',
119120
'dev-allow-localhost': None}
121+
if not EXPERIMENTAL_FEATURES: # BOLT7 DNS RFC #911
122+
opts = {'disable-dns': None, 'announce-addr':
123+
['4acth47i6kxnvkewtm6q7ib2s3ufpo5sqbsnzjpbi7utijcltosqemad.onion',
124+
'1.2.3.4:1234',
125+
'::'],
126+
'log-level': 'io',
127+
'dev-allow-localhost': None}
120128
l1, l2 = node_factory.get_nodes(2, opts=[opts, {}])
121129

122130
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
@@ -126,6 +134,14 @@ def test_announce_address(node_factory, bitcoind):
126134
l1.wait_channel_active(scid)
127135
l2.wait_channel_active(scid)
128136

137+
if not EXPERIMENTAL_FEATURES: # BOLT7 DNS RFC #911
138+
l1.daemon.wait_for_log(r"\[OUT\] 0101.*47"
139+
"010102030404d2"
140+
"017f000001...."
141+
"02000000000000000000000000000000002607"
142+
"04e00533f3e8f2aedaa8969b3d0fa03a96e857bbb28064dca5e147e934244b9ba50230032607")
143+
return
144+
129145
# We should see it send node announce with all addresses (257 = 0x0101)
130146
# Note: local ephemeral port is masked out.
131147
# Note: Since we `disable-dns` it should not announce a resolved IPv4
@@ -153,6 +169,7 @@ def test_announce_address(node_factory, bitcoind):
153169
assert addresses_dns[1]['port'] == 1236
154170

155171

172+
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "BOLT7 DNS RFC #911")
156173
@pytest.mark.developer("gossip without DEVELOPER=1 is slow")
157174
def test_announce_and_connect_via_dns(node_factory, bitcoind):
158175
""" Test that DNS annoucements propagate and can be used when connecting.

0 commit comments

Comments
 (0)