mirror of
https://github.com/TrezOne/docker-mods-uptime-kuma-timeout-fix.git
synced 2026-06-25 17:53:23 -04:00
Add homepage support
This commit is contained in:
@@ -5,6 +5,7 @@ import json
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import sys
|
||||
import urllib3
|
||||
|
||||
PROXY_REGEX = r"\s+set \$upstream_app (?P<name>\S+?);.*\n(\s+)set \$upstream_port (?P<port>\d+);.*\n(\s+)set \$upstream_proto (?P<proto>\w+);.*"
|
||||
@@ -14,14 +15,14 @@ BASIC_AUTH_REGEX = r"\n\s+auth_basic.*"
|
||||
LDAP_REGEX = r"\n\s+include \/config\/nginx\/ldap-location\.conf;.*"
|
||||
|
||||
|
||||
def find_apps():
|
||||
def find_apps(fast=False):
|
||||
apps = {}
|
||||
auths = collections.defaultdict(dict)
|
||||
file_paths = glob.glob("/config/nginx/**/**", recursive=True)
|
||||
auto_confs = glob.glob("/etc/nginx/http.d/*", recursive=True)
|
||||
file_paths.extend(auto_confs)
|
||||
for file_path in file_paths:
|
||||
if not os.path.isfile(file_path):
|
||||
if not os.path.isfile(file_path) or (fast and file_path.endswith(".sample")):
|
||||
continue
|
||||
file = open(file_path, "r")
|
||||
content = file.read()
|
||||
@@ -67,7 +68,8 @@ def is_available(url):
|
||||
|
||||
|
||||
urllib3.disable_warnings()
|
||||
apps, auths = find_apps()
|
||||
fast = (len(sys.argv) > 1)
|
||||
apps, auths = find_apps(fast)
|
||||
discovered_apps = collections.defaultdict(dict)
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor:
|
||||
futures = {executor.submit(is_available, app): app for app in apps.keys()}
|
||||
|
||||
@@ -310,10 +310,49 @@
|
||||
HTML;
|
||||
}
|
||||
|
||||
$goaccess = GetGoaccess();
|
||||
$status = GetHeader() . GetProxies() . GetF2B() . GetTemplates() . GetAnnouncements() . GetLinks() . "<div class='wrap-general'>";
|
||||
$page = str_replace("<div class='wrap-general'>", $status, $goaccess);
|
||||
$ssl = GetCertificate() . "<div class='pull-right hide'>";
|
||||
$page = str_replace("<div class='pull-right'>", $ssl, $page);
|
||||
echo $page;
|
||||
function GetStats() {
|
||||
$output = shell_exec("if test -f /lsiopy/bin/python3; then /lsiopy/bin/python3 /dashboard/swag-f2b.py; else python3 /dashboard/swag-f2b.py; fi");
|
||||
$jails = json_decode($output, true);
|
||||
$banned = 0;
|
||||
foreach($jails as $jail){
|
||||
$banned = $banned + $jail["bans"];
|
||||
}
|
||||
|
||||
$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);
|
||||
$proxied = 0;
|
||||
$auth = 0;
|
||||
foreach($results as $result => $data){
|
||||
if (!empty($data->locations)){
|
||||
$proxied++;
|
||||
if ($data->auth_status == 1) {
|
||||
$auth++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output = shell_exec("/etc/s6-overlay/s6-rc.d/init-version-checks/run");
|
||||
$outdated = 0;
|
||||
foreach(explode(PHP_EOL, $output) as $line) {
|
||||
if(str_contains($line, "/config/")) {
|
||||
$outdated++;
|
||||
}
|
||||
}
|
||||
|
||||
return array("proxied" => "$proxied", "auth" => "$auth", "outdated" => "$outdated", "banned" => "$banned");
|
||||
}
|
||||
|
||||
$stats = $_GET['stats'] == 'true' ? true : false;
|
||||
if($stats) {
|
||||
$page = GetStats();
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode($page);
|
||||
} else {
|
||||
$goaccess = GetGoaccess();
|
||||
$status = GetHeader() . GetProxies() . GetF2B() . GetTemplates() . GetAnnouncements() . GetLinks() . "<div class='wrap-general'>";
|
||||
$page = str_replace("<div class='wrap-general'>", $status, $goaccess);
|
||||
$ssl = GetCertificate() . "<div class='pull-right hide'>";
|
||||
$page = str_replace("<div class='pull-right'>", $ssl, $page);
|
||||
echo $page;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user