utils

package
v0.0.0-...-103085b Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgMaxTTL = 60 * 60 * 24 // 86400

	// min ttl for cached msgs
	MsgMinTTL = 15

	// https://www.netmeister.org/blog/dns-size.html
	MaxMsgSize = 1232
)

Variables

This section is empty.

Functions

func AnsIsError

func AnsIsError(ans *dns.Msg) bool

func ConverFromBytes

func ConverFromBytes(b int64) string

func ConvertToBytes

func ConvertToBytes(s string) (int64, error)

func IsAddrInNetwork

func IsAddrInNetwork(addr string, networks []string) (bool, error)

IsAddrInNetwork checks if an address is contained into any of the networks defined in denyNet Example: allowedNets := []string{"172.17.0.0/16"} addr := "172.17.0.2" returns true

func IsArpa

func IsArpa(name string) bool

func IsClientAllowed

func IsClientAllowed(client net.Addr, allowedNets []string) (bool, error)

func MsgCleanup

func MsgCleanup(ans *dns.Msg, req *dns.Msg) *dns.Msg

MsgCleanup prepares the answer to be returned to the client exluding not requested records

func MsgExtractByType

func MsgExtractByType(msg *dns.Msg, typ uint16, name string) []dns.RR

MsgExtractRRByType detects if an answer contains a message type. If yes returns it, else returns nil Usage:

do not filter by record name: MsgExtractRRByType(m, dns.TypeA, "")
filter by record name: MsgExtractRRByType(m, dns.TypeA, "google.com")

func MsgGetDo

func MsgGetDo(m *dns.Msg) bool

func MsgGetMinTTL

func MsgGetMinTTL(m *dns.Msg) uint32

func MsgRemoveOPT

func MsgRemoveOPT(msg *dns.Msg) *dns.Msg

func MsgSetAuthenticated

func MsgSetAuthenticated(m *dns.Msg, auth bool)

func MsgSetDo

func MsgSetDo(m *dns.Msg, do bool)

func MsgSetupEdns

func MsgSetupEdns(m *dns.Msg)

Types

This section is empty.

Jump to

Keyboard shortcuts

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