enhance MX validation; fix SRV validation
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -68,8 +68,29 @@ if ($action == 'add_record' && ! empty($_POST)) {
|
||||
$errors[] = $lng['error']['dns_arec_noipv4'];
|
||||
} elseif ($type == 'AAAA' && filter_var($content, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
|
||||
$errors[] = $lng['errors']['dns_aaaarec_noipv6'];
|
||||
} elseif ($type == 'MX' && empty($prio)) {
|
||||
$errors[] = $lng['error']['dns_mx_prioempty'];
|
||||
} elseif ($type == 'MX') {
|
||||
if ($prio === null || $prio < 0) {
|
||||
$errors[] = $lng['error']['dns_mx_prioempty'];
|
||||
}
|
||||
// check for trailing dot
|
||||
if (substr($content, - 1) == '.') {
|
||||
// remove it for checks
|
||||
$content = substr($content, 0, - 1);
|
||||
}
|
||||
if (! validateDomain($content)) {
|
||||
$errors[] = $lng['error']['dns_mx_needdom'];
|
||||
} else {
|
||||
// check whether there is a CNAME-record for the same resource
|
||||
foreach ($dom_entries as $existing_entries) {
|
||||
$fqdn = $existing_entries['record'] . '.' . $domain;
|
||||
if ($existing_entries['type'] == 'CNAME' && $fqdn == $content) {
|
||||
$errors[] = $lng['error']['dns_mx_noalias'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// append trailing dot (again)
|
||||
$content .= '.';
|
||||
} elseif ($type == 'CNAME') {
|
||||
// check for trailing dot
|
||||
if (substr($content, - 1) == '.') {
|
||||
@@ -103,14 +124,17 @@ if ($action == 'add_record' && ! empty($_POST)) {
|
||||
// remove it for checks
|
||||
$content = substr($content, 0, - 1);
|
||||
}
|
||||
//
|
||||
if (! validateDomain($content)) {
|
||||
// check only last part of content, as it can look like:
|
||||
// _service._proto.name. TTL class SRV priority weight port target.
|
||||
$_split_content = explode(" ", $content);
|
||||
$target = trim($_split_content[count($_split_content)-1]);
|
||||
if (! validateDomain($target)) {
|
||||
$errors[] = $lng['error']['dns_srv_needdom'];
|
||||
} else {
|
||||
// check whether there is a CNAME-record for the same resource
|
||||
foreach ($dom_entries as $existing_entries) {
|
||||
$fqdn = $existing_entries['record'] . '.' . $domain;
|
||||
if ($existing_entries['type'] == 'CNAME' && $fqdn == $content) {
|
||||
if ($existing_entries['type'] == 'CNAME' && $fqdn == $target) {
|
||||
$errors[] = $lng['error']['dns_srv_noalias'];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1989,3 +1989,16 @@ $lng['serversettings']['backupenabled']['description'] = "If activated, the cust
|
||||
$lng['extras']['path_protection_label'] = '<strong class="red">Important</strong>';
|
||||
$lng['extras']['path_protection_info'] = '<strong class="red">We strongly recommend protecting the given path, see "Extras" -> "Directory protection"</strong>';
|
||||
$lng['tasks']['backup_customerfiles'] = 'Backup job for customer %loginname%';
|
||||
|
||||
$lng['error']['dns_content_empty'] = 'No content given';
|
||||
$lng['error']['dns_arec_noipv4'] = 'No valid IP address for A-record given';
|
||||
$lng['error']['dns_mx_prioempty'] = 'Invalid MX priority given';
|
||||
$lng['error']['dns_mx_needdom'] = 'The MX content value must be a valid domain-name';
|
||||
$lng['error']['dns_mx_noalias'] = 'The MX-content value cannot be an CNAME entry.';
|
||||
$lng['error']['dns_cname_invaliddom'] = 'Invalid domain-name for CNAME record';
|
||||
$lng['error']['dns_cname_nomorerr'] = 'There already exists a resource-record with the same record-name. It cannot be used as CNAME.';
|
||||
$lng['error']['dns_srv_needdom'] = 'The SRV target value must be a valid domain-name';
|
||||
$lng['error']['dns_srv_noalias'] = 'The SRV-target value cannot be an CNAME entry.';
|
||||
$lng['error']['dns_duplicate_entry'] = 'Record already exists';
|
||||
$lng['success']['dns_record_added'] = 'Record added successfully';
|
||||
$lng['success']['dns_record_deleted'] = 'Record deleted successfully';
|
||||
|
||||
Reference in New Issue
Block a user