Skip to content

Fix #548#559

Merged
phillip-stephens merged 3 commits into
mainfrom
ptr-handle-names
Sep 4, 2025
Merged

Fix #548#559
phillip-stephens merged 3 commits into
mainfrom
ptr-handle-names

Conversation

@zakird
Copy link
Copy Markdown
Member

@zakird zakird commented Sep 4, 2025

Fixes bug where we don't handle inputs like 8.8.8.8.in-addr.arpa correctly in the PTR module.

Resolves #548

@zakird zakird requested a review from a team as a code owner September 4, 2025 01:45
Comment thread src/zdns/lookup.go Outdated
return nil, nil, StatusIllegalInput, err
// q.Name is a valid name, we can continue
if err != nil {
if !util.IsStringValidDomainName(q.Name) {
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.

Seems like a good fix, the only thing I don't love is it's a bit hard to reason about the case where err != nil but util.IsStringValidDomainName == true. In that case, we skip the else which might not be best.

I'm thinking this will be flatter logically and thus easier to read

		if err != nil && !util.IsStringValidDomainName(q.Name) {
			return nil, nil, StatusIllegalInput, err
		} else if len(qname) > 0 && qname[len(qname)-1] == '.' {
			// remove trailing "." added by dns.ReverseAddr
			q.Name = qname[:len(qname)-1]
		}

If you agree, I'll make the fix. Tested it with the sample input and looks good 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure! I don't have a strong opinion on the logic.

@phillip-stephens phillip-stephens self-requested a review September 4, 2025 17:32
Copy link
Copy Markdown
Contributor

@phillip-stephens phillip-stephens left a comment

Choose a reason for hiding this comment

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

LGTM

@phillip-stephens phillip-stephens enabled auto-merge (squash) September 4, 2025 17:33
@phillip-stephens phillip-stephens merged commit 1e5db5e into main Sep 4, 2025
3 checks passed
@phillip-stephens phillip-stephens deleted the ptr-handle-names branch September 4, 2025 17:33
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.

Support reverse addr lookups like dig -x

2 participants