Commit bc87933a authored by Elias Werberich's avatar Elias Werberich Committed by Franco Fichtner

RFC2136 RecordType Option

PR: https://github.com/opnsense/core/issues/1456

(cherry picked from commit fb7c4617)
(cherry picked from commit 2acd4595)
(cherry picked from commit 6e57f407)
parent 4b256e74
......@@ -1748,7 +1748,7 @@ EOD;
$need_update = false;
/* Update IPv4 if we have it. */
if (is_ipaddrv4($wanip)) {
if (is_ipaddrv4($wanip) && (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'A')) {
if (($wanip != $cachedipv4) || (($currentTime - $cacheTimev4) > $maxCacheAgeSecs) || $forced) {
$upinst .= "update delete {$dnsupdate['host']}. A\n";
$upinst .= "update add {$dnsupdate['host']}. {$dnsupdate['ttl']} A {$wanip}\n";
......@@ -1764,7 +1764,7 @@ EOD;
}
/* Update IPv6 if we have it. */
if (is_ipaddrv6($wanipv6)) {
if (is_ipaddrv6($wanipv6) && (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'AAAA')) {
if (($wanipv6 != $cachedipv6) || (($currentTime - $cacheTimev6) > $maxCacheAgeSecs) || $forced) {
$upinst .= "update delete {$dnsupdate['host']}. AAAA\n";
$upinst .= "update add {$dnsupdate['host']}. {$dnsupdate['ttl']} AAAA {$wanipv6}\n";
......
......@@ -140,7 +140,7 @@ $main_buttons = array(
<td>
<?php
$filename = "/conf/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
if (file_exists($filename) && !empty($rfc2136['enable'])) {
if (file_exists($filename) && !empty($rfc2136['enable']) && (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'A')) {
echo "IPv4: ";
if (isset($rfc2136['usepublicip'])) {
$ipaddr = dyndnsCheckIP($rfc2136['interface']);
......@@ -160,7 +160,7 @@ $main_buttons = array(
echo "IPv4: N/A";
}
echo "<br />";
if (file_exists("{$filename}.ipv6")) {
if (file_exists("{$filename}.ipv6") && !empty($rfc2136['enable']) && (empty($dnsupdate['recordtype']) || $dnsupdate['recordtype'] == 'AAAA')) {
echo "IPv6: ";
$ipaddr = get_interface_ipv6($rfc2136['interface']);
$cached_ip_s = explode("|", file_get_contents("{$filename}.ipv6"));
......
......@@ -46,6 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} else {
$pconfig['enable'] = true;
}
$pconfig['host'] = isset($id) && !empty($a_rfc2136[$id]['host']) ? $a_rfc2136[$id]['host'] : null;
$pconfig['ttl'] = isset($id) &&!empty($a_rfc2136[$id]['ttl']) ? $a_rfc2136[$id]['ttl'] : 60;
$pconfig['keydata'] = isset($id) &&!empty($a_rfc2136[$id]['keydata']) ? $a_rfc2136[$id]['keydata'] : null;
......@@ -54,6 +55,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['server'] = isset($id) &&!empty($a_rfc2136[$id]['server']) ? $a_rfc2136[$id]['server'] : null;
$pconfig['interface'] = isset($id) &&!empty($a_rfc2136[$id]['interface']) ? $a_rfc2136[$id]['interface'] : null;
$pconfig['descr'] = isset($id) &&!empty($a_rfc2136[$id]['descr']) ? $a_rfc2136[$id]['descr'] : null;
$pconfig['recordtype'] = isset($id) && !empty($a_rfc2136[$id]['recordtype']) ? $a_rfc2136[$id]['recordtype'] : null;
$pconfig['usetcp'] = isset($a_rfc2136[$id]['usetcp']);
$pconfig['usepublicip'] = isset($a_rfc2136[$id]['usepublicip']);
......@@ -96,6 +98,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$rfc2136['interface'] = $pconfig['interface'];
$rfc2136['descr'] = $pconfig['descr'];
if (!empty($pconfig['recordtype'])) {
$rfc2136['recordtype'] = $pconfig['recordtype'];
}
if (isset($id)) {
$a_rfc2136[$id] = $rfc2136;
} else {
......@@ -169,6 +175,17 @@ include("head.inc");
</div>
</td>
</tr>
<tr>
<td><a id="help_for_recordtype" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Record Type");?></td>
<td>
<input name="recordtype" type="radio" value="" <?= empty($pconfig['recordtype']) ? 'checked="checked"' : '' ?> /> <?=gettext('All');?> &nbsp;
<input name="recordtype" type="radio" value="A" <?= $pconfig['recordtype'] == 'A' ? 'checked="checked"' : '' ?> /> <?=gettext('A (IPv4)');?> &nbsp;
<input name="recordtype" type="radio" value="AAAA" <?= $pconfig['recordtype'] == 'AAAA' ? 'checked="checked"' : '' ?> /> <?=gettext('AAAA (IPv6)');?>
<div class="hidden" for="help_for_recordtype">
<?=gettext("'All' will update all available record types.");?>
</div>
</td>
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("TTL"); ?> (<?=gettext("seconds");?>)</td>
<td>
......@@ -189,7 +206,7 @@ include("head.inc");
<td>
<input name="keytype" type="radio" value="zone" <?= $pconfig['keytype'] == "zone" ? "checked=\"checked\"" :""; ?> /> <?=gettext("Zone");?> &nbsp;
<input name="keytype" type="radio" value="host" <?= $pconfig['keytype'] == "host" ? "checked=\"checked\"" :""; ?> /> <?=gettext("Host");?> &nbsp;
<input name="keytype" type="radio" value="user" <?= $pconfig['keytype'] == "user" ? "checked=\"checked\"" :""; ?> /> <?=gettext(" User");?>
<input name="keytype" type="radio" value="user" <?= $pconfig['keytype'] == "user" ? "checked=\"checked\"" :""; ?> /> <?=gettext("User");?>
</td>
</tr>
<tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment