Documentation
¶
Index ¶
- Variables
- func CheckForNewerVersion(client *github.Client, currentVersion string) (bool, string, error)
- func ContainsDomain(domains []string, host string) bool
- func ContainsIP(subnets []Subnet, ip net.IP) bool
- func GetFileContents(afs afero.Fs, path string) ([]byte, error)
- func GetLatestReleaseVersion(client *github.Client, owner, repo string) (string, error)
- func GetRelativeFirstSeenTimestamp(useCurrentTime bool, maxTimestamp time.Time) time.Time
- func IPIsPubliclyRoutable(ip net.IP) bool
- func ParseNetworkID(ip net.IP, agentID string) uuid.UUID
- func ParseRelativePath(dir string) (string, error)
- func SortUInt32s(data []uint32)
- func UInt32sAreSorted(data []uint32) bool
- func ValidFQDN(value string) bool
- func ValidateDirectory(afs afero.Fs, dir string) error
- func ValidateFile(afs afero.Fs, file string) error
- func ValidateTimestamp(timestamp time.Time) (time.Time, bool)
- type FixedString
- type Subnet
- func CompactSubnets(subnets []Subnet) []Subnet
- func IncludeMandatorySubnets(data []Subnet, mandatory []Subnet) []Subnet
- func NewSubnet(ipNet *net.IPNet) Subnet
- func NewSubnetList(subnets []string) ([]Subnet, error)
- func NewTestSubnetList(t *testing.T, subnets []string) []Subnet
- func ParseSubnet(str string) (Subnet, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrParseCIDREmptyString = fmt.Errorf("unable to parse CIDR as subnet, empty string") ErrParseCIDRInvalidIP = fmt.Errorf("unable to parse CIDR as subnet, invalid IP address") ErrParseCIDRInvalidMask = fmt.Errorf("unable to parse CIDR as subnet, invalid mask") ErrIPIsNil = fmt.Errorf("ip is nil") )
var ( PublicNetworkUUID = uuid.MustParse("ffffffff-ffff-ffff-ffff-ffffffffffff") PublicNetworkName = "Public" UnknownPrivateNetworkUUID = uuid.MustParse("ffffffff-ffff-ffff-ffff-fffffffffffe") UnknownPrivateNetworkName = "Unknown Private" ErrFileSystemIsNil = errors.New("filesystem is nil") 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") ErrFetchingLatestRelease = errors.New("error fetching latest release") ErrParsingCurrentVersion = errors.New("error parsing current version") ErrParsingLatestVersion = errors.New("error parsing latest version") )
Functions ¶
func CheckForNewerVersion ¶
CheckForNewerVersion checks if a newer version of the project is available on the GitHub repository
func ContainsDomain ¶
ContainsDomain checks if a given host is in a list of domains
func ContainsIP ¶
ContainsIP checks if a collection of subnets contains an IP
func GetFileContents ¶ added in v5.1.0
GetFileContents reads the contents of a file at the specified path
func GetLatestReleaseVersion ¶ added in v5.0.5
GetLatestReleaseVersion gets the latest release version from the GitHub repository
func GetRelativeFirstSeenTimestamp ¶
GetRelativeFirstSeenTimestamp returns the timestamp to use for first seen calculation/display. This is a shortcut for a commonly used if statement
func IPIsPubliclyRoutable ¶
IPIsPubliclyRoutable checks if an IP address is publicly routable
func ParseNetworkID ¶
ParseNetworkID returns the network ID for a given IP address and agent ID
func ParseRelativePath ¶
ParseRelativePath parses a given directory path and returns the absolute path
func SortUInt32s ¶
func SortUInt32s(data []uint32)
SortUInt32s sorts a slice of uint32 in ascending order
func UInt32sAreSorted ¶
UInt32sAreSorted returns true if a slice of uint32 is sorted in ascending order
func ValidateDirectory ¶
ValidateDirectory returns whether a directory exists and is empty
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
type Subnet ¶ added in v5.1.0
func CompactSubnets ¶ added in v5.1.0
CompactSubnets removes duplicate Subnets from a given slice
func IncludeMandatorySubnets ¶ added in v5.1.0
IncludeMandatorySubnets ensures that a given slice of Subnets contains all elements of a mandatory list
func NewSubnetList ¶ added in v5.1.0
NewSubnetList creates a list of Subnet structs from a list of strings
func NewTestSubnetList ¶ added in v5.1.0
NewTestSubnetList creates a list of Subnet structs from a list of strings, but asserts no error using testing library (used for tests in other packages too, so it must be in the non-test file)
func ParseSubnet ¶ added in v5.1.0
ParseSubnet parses a CIDR string into a Subnet struct, which is formatted as IPv6 It supports both IPv4 and IPv6 CIDRs, as well as IPv4 in IPv6 CIDRs
func (*Subnet) MarshalJSON ¶ added in v5.1.0
MarshalJSON marshals the Subnet struct into JSON bytes The IP is formatted into its most human readable format. If the CIDR mask is full/max (128 or 32), then it is not displayed. For IPv4, the address is specifically formatted to not display IPv4 in IPv6.
func (*Subnet) Scan ¶ added in v5.1.0
Scan implements the sql.Scanner interface for the Subnet struct; allows for scanning a Subnet struct from a database query
func (*Subnet) ToIPString ¶ added in v5.1.0
ToIPString gets string representation of the IP address in the Subnet struct The CIDR is always included. IPv4 is always formatted as IPv4 in IPv6.
func (*Subnet) ToIPv6Notation ¶ added in v5.1.0
func (s *Subnet) ToIPv6Notation()
func (*Subnet) ToString ¶ added in v5.1.0
ToString converts the Subnet struct to a proper string representation of the CIDR
func (*Subnet) UnmarshalJSON ¶ added in v5.1.0
UnmarshalJSON unmarshals the JSON bytes into the IPNet struct overrides the default unmarshalling method to allow for custom parsing