-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Improve DHCP handling #1731
Improve DHCP handling #1731
Conversation
… lease time is one hour for IPv4 and one day for IPv6 (dnsmasq defaults, see their man page). Signed-off-by: DL6ER <[email protected]>
…rt,end,router} from string to IPv4 address to allow detection of invalid settings (e.g., "192.168.1.3000") early on Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
…arning to the log Signed-off-by: DL6ER <[email protected]>
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/api-error-when-enabling-dhcp-server/66079/8 |
test/api/libs/responseVerifyer.py
Outdated
# Split the address into parts | ||
parts = addr.split(":") # type: list[str] | ||
# Check if the address is a valid IPv6 address | ||
if len(parts) != 8: |
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.
Is it possible to use shortened IPv6 addresses here like 2001:db8::1234:5678
?
Will this code work in this case?
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.
Thanks for your comment, something got lost here. As you can see, I added import ipaddress
above and actually have also used it for the check but this got somehow lost. I will add it back in
I tested using Should we add other validation rules? |
The validation of all DHCP-related stuff happens in the embedded |
Signed-off-by: DL6ER <[email protected]>
Signed-off-by: DL6ER <[email protected]>
I'm not sure if we should provide default values. Maybe start with empty fields is the right way. |
Hmm, yes, this is actually tricky. We changed the variable type from I can see two things how we could proceed right now:
What do you say? (1) is obviously the much easier way to go forward but we are known to not be afraid of work at Pi-hole ;-) |
We can go with option 1). Less hand-holding and forcing users to think about their DHCP range before they apply the settings. If we set wrong defaults (which would never happen) and break anything we are the once to blame. |
I think option 1 is better. The interface+API are already verifying most of the entries to avoid invalid values. |
Thanks for your comment, option no. 1 is it then.
See the API description for
|
a1aaa35
to
ceb5ac3
Compare
…in FTL settings Signed-off-by: DL6ER <[email protected]>
ceb5ac3
to
503c053
Compare
What does this implement/fix?
dhcp.leaseTime
if it is a non-empty string. By default it is non-empty, however we have seen users making it empty. If empty, the default lease time is one hour for IPv4 and one day for IPv6 (dnsmasq
defaults, see their man page).dhcp.netmask
defaulting to0.0.0.0
(auto-discovery as before this PR) but freely settable to, e.g.255.255.0.0
to make a/16
DHCP networkipv4
andipv6
are not standardizedformat
properties, we add them as ax-format
instead. However, sinceswagger-api
supports them there is some hope this will end up in a future revision of the OpenAPI standard. Even if not, having the verification using a non-default property seems still usefulwhere I tried to set
This still adds a warning to
FTL.log
:The first two items address a bug reported on Discourse where a user tried to specify a DHCP range from
192.168.0.300
to192.168.0.500
with an emptyleaseTime
config option. The fourth item goes into this direction was well as it will allow us to show the error in a more human-digestible form to the user (upcoming web PR).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:
git rebase
)Checklist:
developmental
branch.