-
-
Notifications
You must be signed in to change notification settings - Fork 556
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
Add 'edit' action to Custom DNS endpoint #2379
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this is all logic that should be in what ever client that would be calling this endpoint.
The client should be doing the lifting of deciding if the record needs to be updated/modified by checking the existing records existence and then checking if the record needs updating. It would also be up to the client to decide if any existing records should be deleted since DNS itself has no requirement for an A record value to be unique.
I guess a simple wrapper update endpoint that is basically syntactic sugar for
delete
and thenadd
could work but I like the idea of API endpoints doing one specific job and being extremely unambiguous with it's function.Solely my views of course.
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.
This is basically:
The only thing needed is to allow
deleteCustomDNSEntry()
to receive parameters (ip and domain from the entry to be deleted).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.
Do you even need the IP address? Just the record should be enough.
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.
@rdwebdesign pretty much, except the current delete endpoint needs you to pass in the current IP address of the entry. As @dschaper points out, the IP is not actually needed, as you can only have one entry per hostname, so the hostname alone should be enough.
I can submit a separate PR to refactor the delete endpoint and remove the need for the IP to be sent. I think that's a good change regardless of the rest. What do you think?
Even if I make that change, it's still two API calls to "edit" a record. Ideally we would want one endpoint per CRUD operation, no? The only reason this is a discussion at the API level is because the underlying pihole CLI doesn't support edits. Maybe I should focus my efforts in adding the
edit
option there and keep the API a one-to-one mapping to the CLI.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.
Actually, this API was created mostly to be used by the web interface.
In my opinion, the introduced change is not being used by the web interface at all. No pages are using use the new feature.
I understand your idea, but this doesn't matter. These API calls use
pihole
to delete/save the values.Your new code calls
pihole
2 times:pihole_execute('-a removecustomdns '.$old_ip.' '.$domain)
andpihole_execute('-a addcustomdns '.$ip.' '.$domain.' '.$reload)
This is exactly like calling the functions we already have (
deleteCustomDNSEntry()
followed byaddCustomDNSEntry()
).This new function just uses a slightly different "path", but it calls the same code from
pihole
.In the end
pihole
code needs 2 calls because it has only 2 functions to handle Custom DNS entries.There is no "edit" or "update" function there. It will just remove the record and write the new one.