@@ -78,52 +78,12 @@ static void try_connect_one_addr(struct connecting *connect);
7878 * timer to call a higher function again, so has to be pre-declared. */
7979static void try_connect_peer (struct daemon * daemon ,
8080 const struct node_id * id ,
81- struct wireaddr_internal * addrs TAKES ,
82- bool dns_fallback );
81+ struct wireaddr_internal * addrs TAKES );
8382
8483/* We track peers which are important, and try to reconnect (with backoff) */
8584static void schedule_reconnect_if_important (struct daemon * daemon ,
8685 const struct node_id * id );
8786
88- /*~ Some ISP resolvers will reply with a dummy IP to queries that would otherwise
89- * result in an NXDOMAIN reply. This just checks whether we have one such
90- * resolver upstream and remembers its reply so we can try to filter future
91- * dummies out.
92- */
93- static bool broken_resolver (struct daemon * daemon )
94- {
95- struct addrinfo * addrinfo ;
96- struct addrinfo hints ;
97- const char * hostname = "nxdomain-test.doesntexist" ;
98- int err ;
99-
100- /* If they told us to never do DNS queries, don't even do this one and
101- * also not if we just say that we don't */
102- if (!daemon -> use_dns || daemon -> always_use_proxy ) {
103- daemon -> broken_resolver_response = NULL ;
104- return false;
105- }
106-
107- memset (& hints , 0 , sizeof (hints ));
108- hints .ai_family = AF_UNSPEC ;
109- hints .ai_socktype = SOCK_STREAM ;
110- hints .ai_protocol = 0 ;
111- hints .ai_flags = AI_ADDRCONFIG ;
112- err = getaddrinfo (hostname , tal_fmt (tmpctx , "%d" , 42 ),
113- & hints , & addrinfo );
114-
115- /*~ Note the use of tal_dup here: it is a memdup for tal, but it's
116- * type-aware so it's less error-prone. */
117- if (err == 0 ) {
118- daemon -> broken_resolver_response
119- = tal_dup (daemon , struct sockaddr , addrinfo -> ai_addr );
120- freeaddrinfo (addrinfo );
121- } else
122- daemon -> broken_resolver_response = NULL ;
123-
124- return daemon -> broken_resolver_response != NULL ;
125- }
126-
12787/*~ Here we see our first tal destructor: in this case the 'struct connect'
12888 * simply removes itself from the table of all 'connecting' structs. */
12989static void destroy_connecting (struct connecting * connect )
@@ -797,7 +757,7 @@ static void reconnect(struct important_id *imp)
797757 append_gossmap_addresses (& addrs , imp -> daemon , & imp -> id );
798758
799759 imp -> reconnect_timer = NULL ;
800- try_connect_peer (imp -> daemon , & imp -> id , take (addrs ), false );
760+ try_connect_peer (imp -> daemon , & imp -> id , take (addrs ));
801761}
802762
803763static void schedule_reconnect_if_important (struct daemon * daemon ,
@@ -1656,11 +1616,6 @@ static void connect_init(struct daemon *daemon, const u8 *msg)
16561616 } else
16571617 daemon -> proxyaddr = NULL ;
16581618
1659- if (broken_resolver (daemon )) {
1660- status_debug ("Broken DNS resolver detected, will check for "
1661- "dummy replies" );
1662- }
1663-
16641619 /* Figure out our addresses. */
16651620 daemon -> listen_fds = setup_listeners (daemon , daemon ,
16661621 proposed_wireaddr ,
@@ -1798,39 +1753,6 @@ static const char **seednames(const tal_t *ctx, const struct node_id *id)
17981753 return seednames ;
17991754}
18001755
1801- /*~ As a last resort, we do a DNS lookup to the lightning DNS seed to
1802- * resolve a node name when they say to connect to it. This is synchronous,
1803- * so connectd blocks, but it's not very common so we haven't fixed it.
1804- *
1805- * This "seed by DNS" approach is similar to what bitcoind uses, and in fact
1806- * has the nice property that DNS is cached, and the seed only sees a request
1807- * from the ISP, not directly from the user. */
1808- static void add_seed_addrs (struct wireaddr_internal * * addrs ,
1809- const struct node_id * id ,
1810- struct sockaddr * broken_reply )
1811- {
1812- struct wireaddr * new_addrs ;
1813- const char * * hostnames = seednames (tmpctx , id );
1814-
1815- for (size_t i = 0 ; i < tal_count (hostnames ); i ++ ) {
1816- status_peer_debug (id , "Resolving %s" , hostnames [i ]);
1817- new_addrs = wireaddr_from_hostname (tmpctx , hostnames [i ], chainparams_get_ln_port (chainparams ),
1818- NULL , broken_reply , NULL );
1819- if (new_addrs ) {
1820- for (size_t j = 0 ; j < tal_count (new_addrs ); j ++ ) {
1821- if (new_addrs [j ].type == ADDR_TYPE_DNS )
1822- continue ;
1823- status_peer_debug (id , "Resolved %s to %s" , hostnames [i ],
1824- fmt_wireaddr (tmpctx , & new_addrs [j ]));
1825- append_addr (addrs , & new_addrs [j ]);
1826- }
1827- /* Other seeds will likely have the same information. */
1828- return ;
1829- } else
1830- status_peer_debug (id , "Could not resolve %s" , hostnames [i ]);
1831- }
1832- }
1833-
18341756static bool addr_in (const struct wireaddr_internal * needle ,
18351757 const struct wireaddr_internal haystack [])
18361758{
@@ -1844,8 +1766,7 @@ static bool addr_in(const struct wireaddr_internal *needle,
18441766/*~ Try to connect to a single peer, given some addresses (in order) */
18451767static void try_connect_peer (struct daemon * daemon ,
18461768 const struct node_id * id ,
1847- struct wireaddr_internal * addrs TAKES ,
1848- bool dns_fallback )
1769+ struct wireaddr_internal * addrs TAKES )
18491770{
18501771 bool use_proxy = daemon -> always_use_proxy ;
18511772 struct connecting * connect ;
@@ -1886,14 +1807,11 @@ static void try_connect_peer(struct daemon *daemon,
18861807 chainparams_get_ln_port (chainparams ));
18871808 tal_arr_expand (& addrs , unresolved );
18881809 }
1889- } else if (daemon -> use_dns && dns_fallback ) {
1890- add_seed_addrs (& addrs , id ,
1891- daemon -> broken_resolver_response );
18921810 }
18931811 }
18941812
1895- /* Still no address? Fail immediately. Lightningd can still choose
1896- * to retry ; an address may get gossiped or appear on the DNS seed . */
1813+ /* Still no address? Fail immediately. Important ones get
1814+ * retried ; an address may get gossiped. */
18971815 if (tal_count (addrs ) == 0 ) {
18981816 connect_failed (daemon , id ,
18991817 CONNECT_NO_KNOWN_ADDRESS ,
@@ -1937,13 +1855,11 @@ static void connect_to_peer(struct daemon *daemon, const u8 *msg)
19371855{
19381856 struct node_id id ;
19391857 struct wireaddr_internal * addrs ;
1940- bool dns_fallback ;
19411858 bool transient ;
19421859 struct important_id * imp ;
19431860
19441861 if (!fromwire_connectd_connect_to_peer (tmpctx , msg ,
19451862 & id , & addrs ,
1946- & dns_fallback ,
19471863 & transient ))
19481864 master_badmsg (WIRE_CONNECTD_CONNECT_TO_PEER , msg );
19491865
@@ -1983,7 +1899,7 @@ static void connect_to_peer(struct daemon *daemon, const u8 *msg)
19831899 /* Do gossmap lookup to find any addresses from there, and append. */
19841900 append_gossmap_addresses (& addrs , daemon , & id );
19851901
1986- try_connect_peer (daemon , & id , addrs , dns_fallback );
1902+ try_connect_peer (daemon , & id , addrs );
19871903}
19881904
19891905/* lightningd tells us a peer should be disconnected. */
0 commit comments