Skip to content

Migrate DNS server to dnsv2#382

Open
zasdaym wants to merge 1 commit into
psviderski:mainfrom
zasdaym:fix/dnsv2
Open

Migrate DNS server to dnsv2#382
zasdaym wants to merge 1 commit into
psviderski:mainfrom
zasdaym:fix/dnsv2

Conversation

@zasdaym

@zasdaym zasdaym commented May 29, 2026

Copy link
Copy Markdown
Contributor

Closes #341.

@miekg

miekg commented May 29, 2026 via email

Copy link
Copy Markdown
Contributor

Comment thread internal/machine/dns/server.go Outdated
var lastErr error
for _, server := range s.upstreamServers {
resp, _, err := client.Exchange(req, server.String())
resp, err := forwardRaw(ctx, req.Data, proto, server.String())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be as simple as io.Copy, if it's not are you ran into problem I would like to know, because then the lib. needs to change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why io.Copy instead of dns.Exchange?

Comment thread internal/machine/dns/server.go Outdated
return resp
}

func truncate(msg *dns.Msg, maxSize int) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably wrong, as you will returns split up RRsets (which is an unfortunate DNS thing). But apparantly this is difficult enough that this needs a helper. https://codeberg.org/miekg/dns/issues/882

Comment thread internal/machine/dns/server.go Outdated
return strings.TrimSuffix(name, "."+InternalDomain)
}

func newResponse(req *dns.Msg, rcode uint16) *dns.Msg {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can, prolly 100% of the time, just the incoming message Reset it and reuse it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's make it simpler.

@zasdaym zasdaym force-pushed the fix/dnsv2 branch 7 times, most recently from c919abd to 175553f Compare June 11, 2026 02:18
Comment thread go.mod Outdated

replace github.com/caddyserver/certmagic v0.25.2 => github.com/caddyserver/certmagic v0.21.4

replace github.com/caddyserver/zerossl v0.1.5 => github.com/caddyserver/zerossl v0.1.3

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miekg why do we need this Caddy stuff for a DNS library? Does it provide a DNS server now as well?

As we have migrated from the JSON caddy config (https://github.com/psviderski/uncloud/blob/5cc005a4237bf7e5367e4570cce5e5f90748d155/internal/machine/caddyconfig/jsonconfig.go) to Caddyfile generation, we can now drop the caddy/v2 Go dependency which is quite heavy.

But this PR seems to brings some of the caddy packages back.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly don't know - this pr is on my list to review again
(or do it myself first and then see what I come up with)

It should not have to do anything with caddy, as both dns and dnsv2 can be used independently. Even though the deps for dnsv2 are heavier than they should be, as atomdns is also there - on the TODO to rip that out as well. That should prolly by done before including it here as a dep - but as said, I want to look at this more closely.

(there is no rush to merge this btw)

@zasdaym zasdaym Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@psviderski we can remove zerossl but not with certmagic.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you both for the context. I'll then leave this PR to you guys to decide how we go with this migration

@zasdaym zasdaym force-pushed the fix/dnsv2 branch 2 times, most recently from faf9040 to 4f40919 Compare June 17, 2026 23:26
Signed-off-by: Zasda Mikail <zasdaym@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

move dns impl to dnsv2

3 participants