shift get_public_ips to json_api.php
This commit is contained in:
parent
ef70457a48
commit
3912fcb238
@ -47,21 +47,6 @@ foreach ($containers as $container => $container_info) {
|
|||||||
// get mailcow data
|
// get mailcow data
|
||||||
$hostname = getenv('MAILCOW_HOSTNAME');
|
$hostname = getenv('MAILCOW_HOSTNAME');
|
||||||
$timezone = getenv('TZ');
|
$timezone = getenv('TZ');
|
||||||
// get public ips
|
|
||||||
$curl = curl_init();
|
|
||||||
curl_setopt($curl, CURLOPT_URL, 'http://ipv4.mailcow.email');
|
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
curl_setopt($curl, CURLOPT_POST, 0);
|
|
||||||
$ipv4 = curl_exec($curl);
|
|
||||||
curl_setopt($curl, CURLOPT_URL, 'http://ipv6.mailcow.email');
|
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
curl_setopt($curl, CURLOPT_POST, 0);
|
|
||||||
$ipv6 = curl_exec($curl);
|
|
||||||
$ips = array(
|
|
||||||
"ipv4" => $ipv4,
|
|
||||||
"ipv6" => $ipv6
|
|
||||||
);
|
|
||||||
curl_close($curl);
|
|
||||||
|
|
||||||
$template = 'debug.twig';
|
$template = 'debug.twig';
|
||||||
$template_data = [
|
$template_data = [
|
||||||
@ -70,7 +55,6 @@ $template_data = [
|
|||||||
'hostname' => $hostname,
|
'hostname' => $hostname,
|
||||||
'timezone' => $timezone,
|
'timezone' => $timezone,
|
||||||
'license_guid' => license('guid'),
|
'license_guid' => license('guid'),
|
||||||
'ips' => $ips,
|
|
||||||
'solr_status' => $solr_status,
|
'solr_status' => $solr_status,
|
||||||
'solr_uptime' => round($solr_status['status']['dovecot-fts']['uptime'] / 1000 / 60 / 60),
|
'solr_uptime' => round($solr_status['status']['dovecot-fts']['uptime'] / 1000 / 60 / 60),
|
||||||
'clamd_status' => $clamd_status,
|
'clamd_status' => $clamd_status,
|
||||||
|
@ -47,7 +47,9 @@ $(document).ready(function() {
|
|||||||
if (mailcow_info.branch === "master"){
|
if (mailcow_info.branch === "master"){
|
||||||
check_update(mailcow_info.version_tag, mailcow_info.project_url);
|
check_update(mailcow_info.version_tag, mailcow_info.project_url);
|
||||||
}
|
}
|
||||||
update_container_stats()
|
// get public ips
|
||||||
|
get_public_ips();
|
||||||
|
update_container_stats();
|
||||||
});
|
});
|
||||||
jQuery(function($){
|
jQuery(function($){
|
||||||
if (localStorage.getItem("current_page") === null) {
|
if (localStorage.getItem("current_page") === null) {
|
||||||
@ -1218,6 +1220,20 @@ function update_container_stats(timeout=5){
|
|||||||
// run again in n seconds
|
// run again in n seconds
|
||||||
setTimeout(update_container_stats, timeout * 1000);
|
setTimeout(update_container_stats, timeout * 1000);
|
||||||
}
|
}
|
||||||
|
// get public ips
|
||||||
|
function get_public_ips(){
|
||||||
|
window.fetch("/api/v1/get/status/host/ip", {method:'GET',cache:'no-cache'}).then(function(response) {
|
||||||
|
return response.json();
|
||||||
|
}).then(function(data) {
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
if (data){
|
||||||
|
// display host ips
|
||||||
|
$("#host_ipv4").text(data.ipv4);
|
||||||
|
$("#host_ipv6").text(data.ipv6);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
// format hosts uptime seconds to readable string
|
// format hosts uptime seconds to readable string
|
||||||
function formatUptime(seconds){
|
function formatUptime(seconds){
|
||||||
seconds = Number(seconds);
|
seconds = Number(seconds);
|
||||||
|
@ -1506,8 +1506,28 @@ if (isset($_GET['query'])) {
|
|||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
case "host":
|
case "host":
|
||||||
$stats = docker("host_stats");
|
if (!$extra){
|
||||||
echo json_encode($stats);
|
$stats = docker("host_stats");
|
||||||
|
echo json_encode($stats);
|
||||||
|
}
|
||||||
|
else if ($extra == "ip") {
|
||||||
|
// get public ips
|
||||||
|
$curl = curl_init();
|
||||||
|
curl_setopt($curl, CURLOPT_URL, 'http://ipv4.mailcow.email');
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($curl, CURLOPT_POST, 0);
|
||||||
|
$ipv4 = curl_exec($curl);
|
||||||
|
curl_setopt($curl, CURLOPT_URL, 'http://ipv6.mailcow.email');
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($curl, CURLOPT_POST, 0);
|
||||||
|
$ipv6 = curl_exec($curl);
|
||||||
|
$ips = array(
|
||||||
|
"ipv4" => $ipv4,
|
||||||
|
"ipv6" => $ipv6
|
||||||
|
);
|
||||||
|
curl_close($curl);
|
||||||
|
echo json_encode($ips);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "version":
|
case "version":
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
|
@ -52,8 +52,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>IPs</td>
|
<td>IPs</td>
|
||||||
<td class="text-break">
|
<td class="text-break">
|
||||||
<span class="d-block">{{ ips.ipv4 }}</span>
|
<span class="d-block" id="host_ipv4">-</span>
|
||||||
<span class="d-block">{{ ips.ipv6 }}</span>
|
<span class="d-block" id="host_ipv6">-</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user