@@ -78,52 +78,12 @@ static void try_connect_one_addr(struct connecting *connect);
78
78
* timer to call a higher function again, so has to be pre-declared. */
79
79
static void try_connect_peer (struct daemon * daemon ,
80
80
const struct node_id * id ,
81
- struct wireaddr_internal * addrs TAKES ,
82
- bool dns_fallback );
81
+ struct wireaddr_internal * addrs TAKES );
83
82
84
83
/* We track peers which are important, and try to reconnect (with backoff) */
85
84
static void schedule_reconnect_if_important (struct daemon * daemon ,
86
85
const struct node_id * id );
87
86
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
-
127
87
/*~ Here we see our first tal destructor: in this case the 'struct connect'
128
88
* simply removes itself from the table of all 'connecting' structs. */
129
89
static void destroy_connecting (struct connecting * connect )
@@ -797,7 +757,7 @@ static void reconnect(struct important_id *imp)
797
757
append_gossmap_addresses (& addrs , imp -> daemon , & imp -> id );
798
758
799
759
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 ));
801
761
}
802
762
803
763
static void schedule_reconnect_if_important (struct daemon * daemon ,
@@ -1656,11 +1616,6 @@ static void connect_init(struct daemon *daemon, const u8 *msg)
1656
1616
} else
1657
1617
daemon -> proxyaddr = NULL ;
1658
1618
1659
- if (broken_resolver (daemon )) {
1660
- status_debug ("Broken DNS resolver detected, will check for "
1661
- "dummy replies" );
1662
- }
1663
-
1664
1619
/* Figure out our addresses. */
1665
1620
daemon -> listen_fds = setup_listeners (daemon , daemon ,
1666
1621
proposed_wireaddr ,
@@ -1798,39 +1753,6 @@ static const char **seednames(const tal_t *ctx, const struct node_id *id)
1798
1753
return seednames ;
1799
1754
}
1800
1755
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
-
1834
1756
static bool addr_in (const struct wireaddr_internal * needle ,
1835
1757
const struct wireaddr_internal haystack [])
1836
1758
{
@@ -1844,8 +1766,7 @@ static bool addr_in(const struct wireaddr_internal *needle,
1844
1766
/*~ Try to connect to a single peer, given some addresses (in order) */
1845
1767
static void try_connect_peer (struct daemon * daemon ,
1846
1768
const struct node_id * id ,
1847
- struct wireaddr_internal * addrs TAKES ,
1848
- bool dns_fallback )
1769
+ struct wireaddr_internal * addrs TAKES )
1849
1770
{
1850
1771
bool use_proxy = daemon -> always_use_proxy ;
1851
1772
struct connecting * connect ;
@@ -1886,14 +1807,11 @@ static void try_connect_peer(struct daemon *daemon,
1886
1807
chainparams_get_ln_port (chainparams ));
1887
1808
tal_arr_expand (& addrs , unresolved );
1888
1809
}
1889
- } else if (daemon -> use_dns && dns_fallback ) {
1890
- add_seed_addrs (& addrs , id ,
1891
- daemon -> broken_resolver_response );
1892
1810
}
1893
1811
}
1894
1812
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. */
1897
1815
if (tal_count (addrs ) == 0 ) {
1898
1816
connect_failed (daemon , id ,
1899
1817
CONNECT_NO_KNOWN_ADDRESS ,
@@ -1937,13 +1855,11 @@ static void connect_to_peer(struct daemon *daemon, const u8 *msg)
1937
1855
{
1938
1856
struct node_id id ;
1939
1857
struct wireaddr_internal * addrs ;
1940
- bool dns_fallback ;
1941
1858
bool transient ;
1942
1859
struct important_id * imp ;
1943
1860
1944
1861
if (!fromwire_connectd_connect_to_peer (tmpctx , msg ,
1945
1862
& id , & addrs ,
1946
- & dns_fallback ,
1947
1863
& transient ))
1948
1864
master_badmsg (WIRE_CONNECTD_CONNECT_TO_PEER , msg );
1949
1865
@@ -1983,7 +1899,7 @@ static void connect_to_peer(struct daemon *daemon, const u8 *msg)
1983
1899
/* Do gossmap lookup to find any addresses from there, and append. */
1984
1900
append_gossmap_addresses (& addrs , daemon , & id );
1985
1901
1986
- try_connect_peer (daemon , & id , addrs , dns_fallback );
1902
+ try_connect_peer (daemon , & id , addrs );
1987
1903
}
1988
1904
1989
1905
/* lightningd tells us a peer should be disconnected. */
0 commit comments