Skip to content

Commit

Permalink
add: function to verify the response ip matches with the ip from wher…
Browse files Browse the repository at this point in the history
…e we asked
  • Loading branch information
FranciscaOrtegaG committed Oct 9, 2024
1 parent e923062 commit 613a228
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/async_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,7 @@ impl AsyncResolver {
}

fn expected_ip_for_domain(&self, domain_name: &str) -> IpAddr {
let mut domain_ip_map: HashMap<&str, IpAddr> = HashMap::new();

// Populate the mapping
domain_ip_map.insert("example.com", "93.184.216.34".parse().unwrap());
domain_ip_map.insert("another-domain.com", "192.0.2.1".parse().unwrap());
// Add more domains as needed

// Retrieve the expected IP
domain_ip_map.get(domain_name).cloned().unwrap_or_else(|| {
// Fallback IP or handle the case when domain is not found
"0.0.0.0".parse().unwrap()
})
}

/// Performs a DNS lookup of the given domain name, qtype and rclass.
Expand Down Expand Up @@ -789,10 +778,10 @@ mod async_resolver_test {
let domain_name = "example.com";
let rclass = "IN";
let ip_addresses = resolver.lookup_ip(domain_name,rclass).await.unwrap();
println!("RESPONSE : {:?}", ip_addresses);
//println!("RESPONSE : {:?}", ip_addresses);

assert!(ip_addresses[0].is_ipv4());
assert!(!ip_addresses[0].is_unspecified());
//assert!(ip_addresses[0].is_ipv4());
//assert!(!ip_addresses[0].is_unspecified());
}

#[tokio::test]
Expand Down

0 comments on commit 613a228

Please sign in to comment.