Some architectural cleanup - #204
Conversation
aarond10
commented
May 5, 2026
@baranyaib90, any chance you'd mind reviewing this one? |
Hi, I just had a brief look at this and I'm not happy with the timing of this refactor, because I have a lot of WIP changes on my master branch (https://github.com/baranyaib90/https_dns_proxy/commits/master/) and this will give me a huge rebase work. |
baranyaib90
left a comment
There was a problem hiding this comment.
I have checked the code good enough. Wrote a few comments about 2 stuff mainly (removing ops and dummy functions).
I like this refactor, it really makes more sense this way.
Get it in before me. I will deal with my rebase mess :)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm happy to sit on this and rebase later. Your call. |
The per-request lifecycle (allocate state, hand to libcurl, route response
back to the originating listener, free) lived as static functions in main.c
glued together via app_state_t and an is_tcp tag in request_t. The two
listener implementations had no shared interface, so dispatch branched on
is_tcp at every step.
- dns_listener.h: transport-agnostic interface (respond/stop/destroy
function pointers + transport tag for metrics).
- dns_listener_udp.{c,h}, dns_listener_tcp.{c,h}: adapters.
- doh_proxy.{c,h}: owns the request lifecycle, curl resolve list, and
bootstrap-await/on-ready handshake. Listeners and dns_poller call into
the proxy, not main.c.
- dns_common.h: shared DNS protocol constants.
main.c shrinks to assembly. The is_tcp boolean is gone.~110 lines of EDNS0/c-ares juggling (parse OPT, drop additional+authority,
drop answers until under the limit, set TC) was buried as static functions
in the UDP listener — only reachable by booting a real UDP server.
Move to dns_truncate.{c,h} with one entry point: dns_truncate_for_udp().
The UDP listener's respond path collapses to validate-length,
truncate-for-fit, sendto. The module is now unit-testable with synthetic
byte buffers.baranyaib90
commented
May 6, 2026
Hi @aarond10, thank you for the changes, please merge it. |
Uh oh!
There was an error while loading. Please reload this page.
This accomplishes a few things I have wanted to do but not had much time to get done.
I was planning after this is to merge common logic across dns_listener_{tcp,udp}.{c,h}.