Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api.php status weird behavior? #2051

Closed
joeroback opened this issue Jan 6, 2022 · 23 comments · Fixed by #2052
Closed

api.php status weird behavior? #2051

joeroback opened this issue Jan 6, 2022 · 23 comments · Fixed by #2052

Comments

@joeroback
Copy link

Versions

  • Pi-hole version is v5.8.1 (Latest: v5.8.1)
  • AdminLTE version is v5.10.1 (Latest: v5.10.1)
  • FTL version is v5.13 (Latest: v5.13)

Platform

  • OS and version: latest raspberry pi os
  • Platform: raspberry pi 3b+

Expected behavior

http:///admin/api.php?status should return the status, but it always returns
{"status": "disabled"}

this seems to break things like PiHole Chrome Brower Extension

if i leave out the status, it correctly returns the status.
http:///admin/api.php

{
    "domains_being_blocked": 534171,
    "dns_queries_today": 44,
    "ads_blocked_today": 0,
    "ads_percentage_today": 0,
    "unique_domains": 24,
    "queries_forwarded": 24,
    "queries_cached": 20,
    "clients_ever_seen": 2,
    "unique_clients": 2,
    "dns_queries_all_types": 41,
    "reply_NODATA": 0,
    "reply_NXDOMAIN": 6,
    "reply_CNAME": 0,
    "reply_IP": 0,
    "privacy_level": 0,
    "status": "enabled",
    "gravity_last_updated": {
        "file_exists": true,
        "absolute": 1641426659,
        "relative": {
            "days": 0,
            "hours": 0,
            "minutes": 15
        }
    }
}

Is this expected behavior? the api.php has code that looks for $_GET['status'] so it seems like using query parameter is the right thing.. unclear tho, since there is no API documentation to reference.

@pralor-bot
Copy link

This issue has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/api-status-is-wrong/52303/2

@badsgahhl
Copy link

badsgahhl commented Jan 6, 2022

if i leave out the status, it correctly returns the status.

It seems like it does but also this status is wrong. If I disable the PiHole via the WebUi oder API, api.php shows status:"enabled". but it should return "disabled".

So both api.php?status and api.php are wrong.

@rdwebdesign
Copy link
Member

Are you using a browser window to test this?
If so, maybe is a cache problem.

@joeroback
Copy link
Author

with curl on command line, if i disable the service, using /admin/api.php the status is correct for me, its just that is now includes all the stats as well, where previously it just said {"status": "disabled"} now it is

{
  "domains_being_blocked": 533580,
  "dns_queries_today": 44492,
  "ads_blocked_today": 3769,
  "ads_percentage_today": 8.471186,
  "unique_domains": 3322,
  "queries_forwarded": 24636,
  "queries_cached": 15601,
  "clients_ever_seen": 37,
  "unique_clients": 37,
  "dns_queries_all_types": 44492,
  "reply_NODATA": 350,
  "reply_NXDOMAIN": 539,
  "reply_CNAME": 1717,
  "reply_IP": 1993,
  "privacy_level": 0,
  "status": "disabled",
  "gravity_last_updated": {
    "file_exists": true,
    "absolute": 1641488093,
    "relative": {
      "days": 0,
      "hours": 2,
      "minutes": 13
    }
  }
}

@badsgahhl
Copy link

badsgahhl commented Jan 6, 2022

Pi-hole v5.8.1 FTL v5.13 Web Interface v5.10.1
PiHole disable via the GUI.
With curl:
curl http://localhost:8090/admin/api.php
{"domains_being_blocked":100735,"dns_queries_today":0,"ads_blocked_today":0,"ads_percentage_today":0,"unique_domains":0,"queries_forwarded":0,"queries_cached":0,"clients_ever_seen":0,"unique_clients":0,"dns_queries_all_types":0,"reply_NODATA":0,"reply_NXDOMAIN":0,"reply_CNAME":0,"reply_IP":0,"privacy_level":0,"status":"enabled","gravity_last_updated":{"file_exists":true,"absolute":1641464912,"relative":{"days":0,"hours":8,"minutes":41}}}
image

@badsgahhl
Copy link

The issue with the api.php status field seems to occur also with the pihole of this user: badsgahhl/pihole-browser-extension#57 (comment)

He disables the PiHole via the extension. After some time the extension reloads the status from api.php and receives "enabled" although it's disabled.

@rdwebdesign
Copy link
Member

rdwebdesign commented Jan 6, 2022

@joeroback

Looks like there are two separated issues:

  1. api.php?status is always returning {"status": "disabled"}.
    This bug has been confirmed and is now being fixed.

  2. api.php (without any parameter) sometimes returns the wrong value for status.
    This is a different bug. We need more testing. Please be patient.

@bcutter
Copy link

bcutter commented Jan 6, 2022

Saw the same. Everything fine (pihole -c, PADD, Webinterface, Home Assistant Pi-Hole integration active switch, ...) but asking API for status always gives disabled. Great to see you guys already discovered and even working on this, thanks.

@yubiuser
Copy link
Member

yubiuser commented Jan 6, 2022

This has been merged into development.
If you would like to try it yourself please try

pihole checkout web devel. To go back on track (for future releases) just run pihole checkout master

@miloit
Copy link

miloit commented Jan 12, 2022

When is the next release plant?

@PromoFaux
Copy link
Member

Soon

@jamie-2bit
Copy link

Yep, finding this an issue in Pi-hole v5.8.1 FTL v5.13 Web Interface v5.10.1 too. It's refferanced here also: arendruni/homebridge-pihole#46

@jacklawry
Copy link

Soon

Any update on release date?

@PromoFaux
Copy link
Member

Soon-ish™

But really, it all depends on when we can align ourselves to get a release prepped and pushed out. We (the folk that press all the buttons) all live in different parts of the world, so it can be tricky to tie down a time sometimes.

The fix will be in the next release, but I can't tell you at this point in time when that next release will be without being as vague as Soon.

@davsav
Copy link

davsav commented Feb 5, 2022

I tried changing to the dev branch with "pihole checkout web devel" but I still show the extension as always off.

What did I do wrong?

@badsgahhl
Copy link

With v3.0.2 and PiHole devel its working fine.

@yubiuser
Copy link
Member

yubiuser commented Feb 5, 2022

With v3.0.2

?

@rdwebdesign
Copy link
Member

Pi-hole version should be 5.x.

I think he is using a different software (not specified) AND pi-hole.

@badsgahhl
Copy link

badsgahhl commented Feb 5, 2022

Pi-hole version should be 5.x.

I think he is using a different software (not specified) AND pi-hole.

@davsav mentioned extension. That's why I referenced to badsgahhl/pihole-browser-extension#54

There the current extension version is 3.0.2. and everything is working right with devel of PiHole.

Sorry for the confusion, forgot to quote reply 😅

@davsav
Copy link

davsav commented Feb 5, 2022

Sorry for not listing what version of have of things.

I have PiHole Browser Extension 3.0.2, OS: Win32, Browser Chrome 97.0.4692.99 and I am running Pi-hole v5.8.1, FTL v5.13, Web Interface vDev (devel, v5.10.1-45-g3e21e323).

It does not appear to be fully working for me.

I can click on the icon in the browser bar (which says off), then click on the slider, changing it from off to on, which causes the icon to say on but maybe a few seconds later it changes back to off.

If I click on the icon in the browser bar (which says off), then click on the slider to turn it on then off, I can see that pi hole gets disabled.

Then clicking on the icon in the browser bar (which says off), then click on the slider, changing it from off to on does reenable pihole and changes the icon to say on but maybe a few seconds later it changes back to off.

@yubiuser
Copy link
Member

yubiuser commented Feb 6, 2022

We won't troubleshoot your Browser extension. Please use http://pi.hole/admin/api.php?status to verify which status is reported after you dis/enabled Pi-hole via it's web interface.

@davsav
Copy link

davsav commented Feb 6, 2022

Thanks for the http://pi.hole/admin/api.php?status tip.

I am running two pi-hole systems so I'm not down if one has an issue. Using the command above, I was able to figure out that one of the systems was working as expected while the other was always reporting disabled.

I then checked to verify that the non-working one was switched to devel and while I did give the command, apparently the command had failed. When giving the command again, I could see that the system could not reach github so I restarted the wireless interface, which then resolved my github access problem and it successfully switched to devel.

Now the extension works as it should. Thanks for the help.

@yubiuser
Copy link
Member

Fixed in https://discourse.pi-hole.net/t/pi-hole-ftl-v5-14-web-v5-11-and-core-v5-9-released/53529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.