Skip to content

Commit

Permalink
Make cname config optional
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hellhake authored and benfrancis committed Oct 22, 2024
1 parent df8c5ca commit cc65a04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct PdnsOptions {
pub mx_records: Vec<(String,String)>,
pub ns_records: Vec<Vec<String>>,
pub txt_records: Vec<Vec<String>>,
pub cname_records: Vec<Vec<String>>,
pub cname_records: Option<Vec<Vec<String>>>,
pub soa_record: String,
pub www_addresses: Vec<String>,
pub geoip: GeoIp,
Expand Down
24 changes: 13 additions & 11 deletions src/pdns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,19 @@ fn build_config_cname_response(
) -> Vec<PdnsLookupResponse> {
let sanitized_qname = remove_trailing_dot(qname);
let mut records = vec![];
for cname in &config.options.pdns.cname_records {
if cname[0] == sanitized_qname {
records.push(PdnsLookupResponse {
qtype: "CNAME".to_owned(),
qname: qname.to_owned(),
content: cname[1].to_owned(),
ttl: config.options.pdns.dns_ttl,
domain_id: None,
scope_mask: None,
auth: None,
});
if let Some(cname_records) = &config.options.pdns.cname_records {
for cname in cname_records {
if cname[0] == sanitized_qname {
records.push(PdnsLookupResponse {
qtype: "CNAME".to_owned(),
qname: qname.to_owned(),
content: cname[1].to_owned(),
ttl: config.options.pdns.dns_ttl,
domain_id: None,
scope_mask: None,
auth: None,
});
}
}
}

Expand Down

0 comments on commit cc65a04

Please sign in to comment.