Services: Unbound DNS: Overrides - add optional TTL field, closes https://github.com/opnsense/core/pull/7616

This commit is contained in:
Ad Schellevis 2025-03-22 10:30:37 +01:00
parent 01f364e1bd
commit 84f48985bf
3 changed files with 15 additions and 3 deletions

View File

@ -570,7 +570,7 @@ function unbound_add_host_entries($ifconfig_details)
/* Handle wildcard entries which have "*" as a hostname. Since we added a . above, we match on "*.". */
if ($alias['hostname'] == '*.') {
$unbound_entries .= "local-zone: \"{$alias['domain']}\" redirect\n";
$unbound_entries .= "local-data: \"{$alias['domain']} IN {$host->rr} {$host->server}\"\n";
$unbound_entries .= "local-data: \"{$alias['domain']} {$host->ttl} IN {$host->rr} {$host->server}\"\n";
} else {
if (($override_is_main || $tmp_aliases[0]['hostname'] === '*') && !in_array($host->server, $ptr_records, true)) {
/* Only generate a PTR record for the non-alias override and only if the IP is not already associated with a PTR.
@ -581,11 +581,11 @@ function unbound_add_host_entries($ifconfig_details)
} else {
syslog(LOG_WARNING, 'PTR record already exists for ' . $alias['hostname'] . $alias['domain'] . '(' . $host->server . ')');
}
$unbound_entries .= "local-data: \"{$alias['hostname']}{$alias['domain']} IN {$host->rr} {$host->server}\"\n";
$unbound_entries .= "local-data: \"{$alias['hostname']}{$alias['domain']} {$host->ttl} IN {$host->rr} {$host->server}\"\n";
}
break;
case 'MX':
$unbound_entries .= "local-data: \"{$alias['hostname']}{$alias['domain']} IN MX {$host->mxprio} {$host->mx}\"\n";
$unbound_entries .= "local-data: \"{$alias['hostname']}{$alias['domain']} {$host->ttl} IN MX {$host->mxprio} {$host->mx}\"\n";
break;
}

View File

@ -46,6 +46,12 @@
<visible>false</visible>
</grid_view>
</field>
<field>
<id>host.ttl</id>
<label>TTL (seconds)</label>
<type>text</type>
<help>TTL of the host, e.g. 3600</help>
</field>
<field>
<id>host.server</id>
<label>IP address</label>

View File

@ -343,6 +343,12 @@
</check001>
</Constraints>
</mx>
<ttl type="IntegerField">
<Required>N</Required>
<!-- https://datatracker.ietf.org/doc/html/rfc2181 -->
<MaximumValue>2147483647</MaximumValue>
<MinimumValue>0</MinimumValue>
</ttl>
<server type="NetworkField">
<Constraints>
<check001>