Merge pull request #1028 from linuxserver/swag-dashboard-add-asn

Add ASN support
This commit is contained in:
quietsy 2025-04-29 16:26:05 +03:00 committed by GitHub
commit d56841b417
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

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;
```
- 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.
## Dashboard Support

View File

@ -280,6 +280,7 @@
}
function GetGoaccess() {
$geodb = '';
$dbip = '/config/geoip2db/dbip-country-lite.mmdb';
$maxmind = '/config/geoip2db/GeoLite2-City.mmdb';
if (file_exists($dbip) and file_exists($maxmind)):
@ -288,12 +289,16 @@
$geodb = '--geoip-database='.$dbip;
elseif (file_exists($maxmind)):
$geodb = '--geoip-database='.$maxmind;
else:
$geodb = '';
endif;
$asndb = '';
$asn = '/config/geoip2db/asn.mmdb';
if (file_exists($asn)):
$asndb = '--geoip-database='.$asn;
endif;
$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("<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);