Skip to content

Commit ef46dd5

Browse files
committed
feat(dns): allow querying via cloudflare DNS
1 parent 544e9f8 commit ef46dd5

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ https-openssl = ["hyper-openssl", "openssl", "tower-layer"]
2424
https-rustls-webpki = ["hyper-rustls/webpki-roots"]
2525
https-rustls-native = ["hyper-rustls/rustls-native-certs"]
2626

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

29+
cloudflare = []
2930
google = []
3031
opendns = []
3132
myip-com = []

src/dns.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ pub const ALL: &dyn crate::Resolver<'static> = &&[
3636
OPENDNS,
3737
#[cfg(feature = "google")]
3838
GOOGLE,
39+
#[cfg(feature = "cloudflare")]
40+
CLOUDFLARE,
3941
];
4042

4143
/// Combined OpenDNS IPv4 and IPv6 options.
@@ -116,6 +118,41 @@ pub const GOOGLE_V6: &dyn crate::Resolver<'static> = &Resolver::new_static(
116118
DNSClass::IN,
117119
);
118120

121+
/// Combined Cloudflare DNS IPv4 and IPv6 options
122+
#[cfg(feature = "cloudflare")]
123+
#[cfg_attr(docsrs, doc(cfg(feature = "cloudflare")))]
124+
pub const CLOUDFLARE: &dyn crate::Resolver<'static> = &&[CLOUDFLARE_V4, CLOUDFLARE_V6];
125+
126+
/// Cloudflare DNS IPv4 DNS resolver options
127+
#[cfg(feature = "cloudflare")]
128+
#[cfg_attr(docsrs, doc(cfg(feature = "cloudflare")))]
129+
pub const CLOUDFLARE_V4: &dyn crate::Resolver<'static> = &Resolver::new_static(
130+
"whoami.cloudflare",
131+
&[
132+
IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)),
133+
IpAddr::V4(Ipv4Addr::new(1, 0, 0, 1)),
134+
],
135+
DEFAULT_DNS_PORT,
136+
QueryMethod::TXT,
137+
DNSClass::CH,
138+
);
139+
140+
/// Cloudflare DNS IPv6 DNS resolver options
141+
#[cfg(feature = "cloudflare")]
142+
#[cfg_attr(docsrs, doc(cfg(feature = "cloudflare")))]
143+
pub const CLOUDFLARE_V6: &dyn crate::Resolver<'static> = &Resolver::new_static(
144+
"whoami.cloudflare",
145+
&[
146+
// 2606:4700:4700::1111
147+
IpAddr::V6(Ipv6Addr::new(9734, 18176, 18176, 0, 0, 0, 0, 4369)),
148+
// 2606:4700:4700::1001
149+
IpAddr::V6(Ipv6Addr::new(9734, 18176, 18176, 0, 0, 0, 0, 4097)),
150+
],
151+
DEFAULT_DNS_PORT,
152+
QueryMethod::TXT,
153+
DNSClass::CH,
154+
);
155+
119156
///////////////////////////////////////////////////////////////////////////////
120157
// Error
121158

0 commit comments

Comments
 (0)