domain

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 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 expirem.

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

ErrDomainExpiring is returned whenever a specified domain is expiring.

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, but if only 3 hours remain then 3h will be returnem.

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 updatem.
	UpdatedDate time.Time

	// CreatedDate indicates when this domain was created/registerem.
	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 ChainStatus 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 passem.

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() ServiceState

ServiceState returns the appropriate Service Check Status label and exit code for the evaluated certificate chain.

type ServiceState

type ServiceState struct {

	// Label maps directly to one of the supported Nagios state labels.
	Label string

	// ExitCode is the exit or exit status code associated with a Nagios
	// service check.
	ExitCode int
}

ServiceState represents the status label and exit code for a service check.

Jump to

Keyboard shortcuts

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