-
-
Notifications
You must be signed in to change notification settings - Fork 566
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
Changing the information source to "pi-hole status" in the API #2059
Conversation
This is a good idea. Refactor this into its own function and use the same functions in both. Prevents this from happening again in the future. |
I think I will reuse my new function: This: if (isset($_GET['status'])) {
// Receive the return of "pihole status web"
$pistatus = pihole_execute('status web');
if (isset($pistatus[0])) {
$pistatus = intval($pistatus[0]);
} else {
// If no response, status="Unknown" (-2)
$pistatus = -2;
}
switch ($pistatus) {
case -2: // Unkown
case -1: // DNS service not running"
case 0: // Offline
$data = array_merge($data, array("status" => "disabled"));
break;
default:
// DNS service on port $returncode
$data = array_merge($data, array("status" => "enabled"));
}
} elseif ... Will become this: if (isset($_GET['status'])) {
// read setupVars and return the status
$data = array_merge($data, array("status" => piholeStatus() ));
} elseif ... What do you think? |
Just reading |
So the question is What happens if there are comments in setupVars.conf ? |
I didn't know it was possible to have |
It could just crash... |
PHP strips the comments. |
Using "pihole status web" info Signed-off-by: rdwebdesign <github@rdwebdesign.com.br>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works both for http://pi.hole/admin/api.php
and http://pi.hole/admin/api.php?status
Using "pihole status web" info Signed-off-by: rdwebdesign <github@rdwebdesign.com.br>
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/pi-hole-ftl-v5-14-web-v5-11-and-core-v5-9-released/53529/1 |
By submitting this pull request, I confirm the following:
git rebase
)git commit --signoff
)What does this PR aim to accomplish?:
Fix an API intermittent error, where the status info received by
api.php
orapi.php?summary
is sometimes wrongly reported.Cause:
api_FTL.php
uses FTL response to determine if pi-hole is enabled or disabled.FTL only updates this value when is internally needed, but it doesn't update this value before answering the API call.
How does this PR accomplish the above?:
Replacing the status received from FTL with the status currently stored in
setupVars.conf
.What documentation changes (if any) are needed to support this PR?:
none