mirror of
https://github.com/TrezOne/docker-mods-uptime-kuma-timeout-fix.git
synced 2026-07-10 01:43:49 -04:00
Add fail2ban to the dashboard
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
import json
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
|
|
||||||
|
con = sqlite3.connect("/config/fail2ban/fail2ban.sqlite3")
|
||||||
|
cur = con.cursor()
|
||||||
|
results = cur.execute("SELECT jails.name, COUNT(bans.ip) AS bans FROM jails LEFT JOIN bans ON jails.name=bans.jail GROUP BY jails.name").fetchall()
|
||||||
|
con.close()
|
||||||
|
output = json.dumps({k:v for (k,v) in results}, sort_keys=True)
|
||||||
|
print(output)
|
||||||
@@ -19,10 +19,10 @@ def find_apps():
|
|||||||
results = re.finditer(r"(\s+)set \$upstream_app (?P<name>\S+?);.*\n(\s+)set \$upstream_port (?P<port>\d+);.*\n(\s+)set \$upstream_proto (?P<proto>\w+);.*", content)
|
results = re.finditer(r"(\s+)set \$upstream_app (?P<name>\S+?);.*\n(\s+)set \$upstream_port (?P<port>\d+);.*\n(\s+)set \$upstream_proto (?P<proto>\w+);.*", content)
|
||||||
for result in results:
|
for result in results:
|
||||||
params = result.groupdict()
|
params = result.groupdict()
|
||||||
app = f"{params['proto']}://{params['name']}:{params['port']}"
|
app = f"{params['proto']}://{params['name']}:{params['port']}/"
|
||||||
if app not in apps:
|
if app not in apps:
|
||||||
apps[app] = set()
|
apps[app] = set()
|
||||||
if not file_path.endswith(".sample"):
|
if file_path.startswith("/config/nginx/site-confs/") or file_path.endswith(".conf"):
|
||||||
apps[app].add(file_path)
|
apps[app].add(file_path)
|
||||||
return apps
|
return apps
|
||||||
|
|
||||||
@@ -1,32 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
function GetStatus() {
|
function GetHeader() {
|
||||||
$output = shell_exec("python3 /dashboard/swag-status.py");
|
|
||||||
$results = json_decode($output);
|
|
||||||
$status = "";
|
|
||||||
$index = 0;
|
|
||||||
foreach($results as $result => $data){
|
|
||||||
$tr_class = ($index % 2 == 0) ? 'shaded' : '';
|
|
||||||
$status .= '<tr class="'.$tr_class.'"><td><span class="status-text">'.$result.'</span></td><td class="align-td">';
|
|
||||||
if ($data->status == 1) {
|
|
||||||
$status .= '<span class="green-circle circle-empty"></span>';
|
|
||||||
} else {
|
|
||||||
$status .= '<span class="red-circle"></span>';
|
|
||||||
}
|
|
||||||
$status .= '</td><td class="align-td">';
|
|
||||||
if (!empty($data->locations)) {
|
|
||||||
$locations = $data->locations;
|
|
||||||
$location = implode(",", $locations);
|
|
||||||
$status .= '<span class="green-circle circle-empty"></span></td><td><span class="status-text">'.$location.'</span></td>';
|
|
||||||
} else {
|
|
||||||
$status .= '<span class="red-circle"></span></td><td></td>';
|
|
||||||
}
|
|
||||||
$status .= '</tr>';
|
|
||||||
$index++;
|
|
||||||
}
|
|
||||||
return <<<HTML
|
return <<<HTML
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.status-div {
|
.status-div {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
.status-text {
|
.status-text {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
@@ -55,34 +35,91 @@
|
|||||||
<h4>A webserver and reverse proxy solution brought to you by <a target="_blank" href="https://www.linuxserver.io/">linuxserver.io</a> with php support and a built-in Certbot client.</h4>
|
<h4>A webserver and reverse proxy solution brought to you by <a target="_blank" href="https://www.linuxserver.io/">linuxserver.io</a> with php support and a built-in Certbot client.</h4>
|
||||||
<h4>We have an article on how to use swag here: <a target="_blank" href="https://docs.linuxserver.io/general/swag">docs.linuxserver.io</a></h4>
|
<h4>We have an article on how to use swag here: <a target="_blank" href="https://docs.linuxserver.io/general/swag">docs.linuxserver.io</a></h4>
|
||||||
<h4>For help and support, please visit: <a target="_blank" href="https://www.linuxserver.io/support">linuxserver.io/support</a></h4>
|
<h4>For help and support, please visit: <a target="_blank" href="https://www.linuxserver.io/support">linuxserver.io/support</a></h4>
|
||||||
|
HTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetProxies() {
|
||||||
|
$output = shell_exec("python3 /dashboard/swag-proxies.py");
|
||||||
|
$results = json_decode($output);
|
||||||
|
$status = "";
|
||||||
|
$index = 0;
|
||||||
|
foreach($results as $result => $data){
|
||||||
|
$tr_class = ($index % 2 == 0) ? 'shaded' : '';
|
||||||
|
$status .= '<tr class="'.$tr_class.'"><td><span class="status-text">'.$result.'</span></td><td class="align-td">';
|
||||||
|
if ($data->status == 1) {
|
||||||
|
$status .= '<span class="green-circle circle-empty"></span>';
|
||||||
|
} else {
|
||||||
|
$status .= '<span class="red-circle"></span>';
|
||||||
|
}
|
||||||
|
$status .= '</td><td class="align-td">';
|
||||||
|
if (!empty($data->locations)) {
|
||||||
|
$locations = $data->locations;
|
||||||
|
$location = implode(",", $locations);
|
||||||
|
$status .= '<span class="green-circle circle-empty"></span></td><td><span class="status-text">'.$location.'</span></td>';
|
||||||
|
} else {
|
||||||
|
$status .= '<span class="red-circle"></span></td><td></td>';
|
||||||
|
}
|
||||||
|
$status .= '</tr>';
|
||||||
|
$index++;
|
||||||
|
}
|
||||||
|
return <<<HTML
|
||||||
<div class="wrap-panel status-div">
|
<div class="wrap-panel status-div">
|
||||||
<div>
|
<div>
|
||||||
|
<h2>Proxies</h2>
|
||||||
<table class="table-hover">
|
<table class="table-hover">
|
||||||
<col>
|
|
||||||
<col>
|
|
||||||
<col>
|
|
||||||
<col>
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td><h3>Application</h3></td>
|
<td><h3>Application</h3></td>
|
||||||
<td><h3>Available</h3></td>
|
<td><h3>Available</h3></td>
|
||||||
<td><h3>Proxied</h3></td>
|
<td><h3>Proxied</h3></td>
|
||||||
<td><h3>Location</h3></td>
|
<td><h3>Location</h3></td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="tbody-data">
|
<tbody class="tbody-data">
|
||||||
{$status}
|
{$status}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<br/>
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
<div class="wrap-general">
|
|
||||||
HTML;
|
HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GetF2B() {
|
||||||
|
$output = exec("python3 /dashboard/swag-f2b.py");
|
||||||
|
$jails = json_decode($output, true);
|
||||||
|
$status = "";
|
||||||
|
$index = 0;
|
||||||
|
foreach($jails as $jail=>$bans){
|
||||||
|
$tr_class = ($index % 2 == 0) ? 'shaded' : '';
|
||||||
|
$status .= '<tr class="'.$tr_class.'"><td><span class="status-text">'.$jail.'</span></td><td><span class="status-text">'.$bans.'</span></td></tr>';
|
||||||
|
$index++;
|
||||||
|
}
|
||||||
|
return <<<HTML
|
||||||
|
<div class="wrap-panel status-div">
|
||||||
|
<div>
|
||||||
|
<h2>Fail2Ban</h2>
|
||||||
|
<table class="table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td><h3>Jail</h3></td>
|
||||||
|
<td><h3>Bans</h3></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="tbody-data">
|
||||||
|
{$status}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
</div>
|
||||||
|
HTML;
|
||||||
|
}
|
||||||
|
|
||||||
$geodb = file_exists('/config/geoip2db/GeoLite2-City.mmdb') ? '--geoip-database=/config/geoip2db/GeoLite2-City.mmdb' : '';
|
$geodb = file_exists('/config/geoip2db/GeoLite2-City.mmdb') ? '--geoip-database=/config/geoip2db/GeoLite2-City.mmdb' : '';
|
||||||
$access = shell_exec("cat /config/log/nginx/access.log | goaccess -a -o html --html-prefs='{\"theme\":\"darkGray\"}' --log-format COMBINED ".$geodb." -");
|
$access = shell_exec("cat /config/log/nginx/access.log | goaccess -a -o html --html-prefs='{\"theme\":\"darkGray\"}' --log-format COMBINED ".$geodb." -");
|
||||||
$status = GetStatus();
|
$status = GetHeader() . GetProxies() . GetF2B() . '<div class="wrap-general">';
|
||||||
echo str_replace("<div class='wrap-general'>", $status, $access);
|
echo str_replace("<div class='wrap-general'>", $status, $access);
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user