Skip to content
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

qtype does not match request family #6670

Open
wranders opened this issue May 8, 2024 · 0 comments
Open

qtype does not match request family #6670

wranders opened this issue May 8, 2024 · 0 comments
Labels

Comments

@wranders
Copy link

wranders commented May 8, 2024

What happened:

When submitting request using IPv6, the state.QType() of the request is dns.TypeA.

state.Family() correctly denotes the request is IPv6.

What you expected to happen:

I would think that state.Family() returning 2, which correctly denotes the request is IPv6,
would set the state.QType() to dns.TypeAAAA.

How to reproduce it (as minimally and precisely as possible):

Start CoreDNS with a plugin that prints dns.TypeToString[state.QType()].

Submit a request using dig -6 example.com.

Anything else we need to know?:

I'm not sure this is a bug or not, but this does seem pretty counter-intuitive.

In a plugin I'm developing, I'm currently using the following code to correct this:

func (m *MyPlugin) ServeDNS(ctx context.Context, w dns.ResponseWriter,r *dns.Msg) (int, error) {
	state := request.Request{W: w, Req: r}
	qtype := fixQType(state)
	. . .
}

func fixQType(state request.Request) uint16 {
	var qtype uint16
	switch state.QType() {
	case dns.TypeA, dns.TypeAAAA:
		switch state.Family() {
		case 1:
			qtype = dns.TypeA
		case 2:
			qtype = dns.TypeAAAA
		}
		return qtype
	default:
		return state.QType()
	}
}

Environment:

  • the version of CoreDNS: v1.11.3
@wranders wranders added the bug label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant