util

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnswerToString

func AnswerToString(answer []dns.RR) string

AnswerToString creates a user-friendly representation of an answer

func Chunks

func Chunks(s string, chunkSize int) []string

Chunks splits the string in multiple chunks

func CreateAnswerFromQuestion

func CreateAnswerFromQuestion(question dns.Question, ip net.IP, remainingTTL uint32) (dns.RR, error)

CreateAnswerFromQuestion creates new answer from a question

func ExtractDomain

func ExtractDomain(question dns.Question) string

ExtractDomain returns domain string from the question

func ExtractDomainOnly

func ExtractDomainOnly(in string) string

ExtractDomainOnly extracts domain from the DNS query

func FatalOnError

func FatalOnError(message string, err error)

FatalOnError logs the message only if error is not nil and exits the program execution

func IterateValueSorted

func IterateValueSorted(in map[string]int, fn func(string, int))

IterateValueSorted iterates over maps value in a sorted order and applies the passed function

func LogOnError

func LogOnError(message string, err error)

LogOnError logs the message only if error is not nil

func LogOnErrorWithEntry

func LogOnErrorWithEntry(logEntry *logrus.Entry, message string, err error)

LogOnErrorWithEntry logs the message only if error is not nil

func NewMsgWithAnswer

func NewMsgWithAnswer(domain string, ttl uint, dnsType uint16, address string) (*dns.Msg, error)

NewMsgWithAnswer creates new DNS message with answer

func NewMsgWithQuestion

func NewMsgWithQuestion(question string, mType uint16) *dns.Msg

NewMsgWithQuestion creates new DNS message with question

func QuestionToString

func QuestionToString(questions []dns.Question) string

QuestionToString creates a user-friendly representation of a question

Types

This section is empty.

Jump to

Keyboard shortcuts

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