diff --git a/src/idna.rs b/src/idna.rs index b3e40e6..39fb75f 100644 --- a/src/idna.rs +++ b/src/idna.rs @@ -14,7 +14,7 @@ pub enum NameType { Ascii, #[default] Unicode, - IDNA, + IDN, } // Note, that the @@ -23,7 +23,7 @@ pub struct IdnaName { pub unicode: String, // if null the unicode version only contains ascii range chars, // not neccessary to encode - pub idna: Option, + pub idn: Option, pub original_was: NameType, #[serde(skip_serializing_if = "Option::is_none")] pub decoder_error: Option, @@ -37,7 +37,7 @@ impl IdnaName { let unicode: String; let decoder_error; if s.starts_with("xn--") && s.is_ascii() { - original_was = NameType::IDNA; + original_was = NameType::IDN; let (uc, ures) = idna::domain_to_unicode(s); unicode = uc; decoder_error = ures.map_or_else(|e| Some(e.to_string()), |_| None); @@ -45,10 +45,10 @@ impl IdnaName { unicode = s.clone(); decoder_error = None; }; - let (idna, encoder_error) = match idna::domain_to_ascii_strict(s) { - Ok(idna) => { - if &idna != s || original_was == NameType::IDNA{ - (Some(idna), None) + let (idn, encoder_error) = match idna::domain_to_ascii(s) { + Ok(idn) => { + if &idn != s || original_was == NameType::IDN { + (Some(idn), None) } else { original_was = NameType::Ascii; (None, None) @@ -61,7 +61,7 @@ impl IdnaName { IdnaName { unicode: unicode, - idna: idna, + idn: idn, original_was: original_was, decoder_error: decoder_error, diff --git a/src/main.rs b/src/main.rs index f833bd6..587d70e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,7 @@ pub struct IpResult { pub struct DigResult { records: simple_dns::DnsLookupResult, #[serde(skip_serializing_if = "IdnaName::was_ascii")] - idna: IdnaName, + idn: IdnaName, } struct ServiceSharedState { @@ -487,9 +487,9 @@ async fn get_dig_result( DigResult { records: simple_dns::lookup( &state.dns_resolver, - &(idna_name.idna.clone().unwrap_or(name.to_owned())+"."), + &(idna_name.idn.clone().unwrap_or(name.to_owned())+"."), true).await, - idna: idna_name, + idn: idna_name, } } }