Skip to content

Commit

Permalink
feat(dns): allow querying via cloudflare DNS
Browse files Browse the repository at this point in the history
  • Loading branch information
jcgruenhage committed Jan 15, 2023
1 parent 544e9f8 commit f0f0e68
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ https-openssl = ["hyper-openssl", "openssl", "tower-layer"]
https-rustls-webpki = ["hyper-rustls/webpki-roots"]
https-rustls-native = ["hyper-rustls/rustls-native-certs"]

all-providers = ["google", "opendns", "ipify-org", "my-ip-io", "myip-com", "seeip-org"]
all-providers = ["cloudflare", "google", "opendns", "ipify-org", "my-ip-io", "myip-com", "seeip-org"]

cloudflare = []
google = []
opendns = []
myip-com = []
Expand Down
35 changes: 35 additions & 0 deletions src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,41 @@ pub const GOOGLE_V6: &dyn crate::Resolver<'static> = &Resolver::new_static(
DNSClass::IN,
);

/// Combined Cloudflare DNS IPv4 and IPv6 options
#[cfg(feature = "cloudflare")]
#[cfg_attr(docsrs, doc(cfg(feature = "cloudflare")))]
pub const CLOUDFLARE: &dyn crate::Resolver<'static> = &&[CLOUDFLARE_V4, CLOUDFLARE_V6];

/// Cloudflare DNS IPv4 DNS resolver options
#[cfg(feature = "cloudflare")]
#[cfg_attr(docsrs, doc(cfg(feature = "cloudflare")))]
pub const CLOUDFLARE_V4: &dyn crate::Resolver<'static> = &Resolver::new_static(
"whoami.cloudflare",
&[
IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)),
IpAddr::V4(Ipv4Addr::new(1, 0, 0, 1)),
],
DEFAULT_DNS_PORT,
QueryMethod::TXT,
DNSClass::CH,
);

/// Cloudflare DNS IPv6 DNS resolver options
#[cfg(feature = "cloudflare")]
#[cfg_attr(docsrs, doc(cfg(feature = "cloudflare")))]
pub const CLOUDFLARE_V6: &dyn crate::Resolver<'static> = &Resolver::new_static(
"whoami.cloudflare",
&[
// 2606:4700:4700::1111
IpAddr::V6(Ipv6Addr::new(9734, 18176, 18176, 0, 0, 0, 0, 4369)),
// 2606:4700:4700::1001
IpAddr::V6(Ipv6Addr::new(9734, 18176, 18176, 0, 0, 0, 0, 4097)),
],
DEFAULT_DNS_PORT,
QueryMethod::TXT,
DNSClass::CH,
);

///////////////////////////////////////////////////////////////////////////////
// Error

Expand Down

0 comments on commit f0f0e68

Please sign in to comment.