mirror of
https://github.com/linuxserver/docker-mods.git
synced 2026-02-04 20:49:31 +08:00
Scan proxies in the background
This commit is contained in:
parent
6f74c4c7f9
commit
cf53ae1807
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
function GetHeader() {
|
||||
return <<<HTML
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||
<style type="text/css">
|
||||
@import url("https://use.fontawesome.com/releases/v5.15.0/css/all.css");
|
||||
.status-div {
|
||||
@ -52,7 +53,7 @@
|
||||
}
|
||||
|
||||
function GetProxies() {
|
||||
$output = shell_exec("if test -f /lsiopy/bin/python3; then /lsiopy/bin/python3 /dashboard/swag-proxies.py; else python3 /dashboard/swag-proxies.py; fi");
|
||||
$output = shell_exec("if test -f /lsiopy/bin/python3; then /lsiopy/bin/python3 /dashboard/swag-proxies.py fast; else python3 /dashboard/swag-proxies.py fast; fi");
|
||||
$results = json_decode($output);
|
||||
$status = "";
|
||||
$index = 0;
|
||||
@ -89,8 +90,18 @@
|
||||
}
|
||||
return <<<HTML
|
||||
<div class="wrap-panel status-div">
|
||||
<div>
|
||||
<div id="proxiesTable">
|
||||
<script>
|
||||
$.ajax({
|
||||
url : 'proxies.php',
|
||||
type: 'GET',
|
||||
success: function(data){
|
||||
$('#proxiesTable').html(data);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<h2>Proxies</h2>
|
||||
<h4>Scanning for unproxied containers ...</h4>
|
||||
<table class="table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -342,7 +353,7 @@
|
||||
return array("proxied" => "$proxied", "auth" => "$auth", "outdated" => "$outdated", "banned" => "$banned");
|
||||
}
|
||||
|
||||
$stats = $_GET['stats'] == 'true' ? true : false;
|
||||
$stats = (isset($_GET['stats']) && $_GET['stats'] == 'true') ? true : false;
|
||||
if($stats) {
|
||||
$page = GetStats();
|
||||
header("Content-Type: application/json");
|
||||
|
||||
53
root/dashboard/www/proxies.php
Normal file
53
root/dashboard/www/proxies.php
Normal file
@ -0,0 +1,53 @@
|
||||
<h2>Proxies</h2>
|
||||
<table class="table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><h3>Application</h3></td>
|
||||
<td><h3>Available</h3></td>
|
||||
<td><h3>Proxied</h3></td>
|
||||
<td><h3>Auth</h3></td>
|
||||
<td><h3>Location</h3></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="tbody-data">
|
||||
<?php
|
||||
$output = shell_exec("if test -f /lsiopy/bin/python3; then /lsiopy/bin/python3 /dashboard/swag-proxies.py; else python3 /dashboard/swag-proxies.py; fi");
|
||||
$results = json_decode($output);
|
||||
$status = "";
|
||||
$index = 0;
|
||||
foreach($results as $result => $data){
|
||||
$tr_class = ($index % 2 == 0) ? 'shaded' : '';
|
||||
$status .= '<tr class="'.$tr_class.'"><td class="left-text"><span class="status-text">'.$result.'</span></td><td class="align-td">';
|
||||
if ($data->status == 1) {
|
||||
$status .= '<i class="fas fa-check-circle"></i>';
|
||||
} else {
|
||||
$status .= '<i class="fas fa-exclamation-circle" title="The SWAG container can\'t reach '.$result.'"></i>';
|
||||
}
|
||||
$status .= '</td><td>';
|
||||
if (!empty($data->locations)) {
|
||||
$locations = $data->locations;
|
||||
$location = implode(",", $locations);
|
||||
$status .= '<i class="fas fa-check-circle"></i></td><td class="align-td">';
|
||||
$auths = implode(PHP_EOL, $data->auths);
|
||||
if ($data->auth_status == 1) {
|
||||
$status .= '<i class="fas fa-lock" title="'.$auths.'"></i>';
|
||||
} else {
|
||||
$status .= '<i class="fas fa-lock-open" title="'.$auths.'"></i>';
|
||||
}
|
||||
$status .= '</td><td class="left-text"><span class="status-text">'.$location.'</span></td>';
|
||||
} else {
|
||||
$error = 'Unable to locate the proxy config for '.$result.', it must use the following structure:'.PHP_EOL;
|
||||
$error .= '	set $upstream_app <container/address>;'.PHP_EOL;
|
||||
$error .= '	set $upstream_port <port>;'.PHP_EOL;
|
||||
$error .= '	set $upstream_proto <protocol>;'.PHP_EOL;
|
||||
$error .= '	proxy_pass $upstream_proto://$upstream_app:$upstream_port;'.PHP_EOL;
|
||||
$status .= '<i class="fas fa-exclamation-circle" title="'.$error.'"></i></td><td></td><td></td>';
|
||||
}
|
||||
$status .= '</tr>';
|
||||
$index++;
|
||||
}
|
||||
echo $status;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
Loading…
x
Reference in New Issue
Block a user