From a80abec4ff0f817d4892ce608ff6e3c074ee67b7 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 18 Dec 2024 16:47:15 +0100 Subject: [PATCH] refactor(connlib): remove unused branch in `match` (#7550) When deciding what to do with a certain DNS query, we check whether the domain name in question corresponds to any of the (wildcard) DNS resource addresses. If yes, we resolve it to the resource ID of that resource. The source of those resource IDs is the `dns_resources` map. If we have looked up a `ResourceId` in that map, it is impossible for it to not be "known" which means the branch deleted in this PR is completely redundant and already covered by the catch-all branch where `maybe_resource` is `None`. --- rust/connlib/tunnel/src/dns.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/rust/connlib/tunnel/src/dns.rs b/rust/connlib/tunnel/src/dns.rs index 884482ff9..023004fa1 100644 --- a/rust/connlib/tunnel/src/dns.rs +++ b/rust/connlib/tunnel/src/dns.rs @@ -268,10 +268,6 @@ impl StubResolver { Some(domain.clone()) } - fn knows_resource(&self, resource: &ResourceId) -> bool { - self.dns_resources.values().contains(resource) - } - /// Processes the incoming DNS query. /// /// Any errors will result in an immediate `SERVFAIL` response. @@ -323,9 +319,6 @@ impl StubResolver { let maybe_resource = self.match_resource_linear(&domain); let resource_records = match (qtype, maybe_resource) { - (_, Some(resource)) if !self.knows_resource(&resource) => { - return Ok(ResolveStrategy::Recurse) - } (Rtype::A, Some(resource)) => self.get_or_assign_a_records(domain.clone(), resource), (Rtype::AAAA, Some(resource)) => { self.get_or_assign_aaaa_records(domain.clone(), resource)