Update dns_diagnostics.php

This commit is contained in:
Michael Kuron 2018-10-15 20:53:41 +02:00 committed by GitHub
parent 89b0e3e0c6
commit 1bb618d563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,9 +10,11 @@ define('state_optional', " <sup>2</sup>");
if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "admin"|| $_SESSION['mailcow_cc_role'] == "domainadmin")) { if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "admin"|| $_SESSION['mailcow_cc_role'] == "domainadmin")) {
$domains = mailbox('get', 'domains'); $domains = mailbox('get', 'domains');
foreach(mailbox('get', 'domains') as $dn) { $alias_domains = array();
$domains = array_merge($domains, mailbox('get', 'alias_domains', $dn)); foreach($domains as $dn) {
$alias_domains = array_merge($alias_domains, mailbox('get', 'alias_domains', $dn));
} }
$domains = array_merge($domains, $alias_domains);
if (isset($_GET['domain'])) { if (isset($_GET['domain'])) {
if (is_valid_domain_name($_GET['domain'])) { if (is_valid_domain_name($_GET['domain'])) {
@ -105,76 +107,80 @@ if ($_SESSION['mailcow_cc_role'] == "admin") {
'TLSA', 'TLSA',
generate_tlsa_digest($autodiscover_config['smtp']['server'], 25, 1) generate_tlsa_digest($autodiscover_config['smtp']['server'], 25, 1)
); );
$records[] = array( if (!in_array($domain, $alias_domains)) {
'_'.$https_port. $records[] = array(
'._tcp.'.$mailcow_hostname, '_'.$https_port.
'TLSA', '._tcp.'.$mailcow_hostname,
generate_tlsa_digest($mailcow_hostname, $https_port) 'TLSA',
); generate_tlsa_digest($mailcow_hostname, $https_port)
$records[] = array( );
'_'.$autodiscover_config['pop3']['tlsport']. $records[] = array(
'._tcp.'.$autodiscover_config['pop3']['server'], '_'.$autodiscover_config['pop3']['tlsport'].
'TLSA', '._tcp.'.$autodiscover_config['pop3']['server'],
generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['tlsport'], 1) 'TLSA',
); generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['tlsport'], 1)
$records[] = array( );
'_'.$autodiscover_config['imap']['tlsport']. $records[] = array(
'._tcp.'.$autodiscover_config['imap']['server'], '_'.$autodiscover_config['imap']['tlsport'].
'TLSA', '._tcp.'.$autodiscover_config['imap']['server'],
generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['tlsport'], 1) 'TLSA',
); generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['tlsport'], 1)
$records[] = array( );
'_'.$autodiscover_config['smtp']['port']. $records[] = array(
'._tcp.'.$autodiscover_config['smtp']['server'], '_'.$autodiscover_config['smtp']['port'].
'TLSA', '._tcp.'.$autodiscover_config['smtp']['server'],
generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['port']) 'TLSA',
); generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['port'])
$records[] = array( );
'_'.$autodiscover_config['smtp']['tlsport']. $records[] = array(
'._tcp.'.$autodiscover_config['smtp']['server'], '_'.$autodiscover_config['smtp']['tlsport'].
'TLSA', '._tcp.'.$autodiscover_config['smtp']['server'],
generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['tlsport'], 1) 'TLSA',
); generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['tlsport'], 1)
$records[] = array( );
'_'.$autodiscover_config['imap']['port']. $records[] = array(
'._tcp.'.$autodiscover_config['imap']['server'], '_'.$autodiscover_config['imap']['port'].
'TLSA', '._tcp.'.$autodiscover_config['imap']['server'],
generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['port']) 'TLSA',
); generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['port'])
$records[] = array( );
'_'.$autodiscover_config['pop3']['port']. $records[] = array(
'._tcp.'.$autodiscover_config['pop3']['server'], '_'.$autodiscover_config['pop3']['port'].
'TLSA', '._tcp.'.$autodiscover_config['pop3']['server'],
generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['port']) 'TLSA',
); generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['port'])
$records[] = array( );
'_'.$autodiscover_config['sieve']['port']. $records[] = array(
'._tcp.'.$autodiscover_config['sieve']['server'], '_'.$autodiscover_config['sieve']['port'].
'TLSA', '._tcp.'.$autodiscover_config['sieve']['server'],
generate_tlsa_digest($autodiscover_config['sieve']['server'], $autodiscover_config['sieve']['port'], 1) 'TLSA',
); generate_tlsa_digest($autodiscover_config['sieve']['server'], $autodiscover_config['sieve']['port'], 1)
);
}
} }
$records[] = array( $records[] = array(
$domain, $domain,
'MX', 'MX',
$mailcow_hostname $mailcow_hostname
); );
$records[] = array( if (!in_array($domain, $alias_domains)) {
'autodiscover.'.$domain, $records[] = array(
'CNAME', 'autodiscover.'.$domain,
$mailcow_hostname 'CNAME',
); $mailcow_hostname
$records[] = array( );
'_autodiscover._tcp.'.$domain, $records[] = array(
'SRV', '_autodiscover._tcp.'.$domain,
$mailcow_hostname. 'SRV',
' '.$https_port $mailcow_hostname.
); ' '.$https_port
$records[] = array( );
'autoconfig.'.$domain, $records[] = array(
'CNAME', 'autoconfig.'.$domain,
$mailcow_hostname 'CNAME',
); $mailcow_hostname
);
}
$records[] = array( $records[] = array(
$domain, $domain,
'TXT', 'TXT',
@ -195,74 +201,76 @@ if (!empty($dkim = dkim('details', $domain))) {
$dkim['dkim_txt'] $dkim['dkim_txt']
); );
} }
$current_records = dns_get_record('_pop3._tcp.' . $domain, DNS_SRV); if (!in_array($domain, $alias_domains)) {
if (count($current_records) == 0 || $current_records[0]['target'] != '') { $current_records = dns_get_record('_pop3._tcp.' . $domain, DNS_SRV);
if ($autodiscover_config['pop3']['tlsport'] != '110') { if (count($current_records) == 0 || $current_records[0]['target'] != '') {
if ($autodiscover_config['pop3']['tlsport'] != '110') {
$records[] = array(
'_pop3._tcp.' . $domain,
'SRV',
$autodiscover_config['pop3']['server'] . ' ' . $autodiscover_config['pop3']['tlsport']
);
}
}
else {
$records[] = array( $records[] = array(
'_pop3._tcp.' . $domain, '_pop3._tcp.' . $domain,
'SRV', 'SRV',
$autodiscover_config['pop3']['server'] . ' ' . $autodiscover_config['pop3']['tlsport'] '. 0'
); );
} }
} $current_records = dns_get_record('_pop3s._tcp.' . $domain, DNS_SRV);
else { if (count($current_records) == 0 || $current_records[0]['target'] != '') {
$records[] = array( if ($autodiscover_config['pop3']['port'] != '995') {
'_pop3._tcp.' . $domain, $records[] = array(
'SRV', '_pop3s._tcp.' . $domain,
'. 0' 'SRV',
); $autodiscover_config['pop3']['server'] . ' ' . $autodiscover_config['pop3']['port']
} );
$current_records = dns_get_record('_pop3s._tcp.' . $domain, DNS_SRV); }
if (count($current_records) == 0 || $current_records[0]['target'] != '') { }
if ($autodiscover_config['pop3']['port'] != '995') { else {
$records[] = array( $records[] = array(
'_pop3s._tcp.' . $domain, '_pop3s._tcp.' . $domain,
'SRV', 'SRV',
$autodiscover_config['pop3']['server'] . ' ' . $autodiscover_config['pop3']['port'] '. 0'
);
}
if ($autodiscover_config['imap']['tlsport'] != '143') {
$records[] = array(
'_imap._tcp.' . $domain,
'SRV',
$autodiscover_config['imap']['server'] . ' ' . $autodiscover_config['imap']['tlsport']
);
}
if ($autodiscover_config['imap']['port'] != '993') {
$records[] = array(
'_imaps._tcp.' . $domain,
'SRV',
$autodiscover_config['imap']['server'] . ' ' . $autodiscover_config['imap']['port']
);
}
if ($autodiscover_config['smtp']['tlsport'] != '587') {
$records[] = array(
'_submission._tcp.' . $domain,
'SRV',
$autodiscover_config['smtp']['server'] . ' ' . $autodiscover_config['smtp']['tlsport']
);
}
if ($autodiscover_config['smtp']['port'] != '465') {
$records[] = array(
'_smtps._tcp.' . $domain,
'SRV',
$autodiscover_config['smtp']['server'] . ' ' . $autodiscover_config['smtp']['port']
);
}
if ($autodiscover_config['sieve']['port'] != '4190') {
$records[] = array(
'_sieve._tcp.' . $domain,
'SRV',
$autodiscover_config['sieve']['server'] . ' ' . $autodiscover_config['sieve']['port']
); );
} }
}
else {
$records[] = array(
'_pop3s._tcp.' . $domain,
'SRV',
'. 0'
);
}
if ($autodiscover_config['imap']['tlsport'] != '143') {
$records[] = array(
'_imap._tcp.' . $domain,
'SRV',
$autodiscover_config['imap']['server'] . ' ' . $autodiscover_config['imap']['tlsport']
);
}
if ($autodiscover_config['imap']['port'] != '993') {
$records[] = array(
'_imaps._tcp.' . $domain,
'SRV',
$autodiscover_config['imap']['server'] . ' ' . $autodiscover_config['imap']['port']
);
}
if ($autodiscover_config['smtp']['tlsport'] != '587') {
$records[] = array(
'_submission._tcp.' . $domain,
'SRV',
$autodiscover_config['smtp']['server'] . ' ' . $autodiscover_config['smtp']['tlsport']
);
}
if ($autodiscover_config['smtp']['port'] != '465') {
$records[] = array(
'_smtps._tcp.' . $domain,
'SRV',
$autodiscover_config['smtp']['server'] . ' ' . $autodiscover_config['smtp']['port']
);
}
if ($autodiscover_config['sieve']['port'] != '4190') {
$records[] = array(
'_sieve._tcp.' . $domain,
'SRV',
$autodiscover_config['sieve']['server'] . ' ' . $autodiscover_config['sieve']['port']
);
} }
$record_types = array( $record_types = array(