DL6ER
October 12, 2023, 4:31pm
2
Thanks for bringing to to our attention, we have a PR aimed to resolve this by replacing pihole -q
by a more modern variant, but it is still awaiting a certain decision, trying to get this rolling again.
pi-hole:development-v6
← pi-hole:query_list_v6
opened 08:24PM - 13 Aug 23 UTC
**What does this PR aim to accomplish?:**
This is a complete rewrite of `quer… y.sh`
So far, we have been using direct access to the gravity database to implement the functions provided by `pihole -q` (query the adlist/denylist for a given domain). With FTL v6, FTL provides an API endpoint `/search/DOMAIN` which will do all the low-level work for us and outputs a json containing all the relevant data (and some more).
This PR changes the implementation of `pihole -q` to use the provided API. To be able to do that, I added a helper file (`api.sh`) which provides the necessary functions to authenticate with the API and request data from it and finally to delete the session if everything is done. It's the same function that I use to access FTL's API int the v6 branch of PADD. As we need to rewrite some more function to use FTL's API they can be reused in other `pihole` cli calls. Both, the `query.sh` as well as `api.sh` are POSIX style. The output colors are similar to that the v6 web interface is using. As we source `COL_TABLE` this was made POSIX compatible as well.
![Screenshot at 2023-08-13 22-07-25](https://github.com/pi-hole/pi-hole/assets/26622301/a66e2302-c3f2-4650-9c1e-3efb69e750a5)
Most of the code in `query.sh` is now the generation of the output (from the json returned by FTL). While working on it, I also changed the way we handle provided option (`--exact`, `--all`). They can be in an arbitrary position and handled gracefully. This
PR supersedes https://github.com/pi-hole/pi-hole/pull/5349
---
**By submitting this pull request, I confirm the following:**
1. I have read and understood the [contributors guide](https://docs.pi-hole.net/guides/github/contributing/), as well as this entire template. I understand which branch to base my commits and Pull Requests against.
2. I have commented my proposed changes within the code and I have tested my changes.
3. I am willing to help maintain this change if there are issues with it later.
4. It is compatible with the [EUPL 1.2 license](https://opensource.org/licenses/EUPL-1.1)
5. I have squashed any insignificant commits. ([`git rebase`](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html))
6. I have checked that another pull request for this purpose does not exist.
7. I have considered, and confirmed that this submission will be valuable to others.
8. I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
9. I give this submission freely, and claim no ownership to its content.
---
- [x] I have read the above and my PR is ready for review. *Check this box to confirm*