util

package
v0.6.29 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hours = 1
	Day   = 24
	Week  = 24 * 7
)

Variables

View Source
var DefaultCommentPrefixes = []string{
	"#",
	"//",
}

takes a line and removes commented section

View Source
var Json = jsoniter.Config{
	EscapeHTML:                    false,
	MarshalFloatWith6Digits:       true,
	ObjectFieldMustBeSimpleString: true,
	SortMapKeys:                   false,
	ValidateJsonRawMessage:        true,
	DisallowUnknownFields:         false,
}.Froze()

write all metrics out to encoder

Functions

func ByteSliceToString added in v0.6.24

func ByteSliceToString(bs []byte) string

from: https://github.com/golang/go/issues/25484

func ClearDirectory added in v0.1.7

func ClearDirectory(inputdir string)

clears the contents of a directory but leaves it

func DomainList added in v0.1.3

func DomainList(domain string) []string

based on a domain name ("sub.google.com") returns a slice of domains that should be matched EXACTLY against ["sub.google.com", "google.com", "com"]

func GetAnswerValues added in v0.3.2

func GetAnswerValues(response *dns.Msg) []string

func GetFileAsArray

func GetFileAsArray(inputfile string) ([]string, error)

func GetFirstIPResponse added in v0.3.2

func GetFirstIPResponse(response *dns.Msg) string

get the first A record response value

func GetRecordValue added in v0.3.2

func GetRecordValue(record interface{}) string

based on the string value for a RR

func IsEmptyResponse

func IsEmptyResponse(response *dns.Msg) bool

returns true if the response is "empty" nil response empty response (no answers or other sections) answers with no content

func IsRecordEmpty added in v0.6.14

func IsRecordEmpty(record interface{}) bool

func LineCount added in v0.3.15

func LineCount(inputfile string) (uint, error)

count file lines from: https://stackoverflow.com/a/24563853

func LookupNetBIOSName added in v0.3.17

func LookupNetBIOSName(address string) (string, error)

this is an experimental feature pulled from: https://github.com/jpillora/icmpscan i made some changes to make it a little more readable and, more importantly, to set the outbound dns flags to 0 so this would work

func ParseDuration added in v0.3.17

func ParseDuration(input string) (time.Duration, error)

func ReverseDomainTree

func ReverseDomainTree(domain string) string

take a domain like "sub.main.top.tld" and transform to "tld.top.main.sub"

func ReverseLookupDomain

func ReverseLookupDomain(ip *net.IP) string

returns the reverse lookup arpa domain for the given IP

func ReverseLookupDomainString

func ReverseLookupDomainString(ipString string) string

func SaferBytes added in v0.6.21

func SaferBytes(input string) []byte

func StartsWithAny

func StartsWithAny(value string, any []string) bool

func StringIn

func StringIn(value string, in []string) bool

determines if the given string is in the array of strings

func SubDomain

func SubDomain(domain string) string

finds the subdomain of a requested domain, so "www.google.com" returns "google.com" and "google.com" returns "google.com"

func TrimComments added in v0.4.8

func TrimComments(line string, commentPrefixes ...string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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