HTTPS record rewrite with $dnsrewrite not working
Prerequisites
-
[x] I have checked the Wiki and Discussions and found no answer
-
[x] I have searched other issues and found no duplicates
-
[x] I want to report a bug and not ask a question or ask for help
-
[x] I have set up AdGuard Home correctly and configured clients to use it. (Use the Discussions for help with installing and configuring clients.)
Platform (OS and CPU architecture)
Linux, ARMv7
Installation
GitHub releases or script from README
Setup
On one machine
AdGuard Home version
v0.107.72
Action
- Add one HTTPS record rewrite rule
||what.ever^$dnsrewrite=NOERROR;HTTPS;1 . ech=AEX+DQBBggAgACCkxcdxouv8w8QtgUzpnhDg0FT8qOyZ2HqSGwogCZdnBQAEAAEAAQASY2xvdWRmbGFyZS1lY2guY29tAAA=
- Use an dns query utility, e.g. https://github.com/natesales/q, to test the record
q https what.ever
Expected result
Return the correct HTTPS record.
Actual result
Return nothing.
Additional information and/or screenshots
No response
I can reproduce this. I’ll forward it to the dev team.
There are two issues here, one with the rule and one with AGH:
- The padding (
=) makes the rule invalid. It's not actually necessary, so you should just remove it. - AGH should be less strict about parsing Base64 with no padding. We'll fix that.
Hi.
The ech key above is from the query of cloudflare-ech.com. For now it's ech="AEX+DQBBFgAgACCwNFLgRRTjCPoQPifC2po/IvrwYwTTzGDqxOmWREutYwAEAAEAAQASY2xvdWRmbGFyZS1lY2guY29tAAA=". If you write " it's an invalid rule. What's the recommend way of writing this?
Just remove the final = (or ==). Once we implement the change on our side, it should work.
Thanks. I'll wait for a test on my side.
@showgood163, should be fixed on the Edge channel in versions v0.108.0-a.1320+922a7aaf and later.
We'll close the issue for now.
Sorry for the late reply and thanks for the update.
With final = removed, the ech rewrite function on v0.107.78 is working. However, now AdguardHome only return https record. All other records, e.g., A, AAAA, are overwritten to none.
Rule example (please replace what.ever with a valid domain name with A/AAAA records): ||what.ever^$dnsrewrite=NOERROR;HTTPS;1 . ech=AEX+DQBBggAgACCkxcdxouv8w8QtgUzpnhDg0FT8qOyZ2HqSGwogCZdnBQAEAAEAAQASY2xvdWRmbGFyZS1lY2guY29tAAA=
@showgood163, you need to limit the rule's action to one DNS type as well. See https://adguard-dns.io/kb/general/dns-filtering-syntax/#dnstype-modifier.
Thanks. I think my initial problem is solved.
The HTTPS only record rewrite function works as expected with ||what.ever^$dnstype=HTTPS,dnsrewrite=NOERROR;HTTPS;1 . ech=AEX+DQBBRQAgACBxypBShIlPJy0+2DWoxw6B6dy/pq5RhFqcAy+R+D2DTAAEAAEAAQASY2xvdWRmbGFyZS1lY2guY29tAAA. I tested it in chrome browser, and it worked.
Another question, is it possible to do dynamic rewriting, e.g., the valid HTTPS record comes from the HTTPS record of another domain which updates constantly? I tested rewriting with CNAME record and dynamic rewriting didn't work when testing in chrome browser.