From 709aeee09dba3cbe6c4c9f0ba84e816d8cff15c0 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 10 Jul 2024 14:20:09 +0000 Subject: [PATCH] Drop offer request messages to update to latest spec/bLIP 32 --- src/lib.rs | 87 +----------------------------------------------------- 1 file changed, 1 insertion(+), 86 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4bc7996..e5d2240 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,8 +39,6 @@ use lightning::onion_message::messenger::Destination; pub enum ResolverMessages { DNSSECQuery(DNSSECQuery), DNSSECProof(DNSSECProof), - OfferRequest(OfferRequest), - OfferResponse(OfferResponse), } #[derive(Debug)] @@ -55,21 +53,6 @@ pub struct DNSSECProof { } const DNSSEC_PROOF_TYPE: u64 = 65538; -#[derive(Debug)] -pub struct OfferRequest { - pub user: String, - pub domain: String, -} -const OFFER_REQUEST_TYPE: u64 = 44; // XXX - -#[derive(Debug)] -pub struct OfferResponse { - pub user: String, - pub domain: String, - pub offer: Offer, -} -const OFFER_RESPONSE_TYPE: u64 = 45; // XXX - impl Writeable for ResolverMessages { fn write(&self, w: &mut W) -> Result<(), lightning::io::Error> { match self { @@ -82,19 +65,6 @@ impl Writeable for ResolverMessages { w.write_all(&name.as_str().as_bytes())?; proof.write(w) }, - Self::OfferRequest(OfferRequest { user, domain }) => { - (user.len() as u8).write(w)?; - w.write_all(&user.as_bytes())?; - (domain.len() as u8).write(w)?; - w.write_all(&domain.as_bytes()) - }, - Self::OfferResponse(OfferResponse { user, domain, offer }) => { - (user.len() as u8).write(w)?; - w.write_all(&user.as_bytes())?; - (domain.len() as u8).write(w)?; - w.write_all(&domain.as_bytes())?; - offer.to_string().write(w) - }, } } } @@ -128,22 +98,6 @@ impl ResolverMessages { let proof = Readable::read(buffer)?; Ok(Some(ResolverMessages::DNSSECProof(DNSSECProof { name, proof }))) }, - OFFER_REQUEST_TYPE => { - let user = read_byte_len_ascii_string(buffer)?; - let domain = read_byte_len_ascii_string(buffer)?; - Ok(Some(ResolverMessages::OfferRequest(OfferRequest { user, domain }))) - }, - OFFER_RESPONSE_TYPE => { - let user = read_byte_len_ascii_string(buffer)?; - let domain = read_byte_len_ascii_string(buffer)?; - let offer_string: String = Readable::read(buffer)?; - if !offer_string.is_ascii() { return Err(DecodeError::InvalidValue); } - if let Ok(offer) = Offer::from_str(&offer_string) { - Ok(Some(ResolverMessages::OfferResponse(OfferResponse { user, domain, offer }))) - } else { - Err(DecodeError::InvalidValue) - } - }, _ => Ok(None), } } @@ -154,8 +108,6 @@ impl OnionMessageContents for ResolverMessages { match self { ResolverMessages::DNSSECQuery(_) => DNSSEC_QUERY_TYPE, ResolverMessages::DNSSECProof(_) => DNSSEC_PROOF_TYPE, - ResolverMessages::OfferRequest(_) => OFFER_REQUEST_TYPE, - ResolverMessages::OfferResponse(_) => OFFER_RESPONSE_TYPE, } } } @@ -310,7 +262,6 @@ mod name_resolver { fn handle_custom_message(&self, msg: ResolverMessages) -> Option { match msg { ResolverMessages::DNSSECQuery(_) => {}, - ResolverMessages::OfferRequest(_) => {}, ResolverMessages::DNSSECProof(DNSSECProof { name: answer_name, proof }) => { let parsed_rrs = parse_rr_stream(&proof); let validated_rrs = @@ -370,35 +321,13 @@ mod name_resolver { } else { continue; }; - if k.eq_ignore_ascii_case("b12") { + if k.eq_ignore_ascii_case("lno") { if let Ok(offer) = Offer::from_str(v) { resolution_callback(Some(offer)); } else { resolution_callback(None); } return false; - } else if k.eq_ignore_ascii_case("omlookup") { - let data_hex = Vec::from_hex(v).map_err(|_| ()); - let request_path = data_hex - .and_then(|data| BlindedPath::read(&mut &data[..]) - .map_err(|_| ())); - let request_path = if let Ok(path) = request_path { - path - } else { - resolution_callback(None); - return false; - }; - let contents = ResolverMessages::OfferRequest(OfferRequest { - user: user.to_owned(), - domain: domain.to_owned(), - }); - let response = PendingOnionMessage { - contents, - destination: Destination::BlindedPath(request_path), - reply_path: Some(self.reply_path.clone()), - }; - self.pending_msgs.lock().unwrap().push(response); - return true; } } resolution_callback(None); @@ -409,20 +338,6 @@ mod name_resolver { }); } }, - ResolverMessages::OfferResponse(OfferResponse { user, domain, offer }) => { - let mut pending_resolves = self.pending_resolves.lock().unwrap(); - pending_resolves.retain_mut(|(_height, query, resolution_callback)| { - let (query_user, query_domain) = if let Some(r) = query.split_once("@") { - r - } else { - debug_assert!(false, "This should be checked before insertion"); - return false; - }; - if query_user != user || query_domain != domain { return true; } - resolution_callback(Some(offer.clone())); - false - }); - }, } None } -- 2.39.5