Deduplication for dns records

This commit is contained in:
Slatian 2023-02-25 12:08:46 +01:00
parent c1cd66782f
commit 9f3b6d0c17
2 changed files with 6 additions and 6 deletions

View File

@ -41,13 +41,13 @@ pub struct DnsLookupResult {
timeout: bool,
}
#[derive(serde::Deserialize, serde::Serialize, Clone)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq)]
pub struct MxRecord {
preference: u16,
exchange: String,
}
#[derive(serde::Deserialize, serde::Serialize, Clone)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq)]
pub struct SoaRecord {
mname: String,
rname: String,
@ -58,7 +58,7 @@ pub struct SoaRecord {
minimum: u32,
}
#[derive(serde::Deserialize, serde::Serialize, Clone)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq)]
pub struct SrvRecord {
priority: u16,
weight: u16,
@ -95,12 +95,12 @@ pub async fn reverse_lookup(
}
}
pub fn opush<T>(opt_vec: &mut Option<Vec<T>>, data: T) {
pub fn opush<T: std::cmp::PartialEq>(opt_vec: &mut Option<Vec<T>>, data: T) {
if opt_vec.is_none() {
*opt_vec = Some(Default::default());
}
match opt_vec {
Some(vec) => vec.push(data),
Some(vec) => if !vec.contains(&data) { vec.push(data) },
None => {},
}
}

View File

@ -41,7 +41,7 @@
{% if r.cname %}
<p>This domain has a cname set, this means its contents are full replaced by the linked record.</p>
<p class="button-paragraph">{{ helper::dig(extra=extra, name=r.cname[1]) }}</p>
<p class="button-paragraph">{{ helper::dig(extra=extra, name=r.cname[0]) }}</p>
</p>Usually you get the <code>A</code> and <code>AAAA</code> records for the linked record to avoid uneccessary requests. If anything else resolves, that is a violation of the DNS specification.</p>