domain

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package domain parses DNS domain names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortDomains

func SortDomains(s []Domain)

SortDomains sorts a list of domains according to their ASCII representations.

func StringToASCII added in v1.7.2

func StringToASCII(domain string) string

StringToASCII normalizes a domain with best efforts, ignoring errors.

Types

type Domain

type Domain interface {
	// DNSNameASCII gives a name suitable for accessing the Cloudflare API
	DNSNameASCII() string

	// Describe gives the most human-readable domain name that is still unambiguous
	Describe() string

	// Split gives a Splitter that can be used to find zones
	Split() Splitter
}

A Domain represents a domain name to update.

func New

func New(domain string) (Domain, error)

NewDomain normalizes a domain to its ASCII form and then stores the normalized domain in its Unicode form when the round trip gives back the same ASCII form without errors. Otherwise, the ASCII form (possibly using Punycode) is stored to avoid ambiguity.

type FQDN

type FQDN string

FQDN is a fully qualified domain in its ASCII form.

func (FQDN) DNSNameASCII

func (f FQDN) DNSNameASCII() string

DNSNameASCII retruns the ASCII form of the FQDN.

func (FQDN) Describe

func (f FQDN) Describe() string

Describe gives a human-readible representation of the FQDN.

func (FQDN) Split

func (f FQDN) Split() Splitter

Split constructs a FQDNSplitter for the FQDN.

type FQDNSplitter

type FQDNSplitter struct {
	// contains filtered or unexported fields
}

FQDNSplitter implements Splitter for a FQDN.

func (*FQDNSplitter) IsValid

func (s *FQDNSplitter) IsValid() bool

IsValid checks whether the cursor is still valid.

func (*FQDNSplitter) Next

func (s *FQDNSplitter) Next()

Next moves the cursor to the next spltting point. Call [IsValid] to check whether the resulting cursor is valid.

func (*FQDNSplitter) ZoneNameASCII

func (s *FQDNSplitter) ZoneNameASCII() string

ZoneNameASCII gives the ASCII form of the current zone suffix.

type Splitter

type Splitter interface {
	// IsValid checks whether the cursor is still valid.
	IsValid() bool

	// ZoneNameASCII gives the suffix after the cursor as a possible zone, if the cursor is still valid.
	ZoneNameASCII() string

	// Next moves the cursor to the next possible splitting point, which might end up being invalid.
	Next()
}

A Splitter enumerates all possible zones of a domain by moving a cursor from the start of the domain's name to its end.

type Wildcard

type Wildcard string

Wildcard is a fully qualified zone name in its ASCII form, represnting the wildcard domain name under the zone. For example, Wildcard("example.org") represents *.example.org.

func (Wildcard) DNSNameASCII

func (w Wildcard) DNSNameASCII() string

DNSNameASCII retruns the ASCII form of the wildcard domain.

func (Wildcard) Describe

func (w Wildcard) Describe() string

Describe gives a human-readible representation of the wildcard domain.

func (Wildcard) Split

func (w Wildcard) Split() Splitter

Split constructs a Splitter for a wildcard domain.

type WildcardSplitter

type WildcardSplitter struct {
	// contains filtered or unexported fields
}

WildcardSplitter implements Splitter for a wildcard domain.

func (*WildcardSplitter) IsValid

func (s *WildcardSplitter) IsValid() bool

IsValid checks whether the cursor is still valid.

func (*WildcardSplitter) Next

func (s *WildcardSplitter) Next()

Next moves the cursor to the next spltting point. Call WildcardSplitter.IsValid to check whether the resulting cursor is valid.

func (*WildcardSplitter) ZoneNameASCII

func (s *WildcardSplitter) ZoneNameASCII() string

ZoneNameASCII gives the ASCII form of the current zone suffix.

Jump to

Keyboard shortcuts

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