Add ASN support

This commit is contained in:
quietsy
2025-04-29 15:57:33 +03:00
parent 08c52ca99c
commit 9ae9a5cca3
2 changed files with 9 additions and 3 deletions
+1
View File
@@ -32,6 +32,7 @@ Remove the allow/deny lines in `/config/nginx/proxy-confs/dashboard.subdomain.co
proxy_pass $upstream_proto://$upstream_app:$upstream_port; proxy_pass $upstream_proto://$upstream_app:$upstream_port;
``` ```
- Either [Swag Maxmind mod](https://github.com/linuxserver/docker-mods/tree/swag-maxmind) or [Swag DBIP mod](https://github.com/linuxserver/docker-mods/tree/swag-dbip) are required to enable the geo location graph. - Either [Swag Maxmind mod](https://github.com/linuxserver/docker-mods/tree/swag-maxmind) or [Swag DBIP mod](https://github.com/linuxserver/docker-mods/tree/swag-dbip) are required to enable the geo location graph.
- Either Maxmind's or DB-IP's ASN mmdb are required under `/config/geoip2db/asn.mmdb` to enable the ASN graph.
- To clear the dashboard stats, you must remove the logs (/config/log/nginx) and **recreate** the container. - To clear the dashboard stats, you must remove the logs (/config/log/nginx) and **recreate** the container.
## Dashboard Support ## Dashboard Support
+8 -3
View File
@@ -280,6 +280,7 @@
} }
function GetGoaccess() { function GetGoaccess() {
$geodb = '';
$dbip = '/config/geoip2db/dbip-country-lite.mmdb'; $dbip = '/config/geoip2db/dbip-country-lite.mmdb';
$maxmind = '/config/geoip2db/GeoLite2-City.mmdb'; $maxmind = '/config/geoip2db/GeoLite2-City.mmdb';
if (file_exists($dbip) and file_exists($maxmind)): if (file_exists($dbip) and file_exists($maxmind)):
@@ -288,12 +289,16 @@
$geodb = '--geoip-database='.$dbip; $geodb = '--geoip-database='.$dbip;
elseif (file_exists($maxmind)): elseif (file_exists($maxmind)):
$geodb = '--geoip-database='.$maxmind; $geodb = '--geoip-database='.$maxmind;
else: endif;
$geodb = '';
$asndb = '';
$asn = '/config/geoip2db/asn.mmdb';
if (file_exists($asn)):
$asndb = '--geoip-database='.$asn;
endif; endif;
$access_log = file_exists("/dashboard/logs") ? "/dashboard/logs/*.log" : "/config/log/nginx/access.log"; $access_log = file_exists("/dashboard/logs") ? "/dashboard/logs/*.log" : "/config/log/nginx/access.log";
$goaccess = shell_exec("cat $access_log | /usr/bin/goaccess -a -o html --config-file=/dashboard/goaccess.conf $geodb -"); $goaccess = shell_exec("cat $access_log | /usr/bin/goaccess -a -o html --config-file=/dashboard/goaccess.conf $geodb $asndb -");
$goaccess = str_replace("<title>Server&nbsp;Statistics", "<title>SWAG&nbsp;Dashboard", $goaccess); $goaccess = str_replace("<title>Server&nbsp;Statistics", "<title>SWAG&nbsp;Dashboard", $goaccess);
$goaccess = str_replace("<h1 class='h-dashboard'>", "<h1>", $goaccess); $goaccess = str_replace("<h1 class='h-dashboard'>", "<h1>", $goaccess);
$goaccess = str_replace("<i class='fa fa-tachometer'></i>", "<img src='/icon.svg' width='32' height='32'>&nbsp;SWAG&nbsp;", $goaccess); $goaccess = str_replace("<i class='fa fa-tachometer'></i>", "<img src='/icon.svg' width='32' height='32'>&nbsp;SWAG&nbsp;", $goaccess);