Skip to content

Improve DHCP static leases management GUI #3565

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

Open
wants to merge 10 commits into
base: development
Choose a base branch
from

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Jul 15, 2025

What does this implement/fix?

See title. This adds a easy accessible table that is kept in sync with the <textarea> which still allows for any advanced configuration.

Please see this movie for a demonstration:

Screencast.From.2025-07-15.12-41-22.webm

You can test all of that even without having the DHCP server enabled. What will be saved in the end is always the content of said <textarea> which is getting stores as dhcp.hosts in pihole.toml.


Related issue or feature (if applicable): N/A

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, 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.
  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
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories development branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

DL6ER added 2 commits July 15, 2025 12:48
Signed-off-by: DL6ER <[email protected]>
…t any possibility for code injection)

Signed-off-by: DL6ER <[email protected]>
@smithbill17
Copy link

The video looks good to me, but unfortunately I'm not able to test this as I have now stopped using PiHole (partly due to this very issue).

However, two comments based on the video:
a) the 'advanced config' line shows nothing in the easy text grid - can't it still show MAC, IP & name but with an expansion arrow (or some kind of indicator) for the additional fields?
b) in PiHole v5, it didn't seem to matter if MACs were entered with hyphens ('-') rather than colons (':'). Is this the case with v6? And does it matter if IPs fall out-with the DHCP scope?

@DL6ER
Copy link
Member Author

DL6ER commented Jul 15, 2025

a) the 'advanced config' line shows nothing in the easy text grid - can't it still show MAC, IP & name but with an expansion arrow (or some kind of indicator) for the additional fields?

Yes, this is expected and per design. Advanced config lines may include set and id and other identifiers and it'd be very complicated (= error-prone) to edit the "simple" parts of it without damaging the advanced config. Not trying to edit these lines but instead showing where they are in the text area (where the user initially created them) seems the most straightforward and most robust way

b) in PiHole v5, it didn't seem to matter if MACs were entered with hyphens ('-') rather than colons (':'). Is this the case with v6? And does it matter if IPs fall out-with the DHCP scope?

I did add - as separators now. It doesn't matter if IP addresses are within the set DHCP scope.

@yubiuser
Copy link
Member

If something invalid is entered in the advanced box (e.g. 00:20:e0:3b:13:af,8.8.8.8.7,laptop) the corresponding field in the table is empty (IP). Maybe we should show invald instead?

The live-editing is cool but only shown advanced > table, not the other way round. Is this by design?

Advanced settings present in line 3

This could be hard to find if n is big. Could we show line numbers in the advanced text box?

@DL6ER
Copy link
Member Author

DL6ER commented Jul 16, 2025

Could we show line numbers in the advanced text box?

Yes.

Screenshot From 2025-07-16 08-27-16

If something invalid is entered in the advanced box (e.g. 00:20:e0:3b:13:af,8.8.8.8.7,laptop) the corresponding field in the table is empty (IP). Maybe we should show invald instead?

The code is written such that it parses the same way dnsmasq parses this line. If the IP address is not valid, it is taken as hostname.

The live-editing is cool but only shown advanced > table, not the other way round. Is this by design?

Yes. First, I implemented it both ways but as soon as you edit the IP address, e.g., 192.168.0. (because you are editing the last digit), it'd immediately be dropped from the IP column as it is now invalid. This prevents further editing. Hence, I decided we let the user finish what they want and then click save.

@yubiuser
Copy link
Member

If the IP address is not valid, it is taken as hostname.

Except when a hostname is also given
2025-07-16_09-09

@rdwebdesign
Copy link
Member

I tested using an invalid IP (192.168.0.300) and a hostname:

00:20:e0:3b:13:af,192.168.0.300,laptop

When saved, the invalid IP is ignored, resulting in 00:20:e0:3b:13:af,laptop.

I think this is the correct behavior, but no warning was returned to the user, to inform something was wrong and the entry was "fixed" to fit the valid input fields. Maybe we need a warning/alert for cases like this.

@DL6ER
Copy link
Member Author

DL6ER commented Jul 20, 2025

Like so?

Screencast.From.2025-07-20.1.webm

@DL6ER
Copy link
Member Author

DL6ER commented Jul 20, 2025

Screencast.From.2025-07-20.20-39-42.webm

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

Successfully merging this pull request may close these issues.

4 participants