]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Allow a `DNSResolverMessageHandler` to set `dns_resolver` feature 2024-10-dns-feature-flag
authorMatt Corallo <git@bluematt.me>
Wed, 2 Oct 2024 18:21:33 +0000 (18:21 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 2 Oct 2024 18:24:40 +0000 (18:24 +0000)
A `DNSResolverMessageHandler` which handles resolution requests
should want the `NodeFeatures` included in the node's
`node_announcement` to include `dns_resolver` to indicate to the
world that it provides that service. Here we enable this by
requesting extra feature flags from the `DNSResolverMessageHandler`
in the features `OnionMessenger`, in turn, provides to
`PeerManager` (which builds the `node_announcement`).

lightning/src/onion_message/dns_resolution.rs
lightning/src/onion_message/messenger.rs

index af133aa7ab43ea86849d5d249ab1e533fabf2277..bbf8caa4f71923b246bea86c39ef007b630919b7 100644 (file)
@@ -34,6 +34,8 @@ use dnssec_prover::validation::verify_rr_stream;
 
 use dnssec_prover::rr::Name;
 
+use lightning_types::features::NodeFeatures;
+
 use crate::blinded_path::message::DNSResolverContext;
 use crate::io;
 #[cfg(feature = "dnssec")]
@@ -67,6 +69,13 @@ pub trait DNSResolverMessageHandler {
        /// With this, we should be able to validate the DNS record we requested.
        fn handle_dnssec_proof(&self, message: DNSSECProof, context: DNSResolverContext);
 
+       /// Gets the node feature flags which this handler itself supports. Useful for setting the
+       /// `dns_resolver` flag if this handler supports returning [`DNSSECProof`] messages in response
+       /// to [`DNSSECQuery`] messages.
+       fn provided_node_features(&self) -> NodeFeatures {
+               NodeFeatures::empty()
+       }
+
        /// Release any [`DNSResolverMessage`]s that need to be sent.
        fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
                vec![]
index c531846912f4f293ae444ded2b528653650103be..0d7243193a35ca550b4b012c33cfcfd256070163 100644 (file)
@@ -1778,7 +1778,7 @@ where
        fn provided_node_features(&self) -> NodeFeatures {
                let mut features = NodeFeatures::empty();
                features.set_onion_messages_optional();
-               features
+               features | self.dns_resolver_handler.provided_node_features()
        }
 
        fn provided_init_features(&self, _their_node_id: PublicKey) -> InitFeatures {