Skip to content

Commit d0a9707

Browse files
committed
Add option to ignore NS records in zone import, #6636
1 parent 2a367aa commit d0a9707

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

interface/web/dns/dns_import.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
$post_server_id = false;
7979
}
8080

81+
$ignore_ns_records = (isset($_POST['ignore_ns_records']))?$app->functions->intval($_POST['ignore_ns_records']):0;
8182

8283
// Load the templates
8384
$records = $app->db->queryAllRecords("SELECT * FROM dns_template WHERE visible = 'Y'");
@@ -322,7 +323,7 @@ function fqdn_name( $owner, $origin ) {
322323
$owner = $name;
323324
$r = 0;
324325
$dns_rr = array();
325-
$add_default_ns = TRUE;
326+
$ns_record_included = FALSE;
326327
$found_soa = FALSE;
327328
foreach($lines as $line){
328329

@@ -570,7 +571,12 @@ function fqdn_name( $owner, $origin ) {
570571
$dns_rr[$r]['type'] = strtoupper($resource_type);
571572

572573
if($dns_rr[$r]['type'] == 'NS' && fqdn_name( $dns_rr[$r]['name'], $soa['name'] ) == $soa['name']){
573-
$add_default_ns = FALSE;
574+
if ($ignore_ns_records) {
575+
unset($dns_rr[$r]);
576+
continue;
577+
} else {
578+
$ns_record_included = TRUE;
579+
}
574580
}
575581

576582
$dns_rr[$r]['ttl'] = $app->functions->intval($dns_rr[$r]['ttl']);
@@ -601,7 +607,7 @@ function fqdn_name( $owner, $origin ) {
601607
$i++;
602608
}
603609

604-
if ( $add_default_ns ) {
610+
if ( $ignore_ns_records || !$ns_record_included ) {
605611
foreach ($servers as $server){
606612
$dns_rr[$r]['name'] = $soa['name'];
607613
$dns_rr[$r]['type'] = 'NS';

interface/web/dns/lib/lang/en_dns_import.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ $wb['ignore_record_not_class_in'] = 'Ignoring DNS record, not class IN.';
2222
$wb['ignore_record_unknown_type'] = 'Ignoring DNS record, unknown type.';
2323
$wb['ignore_record_invalid_owner'] = 'Ignoring DNS record, not able to validate owner name.';
2424
$wb['zone_file_import_fail'] = 'The zone file did not import.';
25+
$wb['ignore_ns_records_txt'] = 'Ignore NS records';
2526
?>

interface/web/dns/templates/dns_import.htm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ <h1>
4646
<div class="col-sm-9 col-text">
4747
<tmpl_var name='domain_field_desc_txt' }</div>
4848
</div>
49+
<div class="form-group">
50+
<label class="col-sm-3 control-label">{tmpl_var name=ignore_ns_records_txt'}</label>
51+
<div class="col-sm-9">
52+
<input type="checkbox" id="ignore_ns_records" value="1" checked name="ignore_ns_records" />
53+
</div>
54+
</div>
55+
4956
<div class="form-group">
5057
<label for="file" class="col-sm-3 control-label">{tmpl_var name='zonefile_to_import_txt'}</label>
5158
<div class="col-sm-9 col-text"><input name="file" id="file" size="30" type="file" class="fileUpload" /></div>

0 commit comments

Comments
 (0)