There are privacy settings on the Pihole which affect the output of the API.
When any privacy settings other than "Show everything" is selected on the Pihole, the DNS Stats widget fails with this error:
The problem is that one of the fields (top_ads) in the JSON response from Pihole's API turns to an empty array because of the setting. For reference, with the privacy setting...
... and without:
I made a fix in pihole.go -- it just uses an alternate struct definition that does not expect top_ads if the original one fails. It copies to the original struct instance to sidestep any type errors, though it does look a little ugly. Here's how it looks after the fix:
It's my first time using Go, so I'm not sure if this was the best way to fix it. Do let me know if there's anything I can do to improve this.
There are privacy settings on the Pihole which affect the output of the API.
When any privacy settings other than "Show everything" is selected on the Pihole, the DNS Stats widget fails with this error:
The problem is that one of the fields (
top_ads
) in the JSON response from Pihole's API turns to an empty array because of the setting. For reference, with the privacy setting...... and without:
I made a fix in
pihole.go
-- it just uses an alternate struct definition that does not expecttop_ads
if the original one fails. It copies to the original struct instance to sidestep any type errors, though it does look a little ugly. Here's how it looks after the fix:It's my first time using Go, so I'm not sure if this was the best way to fix it. Do let me know if there's anything I can do to improve this.