Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,19 @@ All long form (--) flags can be toggled with the dig-standard +[no]flag notation
// Skip if already an in-addr.arpa or ip6.arpa name
lowerName := strings.ToLower(opts.Name)
if !strings.HasSuffix(lowerName, ".in-addr.arpa") && !strings.HasSuffix(lowerName, ".ip6.arpa") {
// Allow underscores during IDNA conversion
_asciiName := strings.ReplaceAll(opts.Name, "_", "..")
asciiName, err := idna.Lookup.ToASCII(_asciiName)
// Use a custom IDNA profile to allow underscores (non-LDH characters).
// Standard IDNA Lookup enforces STD3 rules which forbid underscores,
// but they are valid in DNS records (e.g. TXT, SRV).
p := idna.New(
idna.MapForLookup(),
idna.StrictDomainName(false),
)

asciiName, err := p.ToASCII(opts.Name)
if err != nil {
return fmt.Errorf("idna toascii: %s", err)
}
opts.Name = strings.ReplaceAll(asciiName, "..", "_")
opts.Name = asciiName
}
}

Expand Down
Loading