feat: support CNAME records in customDNS mappings#1352
feat: support CNAME records in customDNS mappings#1352ThinkChaos merged 41 commits into0xERR0R:mainfrom
Conversation
ThinkChaos
left a comment
There was a problem hiding this comment.
Thanks for picking this up!
I've got a couple comments about details, but also wanted to bring up maybe we should use dns.ZoneParser which supports the standard zonefile format instead of making something custom? UnmarshalYAML could error if any RR is not an A/AAAA/CNAME.
That also would have the benefit of allowing to split the mapping into another file via $INCLUDE.
That shouldn't be a blocker for this PR though.
|
Agreed that the zone parser looks promising but is out of scope and could be implemented later on. |
|
Thanks for the review @kwitsch and @ThinkChaos! I'll get these changes implemented tonight 😄 |
ThinkChaos
left a comment
There was a problem hiding this comment.
A couple new minor things and some follow-up from the previous threads.
Progress is looking great :)
…stream timeout duration
|
I think that I've implemented most of the PR feedback. I'm not a regular golang user and have been having a heck of a time implementing the |
|
If you want to post something that's blocking you feel free and I can take a look :) I resolved most threads, there's just that and one error in |
I'm mostly just not sure how to get the nested unmarshalling working. I took the sample posted earlier and tried to run with it. Conceptually, the code makes sense to me, however, when I run it, the UnmarshallYAML function gets called and I'm getting empty strings as the input. I'm sure that I've simply mapped something incorrectly. Here's a gist of the error: https://gist.github.com/BenMcH/32137efc5f5d5f0ce9f33bc94ccda796
Sorry for my ignorance, but which error in processIP am I missing? I thought that I had updated all of the calls that could return an error to bubble the error up and out of the function. I'll take a look at the linter soon! 🚀 |
The code you posted works for me!
The one from this thread: #1352 (comment) |
|
Thank you for all of your help on this, @ThinkChaos! Turns out I was overthinking it and failed to assign I'll go ahead and implement the rest of the feedback tonight. I think that the processIPs change is implemented. The current diff has the following: |
|
Alright, The reverse DNS and old log file deletion tests are failing on both branches on my machine, so I don't think that I introduced it. If I did introduce them, let me know, and I can continue looking into it. |
|
Seems I just had to walk away and come back with fresh eyes. I was able to fix the reverse DNS tests and now both |
kwitsch
left a comment
There was a problem hiding this comment.
Looks good to me.
One small comment how to possibly prevent CNAME loops.
Nice work & communication. 👍
ThinkChaos
left a comment
There was a problem hiding this comment.
Can you delete the blocky binary and add it to .gitignore?
… mapping along with a CNAME
|
@ThinkChaos thanks for the thorough review! I think that I've implemented all of your suggestions. We now conditionally resolve A or AAAA records on CNAMEs based on the question type and we prevent blocky from starting if there is more than 1 mapping for a domain and any of them are a CNAME. |
|
Sorry, I should have run lint locally before pushing. Now it should pass 🤞 I verified both tests and lint |
ThinkChaos
left a comment
There was a problem hiding this comment.
Ok last round for me I think :)
|
IDK why we need to re-approve the CI on every push, I don't remember it being like that before. Maybe because it's your first MR to this repo? |
That would make sense. Some github actions are things that you wouldn't want to run unless the code has been reviewed/trusted unless the user is a contributor/trusted. I've been making do with the makefile targets locally though 😄 |
As far as I observed the behavior: |
First time contributors need always approval (this is some kind of protection from GitHub to avoid execution of project workflows on each PR) 🤷 |
|
I think that the e2e test failure may have been a false positive. The errors reported were for an http port timeout and an error communicating with mariadb. I ran e2e tests on my local machine this morning and all tests passed. |
|
Could someone help with #1644? - I can't get simple CNAME mapping working under "customDNS": mappings:
test.internal: CNAME(host.internal)
host.internal: 192.168.1.100or even with: mappings:
test.internal: "CNAME(host.internal)"
host.internal: 192.168.1.100The error is It seems this code was merged and should be in the latest docker container (?), but I don't know what's wrong. I've looked through the code here but can't work out what's wrong. There's also an old discussion that "unresolved" here at #412. The somewhat annoying stale bot closed down @asianpianoman issue at #1644. |
|
Maybe this was not merged or deployed properly as it seems like "configuration.md" on the live site here does not match entirely with the docs submitted in this PR. i.e. the live/latest docs mention you can use CNAME in the customDNS config instead of an IP, but it does not show how as specified on this PR's file configuration.md line 287. |
|
It seems I've been on a wild Goose Chase... The feature was removed, and the docs were not updated. #1973 and file https://github.com/0xERR0R/blocky/pull/1973/files removed the doc parts referencing CNAME's only a few days ago and not published live yet. However, I can't find the commit/reasoning why this was removed or see it in the change log though. Can someone point me to the right commit/PR just for closure I've spent awhile on this one lol. |
This PR is related to #465. Currently, I have only implemented CNAME records, but it would be simple to add additional record types mentioned in #996.
Please let me know if you'd prefer a different approach, but this PR being merged would allow me to replace pihole with Blocky in my home network. I'm happy to add more record types if they make sense. My understanding of DNS is that most other record types typically have more complex use-cases that may not make sense to implement, as they're usually reserved for serving data such as mail configuration or DNS ownership, neither of which I would expect Blocky to be utilized for, given its local-network scope and risk associated with hosting a publicly accessible DNS server.
Further DNS response types can be added with a simple if statement in both the custom_dns.go and custom_dns_resolver.go.