andre.peters 2018-01-16 12:37:48 +01:00
commit 1d34aa5064
2 changed files with 102 additions and 84 deletions

View File

@ -7,7 +7,7 @@ define('state_missing', '<span class="glyphicon glyphicon-remove text-danger"></
define('state_nomatch', "?"); define('state_nomatch', "?");
define('state_optional', " <sup>2</sup>"); define('state_optional', " <sup>2</sup>");
if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admin") { 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) { foreach(mailbox('get', 'domains') as $dn) {
@ -73,10 +73,12 @@ if (!isset($autodiscover_config['sieve'])) {
} }
// Init records array // Init records array
$spf_link = '<a href="http://www.openspf.org/SPF_Record_Syntax" target="_blank">SPF Record Syntax</a>'; $spf_link = '<a href="http://www.openspf.org/SPF_Record_Syntax" target="_blank">SPF Record Syntax</a><br />
<small>' . sprintf($lang['diagnostics']['allow'], $ip) . '<br />' . sprintf($lang['diagnostics']['allow'], $ip6) . '</small>';
$dmarc_link = '<a href="http://www.kitterman.com/dmarc/assistant.html" target="_blank">DMARC Assistant</a>'; $dmarc_link = '<a href="http://www.kitterman.com/dmarc/assistant.html" target="_blank">DMARC Assistant</a>';
$records = array(); $records = array();
if ($_SESSION['mailcow_cc_role'] == "admin") {
$records[] = array( $records[] = array(
$mailcow_hostname, $mailcow_hostname,
'A', 'A',
@ -105,45 +107,54 @@ $records[] = array(
generate_tlsa_digest($autodiscover_config['smtp']['server'], 25, 1) generate_tlsa_digest($autodiscover_config['smtp']['server'], 25, 1)
); );
$records[] = array( $records[] = array(
'_' . $https_port . '._tcp.' . $mailcow_hostname, '_'.$https_port.
'._tcp.'.$mailcow_hostname,
'TLSA', 'TLSA',
generate_tlsa_digest($mailcow_hostname, $https_port) generate_tlsa_digest($mailcow_hostname, $https_port)
); );
$records[] = array( $records[] = array(
'_' . $autodiscover_config['pop3']['tlsport'] . '._tcp.' . $autodiscover_config['pop3']['server'], '_'.$autodiscover_config['pop3']['tlsport'].
'._tcp.'.$autodiscover_config['pop3']['server'],
'TLSA', 'TLSA',
generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['tlsport'], 1) generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['tlsport'], 1)
); );
$records[] = array( $records[] = array(
'_' . $autodiscover_config['imap']['tlsport'] . '._tcp.' . $autodiscover_config['imap']['server'], '_'.$autodiscover_config['imap']['tlsport'].
'._tcp.'.$autodiscover_config['imap']['server'],
'TLSA', 'TLSA',
generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['tlsport'], 1) generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['tlsport'], 1)
); );
$records[] = array( $records[] = array(
'_' . $autodiscover_config['smtp']['port'] . '._tcp.' . $autodiscover_config['smtp']['server'], '_'.$autodiscover_config['smtp']['port'].
'._tcp.'.$autodiscover_config['smtp']['server'],
'TLSA', 'TLSA',
generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['port']) generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['port'])
); );
$records[] = array( $records[] = array(
'_' . $autodiscover_config['smtp']['tlsport'] . '._tcp.' . $autodiscover_config['smtp']['server'], '_'.$autodiscover_config['smtp']['tlsport'].
'._tcp.'.$autodiscover_config['smtp']['server'],
'TLSA', 'TLSA',
generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['tlsport'], 1) generate_tlsa_digest($autodiscover_config['smtp']['server'], $autodiscover_config['smtp']['tlsport'], 1)
); );
$records[] = array( $records[] = array(
'_' . $autodiscover_config['imap']['port'] . '._tcp.' . $autodiscover_config['imap']['server'], '_'.$autodiscover_config['imap']['port'].
'._tcp.'.$autodiscover_config['imap']['server'],
'TLSA', 'TLSA',
generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['port']) generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['port'])
); );
$records[] = array( $records[] = array(
'_' . $autodiscover_config['pop3']['port'] . '._tcp.' . $autodiscover_config['pop3']['server'], '_'.$autodiscover_config['pop3']['port'].
'._tcp.'.$autodiscover_config['pop3']['server'],
'TLSA', 'TLSA',
generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['port']) generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['port'])
); );
$records[] = array( $records[] = array(
'_' . $autodiscover_config['sieve']['port'] . '._tcp.' . $autodiscover_config['sieve']['server'], '_'.$autodiscover_config['sieve']['port'].
'._tcp.'.$autodiscover_config['sieve']['server'],
'TLSA', 'TLSA',
generate_tlsa_digest($autodiscover_config['sieve']['server'], $autodiscover_config['sieve']['port'], 1) generate_tlsa_digest($autodiscover_config['sieve']['server'], $autodiscover_config['sieve']['port'], 1)
); );
}
$records[] = array( $records[] = array(
$domain, $domain,
'MX', 'MX',
@ -157,7 +168,8 @@ $records[] = array(
$records[] = array( $records[] = array(
'_autodiscover._tcp.'.$domain, '_autodiscover._tcp.'.$domain,
'SRV', 'SRV',
$mailcow_hostname . ' ' . $https_port $mailcow_hostname.
' '.$https_port
); );
$records[] = array( $records[] = array(
'autoconfig.'.$domain, 'autoconfig.'.$domain,
@ -345,9 +357,14 @@ foreach ($records as $record) {
$state = $current[$data_field[$current['type']]] . state_optional; $state = $current[$data_field[$current['type']]] . state_optional;
} }
elseif ($current['type'] == 'TXT' && elseif ($current['type'] == 'TXT' &&
stripos($current['txt'], 'v=spf' && stripos($current['txt'], 'v=spf') === 0 &&
$record[2] == $spf_link) === 0) { $record[2] == $spf_link) {
$state = $current[$data_field[$current['type']]] . state_optional; $state = state_nomatch;
$rslt = get_spf_allowed_hosts($record[0]);
if(in_array($ip, $rslt) && in_array($ip6, $rslt)){
$state = state_good;
}
$state .= '<br />' . $current[$data_field[$current['type']]].state_optional;
} }
elseif ($current['type'] == 'TXT' && elseif ($current['type'] == 'TXT' &&
stripos($current['txt'], 'v=dkim') === 0 && stripos($current['txt'], 'v=dkim') === 0 &&

View File

@ -556,6 +556,7 @@ $lang['diagnostics']['dns_records_data'] = 'Correct Data';
$lang['diagnostics']['dns_records_status'] = 'Current State'; $lang['diagnostics']['dns_records_status'] = 'Current State';
$lang['diagnostics']['optional'] = 'This record is optional.'; $lang['diagnostics']['optional'] = 'This record is optional.';
$lang['diagnostics']['cname_from_a'] = 'Value derived from A/AAAA record. This is supported as long as the record points to the correct resource.'; $lang['diagnostics']['cname_from_a'] = 'Value derived from A/AAAA record. This is supported as long as the record points to the correct resource.';
$lang['diagnostics']['allow'] = 'Allow %s';
$lang['admin']['relay_from'] = '"From:" address'; $lang['admin']['relay_from'] = '"From:" address';
$lang['admin']['api_allow_from'] = "Allow API access from these IPs"; $lang['admin']['api_allow_from'] = "Allow API access from these IPs";