Skip to content

Fix client IP filtering in get_queries - #12

Open
DanielVd wants to merge 1 commit into
sbarbett:mainfrom
DanielVd:fix-query-client-filter
Open

Fix client IP filtering in get_queries#12
DanielVd wants to merge 1 commit into
sbarbett:mainfrom
DanielVd:fix-query-client-filter

Conversation

@DanielVd

@DanielVd DanielVd commented Sep 5, 2026

Copy link
Copy Markdown

Summary

Fix PiHole6Metrics.get_queries() client filtering by sending the value as the Pi-hole v6 client_ip query parameter.

The public Python argument remains client for backward compatibility, but the HTTP request currently sends it as client. Pi-hole FTL /api/queries expects client_ip for filtering by client address and client_name for filtering by client name, so the existing parameter is ignored for client IP filtering.

Changes

  • Keep the existing client Python argument unchanged.
  • Send its value as the HTTP client_ip parameter.
  • Clarify in the docstring that client represents a client IP.
  • Add regression tests covering the parameter mapping and the no-filter case.

Tests

PYTHONPATH=src python3 -m unittest discover -v

Result: 2 tests passed.

This is intentionally scoped to fixing client IP filtering. Support for filtering by client_name can be added separately without changing this fix.

@DanielVd

DanielVd commented Sep 7, 2026

Copy link
Copy Markdown
Author

Validated directly against a real Pi-hole v6 instance, without going through the MCP layer.

For the same 60-second query window and target client:

  • Expected queries for the target client: 1.
  • Current pihole6api: 130 queries returned, 129 belonging to other clients.
  • Patched pihole6api: 1 query returned, 0 mismatches.

Result: the current client HTTP parameter does not filter the query log, while mapping the existing Python client argument to Pi-hole's client_ip parameter produces exactly the expected result.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant