8000 Dns/fix cname by howardjohn · Pull Request #1530 · istio/ztunnel · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Dns/fix cname #1530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

8000
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/dns/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ impl Store {
// '*.example.com'
// '*.com'
trace!(
alias=%alias.name,
"checking against wildcards {:#?}",
get_wildcards(&alias.name)
);
Expand All @@ -358,6 +359,7 @@ impl Store {
search_name.set_fqdn(false);
let search_name_str = search_name.to_string().into();
search_name.set_fqdn(true);
tracing::error!("howardjohn: lookup {search_name_str}...");

let service = state
.services
Expand All @@ -378,6 +380,7 @@ impl Store {
let domain = domain
.strip_suffix('.')
.expect("the svc domain must have a trailing '.'");
tracing::error!("howardjohn: svc hostname {} vs {}", service.hostname, domain);
!service.vips.is_empty() || service.hostname.ends_with(domain)
})
// Get the service matching the client namespace. If no match exists, just
Expand All @@ -387,6 +390,7 @@ impl Store {

// First, lookup the host as a service.
if let Some(service) = service {
tracing::error!("howardjohn: FOUND!");
return Some(ServerMatch {
server: Address::Service(service),
name: search_name,
Expand Down Expand Up @@ -564,7 +568,12 @@ impl Resolver for Store {
}
Err(e) => {
// Forwarding failed. Just return the error.
access_log(request, Some(&client), "forwarding failed", 0);
access_log(
request,
Some(&client),
&format!("forwarding failed ({e})"),
0,
);
return Err(e);
}
}
Expand All @@ -589,7 +598,12 @@ impl Resolver for Store {
}
Err(e) => {
// Forwarding failed. Just return the error.
access_log(request, Some(&client), "forwarding failed", 0);
access_log(
request,
Some(&client),
&format!("forwarding failed ({e})"),
0,
);
return Err(e);
}
}
Expand All @@ -602,6 +616,7 @@ impl Resolver for Store {
source: Some(&client),
});

trace!("found {:#?}", service_match);
// From this point on, we are the authority for the response.
let is_authoritative = true;

Expand Down Expand Up @@ -639,21 +654,21 @@ impl Resolver for Store {
// The match is a wildcard...

// Create a CNAME record that maps from the wildcard with the search domain to
// the wildcard without it.
// the wildcard witqhout it.
let cname_record_name = service_match
.name
.clone()
.append_domain(&stripped.search_domain)
.unwrap();
let canonical_name = service_match.name;
records.push(cname_record(cname_record_name, canonical_name));
records.push(dbg!(cname_record(cname_record_name, canonical_name)));

// For wildcards, continue using the original requested hostname for IP records.
} else {
// The match is NOT a wildcard...

// Create a CNAME record to map from the requested name -> stripped name.
let canonical_name = stripped.name;
let canonical_name = service_match.name;
records.push(cname_record(requested_name.clone(), canonical_name.clone()));

// Also use the stripped name as the IP record name.
Expand Down
0