Support passwordless Pi-hole 6+

This commit support Pi-hole v6+ instances where no password is set. In
this case, the session id endpoint should not be called since it returns
'no password set'.
This commit is contained in:
David Davis
2025-08-02 07:19:32 -04:00
parent 9720ebe9b1
commit 160a724fdc
2 changed files with 18 additions and 16 deletions

View File

@@ -2359,7 +2359,7 @@ Only required when using AdGuard Home. The username used to log into the admin d
##### `password`
Required when using AdGuard Home, where the password is the one used to log into the admin dashboard.
Also required when using Pi-hole major version 6 and above, where the password is the one used to log into the admin dashboard or the application password, which can be found in `Settings -> Web Interface / API -> Configure app password`.
For Pi-hole version 6+, this field is required if you have set a password to log into Pi-hole. You can either use the password you use to log into the admin dashboard or the application password, which can be found in `Settings -> Web Interface / API -> Configure app password`.
##### `token`
Required when using Pi-hole major version 5 or earlier. The API token which can be found in `Settings -> API -> Show API token`.

View File

@@ -429,6 +429,7 @@ func fetchPiholeStats(
return nil
}
if password != "" {
if sessionID == "" {
if err := fetchNewSessionID(); err != nil {
slog.Error("Failed to fetch Pihole v6 session ID", "error", err)
@@ -448,6 +449,7 @@ func fetchPiholeStats(
}
}
}
}
var wg sync.WaitGroup
ctx, cancel := context.WithCancel(context.Background())