build

package
v1.0.4661 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeLength specifies a length constraint for labels.
	// The Policy.Key will be "min" or "max".
	TypeLength = "length"

	// KeyMin specifies a mininum length constraint for a label.
	KeyMin = "min"

	// KeyMax specifies a maximum length constraint for a label.
	KeyMax = "max"

	// TypeIDNTable specifies a location for an IDN table a language or script.
	TypeIDNTable = "idn-table"

	// TypeIDNDisallowed specifies that IDN labels are disallowed by the operator for this zone.
	TypeIDNDisallowed = "idn-disallowed"
)
View Source
const (
	TagAdult          = "adult"
	TagBrand          = "brand"
	TagCity           = "city"
	TagClosed         = "closed"
	TagCommunity      = "community"
	TagCountry        = "country"
	TagGeneric        = "generic"
	TagGeo            = "geo"
	TagInfrastructure = "infrastructure"
	TagPrivate        = "private"
	TagRegion         = "region"
	TagReserved       = "reserved"
	TagRetired        = "retired"
	TagSpecial        = "special"
	TagSponsored      = "sponsored"
	TagTest           = "test"
	TagWithdrawn      = "withdrawn"
)

Well-known tags

Variables

View Source
var (
	// Concurrency specifies the maximimum number of concurrent build operations to execute.
	Concurrency = 32

	// Timeout specifies the maximum duration to wait for network operations to complete.
	Timeout = 10 * time.Second
)
View Source
var BaseDir = "."

BaseDir specifies the base working directory that contains the ZoneDB flat-file database.

View Source
var (
	// Verbose enables verbose logging
	Verbose bool
)

Functions

func AddLanguages

func AddLanguages(zones map[string]*Zone, languages []string)

func AddLocations

func AddLocations(zones map[string]*Zone, locations []string)

func AddRDAPURLs

func AddRDAPURLs(zones map[string]*Zone, urls []string)

func AddTags

func AddTags(zones map[string]*Zone, tags []string)

AddTags adds one or more tags to a Zone.

func CanDial

func CanDial(network, addr string) error

CanDial verifies if possible to connect to a given network and address. Returns nil for successful dial or an error.

func CheckPublicSuffix

func CheckPublicSuffix(zones map[string]*Zone)

CheckPublicSuffix compares the zones against the Public Suffix List.

func CloseN

func CloseN(rc io.ReadCloser, n int64) (int64, error)

CloseN drains rc up to a maximum of n bytes and closes rc. It returns the number of bytes drained and the first error encountered. Regardless of any errors, rc.Close() is guaranteed to be called.

func CountNameServers

func CountNameServers(zones map[string]*Zone)

CountNameServers counts unique name servers for zones.

func Fetch

func Fetch(u string) (*http.Response, error)

Fetch fetches a URL.

func FetchGTLDsFromICANN

func FetchGTLDsFromICANN(zones map[string]*Zone) error

FetchGTLDsFromICANN retrieves the list of gTLDs from ICANN.

func FetchIDNTablesFromIANA

func FetchIDNTablesFromIANA(zones map[string]*Zone) error

FetchIDNTablesFromIANA fetches IDN table references from the IANA website.

func FetchNameServers

func FetchNameServers(zones, allZones map[string]*Zone) error

FetchNameServers fetches NS records for zones.

func FetchRDAPFromIANA

func FetchRDAPFromIANA(zones map[string]*Zone) error

FetchRDAPFromIANA retrieves the map of zones to RDAP service endpoints from IANA.

func FetchRootZone

func FetchRootZone(zones map[string]*Zone, addNew bool) error

FetchRootZone fetches the IANA root zone file and adds name servers to zones.

func FetchRubyWhoisServers

func FetchRubyWhoisServers(zones map[string]*Zone, addNew bool) error

FetchRubyWhoisServers fetches whois servers from the Ruby Whois project.

func FetchSpecialUseDomainsFromIANA

func FetchSpecialUseDomainsFromIANA(zones map[string]*Zone, addNew bool) error

FetchSpecialUseDomainsFromIANA fetches special use domains from the IANA website.

func FindWildcards

func FindWildcards(zones map[string]*Zone) error

FindWildcards finds wildcard DNS records for a zone.

func GenerateGo

func GenerateGo(zones map[string]*Zone) error

GenerateGo generates a Go source representation of ZoneDB.

func GuessLanguages

func GuessLanguages(zones map[string]*Zone)

func IndexOfString

func IndexOfString(haystack []string, s string) (int, int)

IndexOfString finds s as a substring in haystack, returning the index and offset of s in haystack. Returns -1, -1 if s is not present in haystack.

func IndexOfStrings

func IndexOfStrings(haystack []string, needle []string) int

IndexOfStrings finds a rank-sorted slice of domain names (needle) within a larger slice (haystack).

func IndexOrAppendString

func IndexOrAppendString(haystack *[]string, s string) (int, int, int)

IndexOrAppendString finds or adds s to haystack, returning the index and offset of s in haystack. Returns 0, 0, 0 for an empty string.

func IndexOrAppendStrings

func IndexOrAppendStrings(haystack *[]string, needle []string) (int, int)

IndexOrAppendStrings finds or appends a slice of rank-sorted domain names (needle) Returns 0,0 for a zero-length needle.

func LogError

func LogError(err error)

LogError logs an error to stderr.

func LogFatal

func LogFatal(err error)

LogFatal logs an error to stderr and exits with a non-zero exit code.

func LogWarning

func LogWarning(err error)

LogWarning logs an error to stderr as a warning.

func LogWarningFor

func LogWarningFor(err error, label string)

LogWarningFor logs an error to stderr for a given label.

func LogWarningForAt

func LogWarningForAt(err error, label string, offset int)

LogWarningForAt logs a warning to stderr for a given label and offset.

func Normalize

func Normalize(s string) string

Normalize normalizes a domain name into valid, lowercase, Unicode form.

func NormalizeDomains

func NormalizeDomains(in []string) []string

NormalizeDomains normalizes a slice of domain names. Returns a sorted, de-duplicated, normalized list of domain names.

func NormalizeURL

func NormalizeURL(s string) string

NormalizeURL normalizes the domain name part of a URL, with a Unicode (non-IDNA encoded) hostname. Returns a blank string if it is unable to parse s as a valid URL.

func QueryIANA

func QueryIANA(zones map[string]*Zone) error

QueryIANA fetches whois data from whois.iana.org.

func QueryWhoisServers

func QueryWhoisServers(zones map[string]*Zone) error

QueryWhoisServers queries whois-servers.net for CNAME’d whois servers.

func ReadMetadata

func ReadMetadata(zones map[string]*Zone) (errs []error)

ReadMetadata reads JSON files for each zone in the metadata directory.

func ReadZones

func ReadZones() (zones map[string]*Zone, errs []error)

ReadZones reads the zone database from the local filesystem.

func ReadZonesFile

func ReadZonesFile() (zones map[string]*Zone, errs []error)

ReadZonesFile reads and parses the zones.txt file.

func RemoveLocations

func RemoveLocations(zones map[string]*Zone, locations []string)

func RemoveTags

func RemoveTags(zones map[string]*Zone, tags []string)

RemoveTags removes one or more tags from a Zone.

func Sort

func Sort(domains []string)

Sort sorts a slice of domain names by rank. Rank sort defined as: 1. Label count (TLDs followed by second- and third-level domains), then 2. lexically sorted reversed label order (TLD first, then second-level label, etc.) Example: com, net, org, uk, uk.com, ac.uk, co.uk, ...

func SortedDomains

func SortedDomains(zones map[string]*Zone) []string

SortedDomains returns a list of domain names sorted by rank.

func TLDs

func TLDs(zones map[string]*Zone) map[string]*Zone

TLDs filters a zone set for top-level domains.

func ToASCII

func ToASCII(s string) string

ToASCII normalizes a domain name to ASCII/punycode.

func ToASCIIURL

func ToASCIIURL(s string) string

ToASCIIURL normalizes the domain name part of a URL to ASCII/punycode.

func Trace

func Trace(spec string, args ...interface{})

Trace logs an error to stderr.

func UpdateInfoURLs

func UpdateInfoURLs(zones map[string]*Zone)

func ValidateTags added in v1.0.4155

func ValidateTags(zones map[string]*Zone) error

ValidateTags validates tags in one or more zones.

func VerifyNameServers

func VerifyNameServers(zones map[string]*Zone)

VerifyNameServers verifies the name servers for zones.

func VerifyWhois

func VerifyWhois(zones map[string]*Zone)

VerifyWhois verifies that the whois servers respond on TCP port 43.

func WriteMetadata

func WriteMetadata(zones map[string]*Zone, delete bool) error

WriteMetadata writes the metadata/*.json files.

func WriteZonesFile

func WriteZonesFile(zones map[string]*Zone) error

WriteZonesFile writes the zones.txt file.

Types

type ISODate

type ISODate struct {
	time.Time
}

func (*ISODate) UnmarshalJSON

func (d *ISODate) UnmarshalJSON(b []byte) error

type Policy

type Policy struct {
	Type    string `json:"type"`
	Key     string `json:"key,omitempty"`
	Value   string `json:"value,omitempty"`
	Comment string `json:"comment,omitempty"`
}

Policy represents a registry or technical policy applicable to subdomains of a zone.

type Set

type Set map[string]bool

Set implements a unique set of strings.

func NewSet

func NewSet(vals ...string) Set

NewSet creates a new set from the supplied values.

func (Set) Add

func (set Set) Add(vals ...string)

Add inserts a string into a set. Underlying map enforces uniqueness.

func (Set) Values

func (set Set) Values() []string

Values returns a sorted slice of the set’s values.

type Zone

type Zone struct {
	Domain           string   `json:"domain,omitempty"`
	RegistryOperator string   `json:"registryOperator,omitempty"`
	InfoURL          string   `json:"infoURL,omitempty"`
	WhoisServer      string   `json:"whoisServer,omitempty"`
	WhoisURL         string   `json:"whoisURL,omitempty"`
	RDAPURLs         []string `json:"rdapURLs,omitempty"`
	NameServers      []string `json:"nameServers,omitempty"`
	Wildcards        []string `json:"wildcards,omitempty"`
	Locations        []string `json:"locations,omitempty"`
	Languages        []string `json:"languages,omitempty"`
	Tags             []string `json:"tags,omitempty"`
	Policies         []Policy `json:"policies,omitempty"`

	// Exported for use in text/template
	IDNDisallowed                                 bool   `json:"-"`
	ParentOffset, SubdomainsOffset, SubdomainsEnd int    `json:"-"`
	TagBits                                       uint64 `json:"-"`
	// contains filtered or unexported fields
}

Zone represents a build-time DNS zone (public suffix).

func (*Zone) ASCII

func (z *Zone) ASCII() string

ASCII returns the ACE encoded form of the Zone’s label(s).

func (*Zone) AddPolicy

func (z *Zone) AddPolicy(ptype, key, value, comment string)

AddPolicy adds a single policy to Zone z.

func (*Zone) AddTags

func (z *Zone) AddTags(tags ...string) int

AddTags adds tags to z, returning the number of tag(s) added, if any.

func (*Zone) HasMetadata

func (z *Zone) HasMetadata() bool

HasMetadata returns true if the Zone has any metadata necessary for emitting a metadata JSON file.

func (*Zone) IsBrand

func (z *Zone) IsBrand() bool

Brand TLDs have tag "brand".

func (*Zone) IsGeneric

func (z *Zone) IsGeneric() bool

IsGeneric returns true if the zone is generic.

func (*Zone) IsIDN

func (z *Zone) IsIDN() bool

IsIDN returns true if the Zone label(s) use non-ASCII characters.

func (*Zone) IsRetiredOrWithdrawn

func (z *Zone) IsRetiredOrWithdrawn() bool

IsRetiredOrWithdrawn returns true if the zone is retired or withdrawn.

func (*Zone) IsTLD

func (z *Zone) IsTLD() bool

IsTLD returns true if z is a TLD.

func (*Zone) Normalize

func (z *Zone) Normalize()

Normalize formats a build.Zone into normal form suitable for serialization.

func (*Zone) ParentDomain

func (z *Zone) ParentDomain() string

ParentDomain returns the parent domain name (if any) for the Zone.

func (*Zone) RemoveTags

func (z *Zone) RemoveTags(tags ...string) int

RemoveTags removes tags from z, returning the number of tag(s) removed, if any.

Jump to

Keyboard shortcuts

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