[Web] Add DNS diagnostics as modal, some minor fixes, todo: Detect IPv4/6 by multiple sources and random selection
parent
102b33d619
commit
34b7ab7104
|
@ -9,6 +9,27 @@ 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") {
|
||||||
|
|
||||||
|
$domains = mailbox('get', 'domains');
|
||||||
|
foreach(mailbox('get', 'domains') as $dn) {
|
||||||
|
$domains = array_merge($domains, mailbox('get', 'alias_domains', $dn));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['domain'])) {
|
||||||
|
if (is_valid_domain_name($_GET['domain'])) {
|
||||||
|
if (in_array($_GET['domain'], $domains)) {
|
||||||
|
$domain = $_GET['domain'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "No such domain in context";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "Invalid domain name";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$ch = curl_init('http://ip4.mailcow.email');
|
$ch = curl_init('http://ip4.mailcow.email');
|
||||||
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||||
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
curl_setopt($ch, CURLOPT_VERBOSE, false);
|
||||||
|
@ -53,10 +74,6 @@ if (!empty($ip6)) {
|
||||||
$records[] = array($mailcow_hostname, 'AAAA', $ip6);
|
$records[] = array($mailcow_hostname, 'AAAA', $ip6);
|
||||||
$records[] = array($ptr6, 'PTR', $mailcow_hostname);
|
$records[] = array($ptr6, 'PTR', $mailcow_hostname);
|
||||||
}
|
}
|
||||||
$domains = mailbox('get', 'domains');
|
|
||||||
foreach(mailbox('get', 'domains') as $domain) {
|
|
||||||
$domains = array_merge($domains, mailbox('get', 'alias_domains', $domain));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($autodiscover_config['sieve'])) {
|
if (!isset($autodiscover_config['sieve'])) {
|
||||||
$autodiscover_config['sieve'] = array('server' => $mailcow_hostname, 'port' => array_pop(explode(':', getenv('SIEVE_PORT'))));
|
$autodiscover_config['sieve'] = array('server' => $mailcow_hostname, 'port' => array_pop(explode(':', getenv('SIEVE_PORT'))));
|
||||||
|
@ -71,8 +88,6 @@ $records[] = array('_' . $autodiscover_config['smtp']['tlsport'] . '._tcp.' . $a
|
||||||
$records[] = array('_' . $autodiscover_config['imap']['port'] . '._tcp.' . $autodiscover_config['imap']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['port']));
|
$records[] = array('_' . $autodiscover_config['imap']['port'] . '._tcp.' . $autodiscover_config['imap']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['imap']['server'], $autodiscover_config['imap']['port']));
|
||||||
$records[] = array('_' . $autodiscover_config['pop3']['port'] . '._tcp.' . $autodiscover_config['pop3']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['port']));
|
$records[] = array('_' . $autodiscover_config['pop3']['port'] . '._tcp.' . $autodiscover_config['pop3']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['pop3']['server'], $autodiscover_config['pop3']['port']));
|
||||||
$records[] = array('_' . $autodiscover_config['sieve']['port'] . '._tcp.' . $autodiscover_config['sieve']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['sieve']['server'], $autodiscover_config['sieve']['port'], 1));
|
$records[] = array('_' . $autodiscover_config['sieve']['port'] . '._tcp.' . $autodiscover_config['sieve']['server'], 'TLSA', generate_tlsa_digest($autodiscover_config['sieve']['server'], $autodiscover_config['sieve']['port'], 1));
|
||||||
|
|
||||||
foreach ($domains as $domain) {
|
|
||||||
$records[] = array($domain, 'MX', $mailcow_hostname);
|
$records[] = array($domain, 'MX', $mailcow_hostname);
|
||||||
$records[] = array('autodiscover.' . $domain, 'CNAME', $mailcow_hostname);
|
$records[] = array('autodiscover.' . $domain, 'CNAME', $mailcow_hostname);
|
||||||
$records[] = array('_autodiscover._tcp.' . $domain, 'SRV', $mailcow_hostname . ' ' . $https_port);
|
$records[] = array('_autodiscover._tcp.' . $domain, 'SRV', $mailcow_hostname . ' ' . $https_port);
|
||||||
|
@ -115,7 +130,6 @@ foreach ($domains as $domain) {
|
||||||
if ($autodiscover_config['sieve']['port'] != '4190') {
|
if ($autodiscover_config['sieve']['port'] != '4190') {
|
||||||
$records[] = array('_sieve._tcp.' . $domain, 'SRV', $autodiscover_config['sieve']['server'] . ' ' . $autodiscover_config['sieve']['port']);
|
$records[] = array('_sieve._tcp.' . $domain, 'SRV', $autodiscover_config['sieve']['server'] . ' ' . $autodiscover_config['sieve']['port']);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$record_types = array(
|
$record_types = array(
|
||||||
'A' => DNS_A,
|
'A' => DNS_A,
|
||||||
|
@ -205,12 +219,11 @@ foreach ($records as $record) {
|
||||||
stripos($current['txt'], 'v=dmarc') === 0 &&
|
stripos($current['txt'], 'v=dmarc') === 0 &&
|
||||||
stripos($current['host'], '_dmarc') === 0) {
|
stripos($current['host'], '_dmarc') === 0) {
|
||||||
$current['txt'] = str_replace(' ', '', $current['txt']);
|
$current['txt'] = str_replace(' ', '', $current['txt']);
|
||||||
$state = state_optional . '<br />' . $current[$data_field[$current['type']]];
|
$state = $current[$data_field[$current['type']]] . state_optional;
|
||||||
}
|
}
|
||||||
elseif ($current['type'] == 'TXT' &&
|
elseif ($current['type'] == 'TXT' &&
|
||||||
stripos($current['host'], '_dmarc') !== 0 &&
|
|
||||||
stripos($current['txt'], 'v=spf') === 0) {
|
stripos($current['txt'], 'v=spf') === 0) {
|
||||||
$state = state_optional . '<br />' . $current[$data_field[$current['type']]];
|
$state = $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) {
|
||||||
|
@ -251,12 +264,12 @@ foreach ($records as $record) {
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
<sup>1</sup> Found A/AAAA record instead of a CNAME. This is supported as long as the A records destination points to the correct resource.<br />
|
<sup>1</sup> <?=$lang['diagnostics']['cname_from_a'];?><br />
|
||||||
<sup>2</sup> This record is optional.
|
<sup>2</sup> <?=$lang['diagnostics']['optional'];?>
|
||||||
</p>
|
</p>
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
header('Location: index.php');
|
echo "Session invalid";
|
||||||
exit();
|
die();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -188,7 +188,7 @@ $(document).ready(function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: '/inc/ajax/container_ctrl.php',
|
url: '/inc/ajax/container_ctrl.php',
|
||||||
timeout: 3000,
|
timeout: 10000,
|
||||||
data: {
|
data: {
|
||||||
'service': container,
|
'service': container,
|
||||||
'action': 'restart'
|
'action': 'restart'
|
||||||
|
|
|
@ -3,7 +3,7 @@ function init_db_schema() {
|
||||||
try {
|
try {
|
||||||
global $pdo;
|
global $pdo;
|
||||||
|
|
||||||
$db_version = "29112017_1515";
|
$db_version = "02012018_1515";
|
||||||
|
|
||||||
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
||||||
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||||
|
@ -540,12 +540,13 @@ function init_db_schema() {
|
||||||
"c_sn" => "VARCHAR(255)",
|
"c_sn" => "VARCHAR(255)",
|
||||||
"c_screenname" => "VARCHAR(255)",
|
"c_screenname" => "VARCHAR(255)",
|
||||||
"c_l" => "VARCHAR(255)",
|
"c_l" => "VARCHAR(255)",
|
||||||
"c_mail" => "VARCHAR(255)",
|
"c_mail" => "TEXT",
|
||||||
"c_o" => "VARCHAR(255)",
|
"c_o" => "VARCHAR(255)",
|
||||||
"c_ou" => "VARCHAR(255)",
|
"c_ou" => "VARCHAR(255)",
|
||||||
"c_telephonenumber" => "VARCHAR(255)",
|
"c_telephonenumber" => "VARCHAR(255)",
|
||||||
"c_categories" => "VARCHAR(255)",
|
"c_categories" => "VARCHAR(255)",
|
||||||
"c_component" => "VARCHAR(10) NOT NULL"
|
"c_component" => "VARCHAR(10) NOT NULL",
|
||||||
|
"c_hascertificate" => "INT4 DEFAULT 0"
|
||||||
),
|
),
|
||||||
"keys" => array(
|
"keys" => array(
|
||||||
"primary" => array(
|
"primary" => array(
|
||||||
|
@ -588,8 +589,8 @@ function init_db_schema() {
|
||||||
"sogo_user_profile" => array(
|
"sogo_user_profile" => array(
|
||||||
"cols" => array(
|
"cols" => array(
|
||||||
"c_uid" => "VARCHAR(255) NOT NULL",
|
"c_uid" => "VARCHAR(255) NOT NULL",
|
||||||
"c_defaults" => "TEXT",
|
"c_defaults" => "LONGTEXT",
|
||||||
"c_settings" => "TEXT"
|
"c_settings" => "LONGTEXT"
|
||||||
),
|
),
|
||||||
"keys" => array(
|
"keys" => array(
|
||||||
"primary" => array(
|
"primary" => array(
|
||||||
|
|
|
@ -58,6 +58,7 @@ $(document).ready(function() {
|
||||||
// Log modal
|
// Log modal
|
||||||
$('#dnsInfoModal').on('show.bs.modal', function(e) {
|
$('#dnsInfoModal').on('show.bs.modal', function(e) {
|
||||||
var domain = $(e.relatedTarget).data('domain');
|
var domain = $(e.relatedTarget).data('domain');
|
||||||
|
$('.dns-modal-body').html('<center><span style="font-size:18pt;margin:50px" class="glyphicon glyphicon-refresh glyphicon-spin"></span></center>');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/inc/ajax/dns_diagnostics.php',
|
url: '/inc/ajax/dns_diagnostics.php',
|
||||||
data: { domain: domain },
|
data: { domain: domain },
|
||||||
|
@ -443,7 +444,7 @@ jQuery(function($){
|
||||||
{"sorted": true,"name":"alias_domain","title":lang.alias,"style":{"width":"250px"}},
|
{"sorted": true,"name":"alias_domain","title":lang.alias,"style":{"width":"250px"}},
|
||||||
{"name":"target_domain","title":lang.target_domain},
|
{"name":"target_domain","title":lang.target_domain},
|
||||||
{"name":"active","filterable": false,"style":{"maxWidth":"50px","width":"70px"},"title":lang.active},
|
{"name":"active","filterable": false,"style":{"maxWidth":"50px","width":"70px"},"title":lang.active},
|
||||||
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"180px","width":"180px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
{"name":"action","filterable": false,"sortable": false,"style":{"text-align":"right","maxWidth":"250px","width":"250px"},"type":"html","title":lang.action,"breakpoints":"xs sm"}
|
||||||
],
|
],
|
||||||
"empty": lang.empty,
|
"empty": lang.empty,
|
||||||
"rows": $.ajax({
|
"rows": $.ajax({
|
||||||
|
@ -458,6 +459,7 @@ jQuery(function($){
|
||||||
item.action = '<div class="btn-group">' +
|
item.action = '<div class="btn-group">' +
|
||||||
'<a href="/edit.php?aliasdomain=' + encodeURI(item.alias_domain) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
|
'<a href="/edit.php?aliasdomain=' + encodeURI(item.alias_domain) + '" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-pencil"></span> ' + lang.edit + '</a>' +
|
||||||
'<a href="#" id="delete_selected" data-id="single-alias-domain" data-api-url="delete/alias-domain" data-item="' + encodeURI(item.alias_domain) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
'<a href="#" id="delete_selected" data-id="single-alias-domain" data-api-url="delete/alias-domain" data-item="' + encodeURI(item.alias_domain) + '" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span> ' + lang.remove + '</a>' +
|
||||||
|
'<a href="#dnsInfoModal" class="btn btn-xs btn-info" data-toggle="modal" data-domain="' + encodeURI(item.alias_domain) + '"><span class="glyphicon glyphicon-question-sign"></span> DNS</a></div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
item.chkbox = '<input type="checkbox" data-id="alias-domain" name="multi_select" value="' + item.alias_domain + '" />';
|
item.chkbox = '<input type="checkbox" data-id="alias-domain" name="multi_select" value="' + item.alias_domain + '" />';
|
||||||
});
|
});
|
||||||
|
|
|
@ -550,6 +550,8 @@ $lang['diagnostics']['dns_records_name'] = 'Name';
|
||||||
$lang['diagnostics']['dns_records_type'] = 'Typ';
|
$lang['diagnostics']['dns_records_type'] = 'Typ';
|
||||||
$lang['diagnostics']['dns_records_data'] = 'Korrekte Daten';
|
$lang['diagnostics']['dns_records_data'] = 'Korrekte Daten';
|
||||||
$lang['diagnostics']['dns_records_status'] = 'Aktueller Status';
|
$lang['diagnostics']['dns_records_status'] = 'Aktueller Status';
|
||||||
|
$lang['diagnostics']['optional'] = 'Dieser Eintrag ist optional.';
|
||||||
|
$lang['diagnostics']['cname_from_a'] = 'Wert abgeleitet von A/AAAA Eintrag. Wird unterstützt, sofern der Eintrag auf die korrekte Ressource zeigt.';
|
||||||
$lang['admin']['relay_from'] = "Absenderadresse";
|
$lang['admin']['relay_from'] = "Absenderadresse";
|
||||||
$lang['admin']['relay_run'] = "Test durchführen";
|
$lang['admin']['relay_run'] = "Test durchführen";
|
||||||
$lang['admin']['customize'] = "Anpassung";
|
$lang['admin']['customize'] = "Anpassung";
|
||||||
|
|
|
@ -552,6 +552,9 @@ $lang['diagnostics']['dns_records_name'] = 'Name';
|
||||||
$lang['diagnostics']['dns_records_type'] = 'Type';
|
$lang['diagnostics']['dns_records_type'] = 'Type';
|
||||||
$lang['diagnostics']['dns_records_data'] = 'Correct Data';
|
$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']['cname_from_a'] = 'Value derived from A/AAAA record. This is supported as long as the record points to the correct resource.';
|
||||||
|
|
||||||
$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";
|
||||||
$lang['admin']['api_key'] = "API key";
|
$lang['admin']['api_key'] = "API key";
|
||||||
|
|
Loading…
Reference in New Issue