pub struct DomainVerifier { /* private fields */ }Expand description
DNS-based domain ownership verification service.
Checks TXT record ownership and CNAME routing via raw UDP DNS queries.
Construct with DomainVerifier::from_config. The struct is cheap to
clone because it wraps an Arc internally.
§Example
use modo::dns::{DnsConfig, DomainVerifier, generate_verification_token};
let config = DnsConfig::new("8.8.8.8:53");
let verifier = DomainVerifier::from_config(&config).unwrap();
let token = generate_verification_token();
// Ask the user to create: _modo-verify.example.com TXT "<token>"
// Then verify:
// let ok = verifier.check_txt("example.com", &token).await?;Implementations§
Source§impl DomainVerifier
impl DomainVerifier
Sourcepub fn from_config(config: &DnsConfig) -> Result<Self>
pub fn from_config(config: &DnsConfig) -> Result<Self>
Sourcepub async fn check_txt(
&self,
domain: &str,
expected_token: &str,
) -> Result<bool>
pub async fn check_txt( &self, domain: &str, expected_token: &str, ) -> Result<bool>
Check whether a TXT record matches the expected verification token.
Looks up {txt_prefix}.{domain} and returns true if any TXT record
value equals expected_token exactly (case-sensitive). Returns false
when the record exists but no value matches, or when no TXT records
exist (NXDOMAIN is treated as an empty record set, not an error).
§Errors
Returns crate::Error with status 400 when domain or
expected_token is empty, or a gateway error on network/DNS failure.
Sourcepub async fn check_cname(
&self,
domain: &str,
expected_target: &str,
) -> Result<bool>
pub async fn check_cname( &self, domain: &str, expected_target: &str, ) -> Result<bool>
Check whether a CNAME record points to the expected target.
Normalizes both the resolved target and expected_target before
comparing: both are lowercased and any trailing dot is stripped.
Returns false when no CNAME record is present.
§Errors
Returns crate::Error with status 400 when domain or
expected_target is empty, or a gateway error on network/DNS failure.
Sourcepub async fn verify_domain(
&self,
domain: &str,
expected_token: &str,
expected_cname: &str,
) -> Result<DomainStatus>
pub async fn verify_domain( &self, domain: &str, expected_token: &str, expected_cname: &str, ) -> Result<DomainStatus>
Check both TXT ownership and CNAME routing concurrently.
Runs check_txt and
check_cname in parallel via tokio::join!.
Returns DomainStatus with individual results.
§Errors
If either check returns a hard error (e.g. network failure) the error is propagated and the other result is discarded.