domain

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package domain provides common/shared utility code to support applications in this module which process domain metdata.

Index

Constants

View Source
const DomainDateLayout string = "2006-01-02 15:04:05 -0700 MST"

DomainDateLayout is the chosen date layout for displaying domain created/expiration date/time values across our application.

Variables

View Source
var ErrDomainExpired = errors.New("domain has expired")

ErrDomainExpired is returned whenever a specified domain has expired.

View Source
var ErrDomainExpiring = errors.New("domain is expiring")

ErrDomainExpiring is returned whenever a specified domain is expiring.

View Source
var ErrMissingValue = errors.New("missing expected value")

ErrMissingValue indicates that an expected value was missing.

Functions

func FormattedExpiration

func FormattedExpiration(expireTime time.Time) string

FormattedExpiration receives a Time value and converts it to a string representing the largest useful whole units of time in days and hours. For example, if a domain has 1 year, 2 days and 3 hours remaining until expiration, this function will return the string '367d 3h remaining', but if only 3 hours remain then '3h remaining' will be returned. If a domain registration has expired, the 'ago' suffix will be used instead. For example, if a domain has expired 3 hours ago, '3h ago' will be returned.

func SinceCreation added in v0.4.0

func SinceCreation(d *Metadata) (int, error)

SinceCreation evaluates the given domain metadata and returns the number of days since the domain metadata was first created.

An error is returned if the pointer to the given domain metadata is nil.

func SinceUpdate added in v0.4.0

func SinceUpdate(d *Metadata) (int, error)

SinceUpdate evaluates the given domain metadata and returns the number of days since the domain metadata was last updated.

An error is returned if the pointer to the given domain metadata is nil.

func UntilExpiration added in v0.4.0

func UntilExpiration(d *Metadata) (int, error)

UntilExpiration evaluates the given domain metadata and returns the number of days until the domain expires. If already expired, a negative number is returned indicating how many days the domain is past expiration.

An error is returned if the pointer to the given domain metadata is nil.

Types

type Metadata

type Metadata struct {

	// Results from parsing the WHOIS info. Most fields are plain text values.
	WhoisInfo whoisparser.WhoisInfo

	// Name is the plaintext label for this domain.
	Name string

	// ExpirationDate indicates when this domain expires.
	ExpirationDate time.Time

	// UpdatedDate indicates when the domain WHOIS metadata was last updated.
	UpdatedDate time.Time

	// CreatedDate indicates when this domain was created/registered.
	CreatedDate time.Time

	// AgeWarningThreshold is the specified age threshold for when domains
	// with an expiration less than this value are considered to be in a
	// WARNING state.
	AgeWarningThreshold time.Time

	// AgeCRITICALThreshold is the specified age threshold for when domains
	// with an expiration less than this value are considered to be in a
	// CRITICAL state.
	AgeCriticalThreshold time.Time
}

Metadata represents the details for a specified domain, including the parsed WHOIS info, expiration (age) thresholds and parsed date values.

func NewDomain

func NewDomain(whoisInfo whoisparser.WhoisInfo, ageWarning time.Time, ageCritical time.Time) (*Metadata, error)

NewDomain instantiates a new Metadata type from parsed WHOIS data.

func (Metadata) IsCriticalState

func (m Metadata) IsCriticalState() bool

IsCriticalState indicates whether a domain's expiration date has been determined to be in a CRITICAL state. This returns false if the expiration date is in an OK or WARNING state, true otherwise.

func (Metadata) IsExpired

func (m Metadata) IsExpired() bool

IsExpired indicates whether the domain expiration date has passed.

func (Metadata) IsExpiring

func (m Metadata) IsExpiring() bool

IsExpiring compares the domain's current expiration date against the provided CRITICAL and WARNING thresholds to determine if the domain is about to expire.

func (Metadata) IsOKState

func (m Metadata) IsOKState() bool

IsOKState indicates whether a domain's expiration date has been determined to be in an OK state, without expired or expiring domain registration.

func (Metadata) IsWarningState

func (m Metadata) IsWarningState() bool

IsWarningState indicates whether a domain's expiration date has been determined to be in a WARNING state. This returns false if the expiration date is in an OK or CRITICAL state, true otherwise.

func (Metadata) OneLineCheckSummary

func (m Metadata) OneLineCheckSummary() string

OneLineCheckSummary generates a one-line summary of the domain WHOIS check results for display and notification purposes.

func (Metadata) Report

func (m Metadata) Report() string

Report provides an overview of domain details appropriate for display as the LongServiceOutput provided via the web UI or as email or Teams notifications.

func (Metadata) ServiceState

func (m Metadata) ServiceState() nagios.ServiceState

ServiceState returns the appropriate Service Check Status label and exit code for the evaluated domain expiration metadata.

Jump to

Keyboard shortcuts

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