util

package
v5.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PublicNetworkUUID         = uuid.MustParse("ffffffff-ffff-ffff-ffff-ffffffffffff")
	PublicNetworkName         = "Public"
	UnknownPrivateNetworkUUID = uuid.MustParse("ffffffff-ffff-ffff-ffff-fffffffffffe")
	UnknownPrivateNetworkName = "Unknown Private"

	ErrInvalidPath = errors.New("path cannot be empty string")

	ErrFileDoesNotExist = errors.New("file does not exist")
	ErrFileIsEmtpy      = errors.New("file is empty")
	ErrPathIsDir        = errors.New("given path is a directory, not a file")

	ErrDirDoesNotExist = errors.New("directory does not exist")
	ErrDirIsEmpty      = errors.New("directory is empty")
	ErrPathIsNotDir    = errors.New("given path is not a directory")
)

Functions

func CheckForNewerVersion

func CheckForNewerVersion(client *github.Client, currentVersion string) (bool, string, error)

CheckForNewerVersion checks if a newer version of the project is available on the GitHub repository

func ContainsDomain

func ContainsDomain(domains []string, host string) bool

ContainsDomain checks if a given host is in a list of domains

func ContainsIP

func ContainsIP(subnets []*net.IPNet, ip net.IP) bool

ContainsIP checks if a collection of subnets contains an IP

func EnsureSliceContainsAll

func EnsureSliceContainsAll(data []string, mandatory []string) []string

EnsureSliceContainsAll ensures that a given slice contains all elements of a mandatory list

func GetLatestReleaseVersion added in v5.0.5

func GetLatestReleaseVersion(client *github.Client, owner, repo string) (string, error)

GetLatestReleaseVersion gets the latest release version from the GitHub repository

func GetRelativeFirstSeenTimestamp

func GetRelativeFirstSeenTimestamp(useCurrentTime bool, maxTimestamp time.Time) time.Time

GetRelativeFirstSeenTimestamp returns the timestamp to use for first seen calculation/display. This is a shortcut for a commonly used if statement

func IPIsPubliclyRoutable

func IPIsPubliclyRoutable(ip net.IP) bool

IPIsPubliclyRoutable checks if an IP address is publicly routable. See privateIPBlocks.

func ParseNetworkID

func ParseNetworkID(ip net.IP, agentID string) uuid.UUID

ParseNetworkID returns the network ID for a given IP address and agent ID

func ParseRelativePath

func ParseRelativePath(dir string) (string, error)

ParseRelativePath parses a given directory path and returns the absolute path

func ParseSubnets

func ParseSubnets(subnets []string) ([]*net.IPNet, error)

ParseSubnets parses the provided subnets into net.IPNet format

func SortUInt32s

func SortUInt32s(data []uint32)

SortUInt32s sorts a slice of uint32 in ascending order

func UInt32sAreSorted

func UInt32sAreSorted(data []uint32) bool

UInt32sAreSorted returns true if a slice of uint32 is sorted in ascending order

func ValidFQDN

func ValidFQDN(value string) bool

func ValidateDirectory

func ValidateDirectory(afs afero.Fs, dir string) error

ValidateDirectory returns whether a directory exists and is empty

func ValidateFile

func ValidateFile(afs afero.Fs, file string) error

Validate File

func ValidateTimestamp

func ValidateTimestamp(timestamp time.Time) (time.Time, bool)

Types

type FixedString

type FixedString struct {
	Data [16]byte
	// contains filtered or unexported fields
}

func NewFixedStringFromHex

func NewFixedStringFromHex(h string) (FixedString, error)

NewFixedStringFromString creates a FixedString from a passed in hex string

func NewFixedStringHash

func NewFixedStringHash(args ...string) (FixedString, error)

NewFixedStringHash creates a FixedString from a hash of all the passed in strings

func (*FixedString) Hex

func (bin *FixedString) Hex() string

func (FixedString) MarshalBinary

func (bin FixedString) MarshalBinary() ([]byte, error)

Returns expected type for writing to the database

func (*FixedString) UnmarshalBinary

func (bin *FixedString) UnmarshalBinary(b []byte) error

Returns expected type for reading from the database

func (FixedString) Value

func (bin FixedString) Value() (driver.Value, error)

Returns value of FixedString as a pointer, used when sometimes writing to database

Jump to

Keyboard shortcuts

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