From 9ae9a5cca3e6dbfdf7384ffae967815650cba0e9 Mon Sep 17 00:00:00 2001 From: quietsy Date: Tue, 29 Apr 2025 15:57:33 +0300 Subject: [PATCH] Add ASN support --- README.md | 1 + root/dashboard/www/index.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 788c41a..3ea54ee 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/root/dashboard/www/index.php b/root/dashboard/www/index.php index c305144..6064284 100644 --- a/root/dashboard/www/index.php +++ b/root/dashboard/www/index.php @@ -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("Server Statistics", "<title>SWAG 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'> SWAG ", $goaccess);