utils

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const WhoisTimeFmt = "2006-01-02T15:04:05+00:00"

WhoisTimeFmt is time format for CreatedDate, UpdatedDate and ExpiredDate Copied from domain package to avoid import cycle

Variables

View Source
var GlobalLoc *time.Location

GlobalLoc is global timezone for converting time format

Functions

func ConvTimeFmt

func ConvTimeFmt(timeStr, inFmt, outFmt string) (string, error)

ConvTimeFmt converts time from input format to output format

func ConvTimeFmtInLocation

func ConvTimeFmtInLocation(timeStr, inFmt, outFmt string, loc *time.Location) (string, error)

ConvTimeFmtInLocation converts time from input format with timezone to output format in UTC

func ExtractField

func ExtractField(line, prefix string) string

ExtractField extracts a field value that comes after a specific prefix. This is commonly used for parsing nameserver and other prefixed fields.

func ExtractValue

func ExtractValue(line string) string

ExtractValue extracts the value portion from a colon-separated line. It handles both "key: value" and "key:value" formats.

func ForceQueryPSPlusOne

func ForceQueryPSPlusOne(ps string) bool

If length of all the items in public suffix less than 3, force query publicsuffix + 1 first no matter it's ICANN-managed domain or not E.g. "co.uk", "jpn.com", "net.ua" -> true E.g. "github.io", "zhitomir.ua" -> false

func GetDescentLevel

func GetDescentLevel(ps string) string

GetDescentLevel get n-1 level of ps E.g., "abc.co.com" -> "co.com"

func GetGlobalLoc

func GetGlobalLoc() (*time.Location, error)

GetGlobalLoc get global timezone if set, else load again

func GetHost

func GetHost(domain string) (string, error)

GetHost fetch host from "<host>:<port>" string, and return input string if it does not contain port

func GetPublicSuffixs

func GetPublicSuffixs(domain string) ([]string, error)

GetPublicSuffixs returns public suffixs of input domain

func GetTLD

func GetTLD(ps string) string

return string after first ".", and return input string if it does not contains "." E.g,

GetTLD("aaa.aaa") = "aaa"
GetTLD("pooch.co.uk") = "co.uk"
GetTLD("com") = "com"

func GuessTimeFmt

func GuessTimeFmt(timeStr string, loc *time.Location) (time.Time, error)

GuessTimeFmt guesses input time string and converts to time object

func GuessTimeFmtAndConvert

func GuessTimeFmtAndConvert(timeStr, outFmt string) (string, error)

GuessTimeFmtAndConvert guesses input time string and converts to output format string

func HandleNameserverField

func HandleNameserverField(line string, prefix string, nameservers *[]string) bool

HandleNameserverField processes a nameserver field and adds it to the nameservers slice. Returns true if the line was processed as a nameserver field.

func InitContact

func InitContact() map[string]string

InitContact creates a new contact map with default empty values. This is used as a template for parsing contact information.

func InitRegistrar

func InitRegistrar() map[string]string

InitRegistrar creates a new registrar map with default empty values. This is used as a template for parsing registrar information.

func IsContactSection

func IsContactSection(line string) bool

IsContactSection determines if a line indicates the start of a contact section. It looks for common contact section headers in whois responses.

func IsIP

func IsIP(host string) bool

IsIP return true if input host string is a valid IP

func IsNameserverLine

func IsNameserverLine(line, prefix string) bool

IsNameserverLine checks if a line contains nameserver information with the given prefix.

func IsRegistrarLine

func IsRegistrarLine(line, prefix string) bool

IsRegistrarLine checks if a line contains registrar information with the given prefix.

func IsTimeout

func IsTimeout(err error) bool

IsTimeout return whether an error is classified as **timeout** error

func ParseDateField

func ParseDateField(line, prefix string) *time.Time

ParseDateField parses a date field from a line with the given prefix. Returns nil if the date cannot be parsed or if the line doesn't match the prefix.

func ParseNameServers

func ParseNameServers(lines []string) []string

ParseNameServers extracts name server entries from an array of lines. It looks for lines that appear to contain nameserver information.

func SetGlobalLoc

func SetGlobalLoc() (err error)

SetGlobalLoc set global timezone

func SkipLine

func SkipLine(line string) bool

SkipLine determines if a line should be skipped during parsing. It returns true for empty lines and comments starting with %.

func StrInArray

func StrInArray(val string, arr []string) bool

StrInArray returns whether item is in array

func UTCNow

func UTCNow() time.Time

UTCNow returns now in utc timezone

Types

This section is empty.

Jump to

Keyboard shortcuts

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