domainname

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package domainname owns the Draft-09 Section 18 conversion of protocol domain names from U-labels to A-labels.

Input is treated as a protocol label sequence, not as browser or user input: ASCII letters are case-folded, but no Unicode compatibility mapping, width folding, alternate dot separators, or transitional processing is applied. U-labels must already be NFC and valid under the IDNA2008 registration profile of golang.org/x/net/idna, including the Bidi and joiner rules; existing A-labels are validated by decoding. Output is a lowercase ASCII A-label domain. A failure never returns partial output.

Plain ASCII names without an "xn--" label take an LDH fast path that keeps their previous handling; it does not apply the IDNA hyphen rule for reserved "??--" labels, which is harmless for DNS lookup and comparison.

Known limitation: golang.org/x/net/idna collapses the IDNA2008 NV8 and XV8 categories into "valid", so it is not a complete strict IDNA2008 validator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsASCII

func IsASCII(domain []byte) bool

IsASCII reports whether domain contains only ASCII bytes, which is the form Draft-09 Section 18 requires for domains recorded in DKIM2 header fields.

func ToASCII

func ToASCII(domain []byte) (string, bool)

ToASCII converts one DNS domain name in U-label or A-label form to its lowercase A-label form. It rejects empty input, leading or trailing dots, empty labels, labels outside letter/digit/hyphen form after conversion, and names longer than 253 octets.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL