Skip to content

Commit cf53ae1

Browse files
committed
Scan proxies in the background
1 parent 6f74c4c commit cf53ae1

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

root/dashboard/www/index.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
function GetHeader() {
33
return <<<HTML
4+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
45
<style type="text/css">
56
@import url("https://use.fontawesome.com/releases/v5.15.0/css/all.css");
67
.status-div {
@@ -52,7 +53,7 @@ function GetHeader() {
5253
}
5354

5455
function GetProxies() {
55-
$output = shell_exec("if test -f /lsiopy/bin/python3; then /lsiopy/bin/python3 /dashboard/swag-proxies.py; else python3 /dashboard/swag-proxies.py; fi");
56+
$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");
5657
$results = json_decode($output);
5758
$status = "";
5859
$index = 0;
@@ -89,8 +90,18 @@ function GetProxies() {
8990
}
9091
return <<<HTML
9192
<div class="wrap-panel status-div">
92-
<div>
93+
<div id="proxiesTable">
94+
<script>
95+
$.ajax({
96+
url : 'proxies.php',
97+
type: 'GET',
98+
success: function(data){
99+
$('#proxiesTable').html(data);
100+
}
101+
});
102+
</script>
93103
<h2>Proxies</h2>
104+
<h4>Scanning for unproxied containers ...</h4>
94105
<table class="table-hover">
95106
<thead>
96107
<tr>
@@ -342,7 +353,7 @@ function GetStats() {
342353
return array("proxied" => "$proxied", "auth" => "$auth", "outdated" => "$outdated", "banned" => "$banned");
343354
}
344355

345-
$stats = $_GET['stats'] == 'true' ? true : false;
356+
$stats = (isset($_GET['stats']) && $_GET['stats'] == 'true') ? true : false;
346357
if($stats) {
347358
$page = GetStats();
348359
header("Content-Type: application/json");

root/dashboard/www/proxies.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<h2>Proxies</h2>
2+
<table class="table-hover">
3+
<thead>
4+
<tr>
5+
<td><h3>Application</h3></td>
6+
<td><h3>Available</h3></td>
7+
<td><h3>Proxied</h3></td>
8+
<td><h3>Auth</h3></td>
9+
<td><h3>Location</h3></td>
10+
</tr>
11+
</thead>
12+
<tbody class="tbody-data">
13+
<?php
14+
$output = shell_exec("if test -f /lsiopy/bin/python3; then /lsiopy/bin/python3 /dashboard/swag-proxies.py; else python3 /dashboard/swag-proxies.py; fi");
15+
$results = json_decode($output);
16+
$status = "";
17+
$index = 0;
18+
foreach($results as $result => $data){
19+
$tr_class = ($index % 2 == 0) ? 'shaded' : '';
20+
$status .= '<tr class="'.$tr_class.'"><td class="left-text"><span class="status-text">'.$result.'</span></td><td class="align-td">';
21+
if ($data->status == 1) {
22+
$status .= '<i class="fas fa-check-circle"></i>';
23+
} else {
24+
$status .= '<i class="fas fa-exclamation-circle" title="The SWAG container can\'t reach '.$result.'"></i>';
25+
}
26+
$status .= '</td><td>';
27+
if (!empty($data->locations)) {
28+
$locations = $data->locations;
29+
$location = implode(",", $locations);
30+
$status .= '<i class="fas fa-check-circle"></i></td><td class="align-td">';
31+
$auths = implode(PHP_EOL, $data->auths);
32+
if ($data->auth_status == 1) {
33+
$status .= '<i class="fas fa-lock" title="'.$auths.'"></i>';
34+
} else {
35+
$status .= '<i class="fas fa-lock-open" title="'.$auths.'"></i>';
36+
}
37+
$status .= '</td><td class="left-text"><span class="status-text">'.$location.'</span></td>';
38+
} else {
39+
$error = 'Unable to locate the proxy config for '.$result.', it must use the following structure:'.PHP_EOL;
40+
$error .= '&#09;set $upstream_app <container/address>;'.PHP_EOL;
41+
$error .= '&#09;set $upstream_port <port>;'.PHP_EOL;
42+
$error .= '&#09;set $upstream_proto <protocol>;'.PHP_EOL;
43+
$error .= '&#09;proxy_pass $upstream_proto://$upstream_app:$upstream_port;'.PHP_EOL;
44+
$status .= '<i class="fas fa-exclamation-circle" title="'.$error.'"></i></td><td></td><td></td>';
45+
}
46+
$status .= '</tr>';
47+
$index++;
48+
}
49+
echo $status;
50+
?>
51+
</tbody>
52+
</table>
53+
<br/>

0 commit comments

Comments
 (0)