Skip to content
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

Add Wildcard Record detection #6

Closed
junnlikestea opened this issue Oct 29, 2020 · 0 comments
Closed

Add Wildcard Record detection #6

junnlikestea opened this issue Oct 29, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@junnlikestea
Copy link
Owner

Currently the wildcard detection is just a naive check on the label of the record and isn't very effective.

let is_wildcard = record.name().is_wildcard();

The proposed implementation takes the contents of ResultsCache and appends a canary string to each record in the cache , then attempts to resolve it. If it resolves we mark it as a wildcard record. For example, we have some record named example.com we then add the canary cmVlc29sdmVjYW5hcnk.example.com and attempt to resolve that record.

reesolve/src/resolver.rs

Lines 278 to 282 in c8f023d

let wildcard = format!("{}.{}", CANARY, name);
if resolver.lookup_ip(wildcard).await.is_ok() {
info!("{} is wildcard record", &key);
// Only acquire the lock if we've found a wildcard
cache.set_wildcard(&key).await;

The cache.set_wildcard method just acquires the lock and modifies the is_wildcard to be true

reesolve/src/data.rs

Lines 49 to 59 in c8f023d

pub(crate) async fn set_wildcard(&self, key: &str) {
let mut lock = self.inner.lock().await;
if let Some(record) = lock.get_mut(key) {
if let ResolveResponse::IpRecord { is_wildcard, .. }
| ResolveResponse::Record { is_wildcard, .. } = record
{
*is_wildcard = true;
}
}
}

@junnlikestea junnlikestea added the enhancement New feature or request label Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant