From e4474880798fbe36283f254403f1b4aad1379825 Mon Sep 17 00:00:00 2001 From: Alex Castilio dos Santos Date: Fri, 22 Nov 2024 14:52:48 +0000 Subject: [PATCH] tool: update kapinger to make random dns requests Signed-off-by: Alex Castilio dos Santos --- hack/tools/kapinger/clients/dns.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hack/tools/kapinger/clients/dns.go b/hack/tools/kapinger/clients/dns.go index fd2fda3ca1..b4ec4be3b0 100644 --- a/hack/tools/kapinger/clients/dns.go +++ b/hack/tools/kapinger/clients/dns.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log" + "math/rand" "net" "time" ) @@ -30,7 +31,7 @@ func (k *KapingerDNSClient) MakeRequests(ctx context.Context) error { case <-ticker.C: go func() { for i := 0; i < k.volume; i++ { - domain := "retina.sh" + domain := randomString(20) + ".test" ips, err := net.LookupIP(domain) if err != nil { @@ -43,3 +44,16 @@ func (k *KapingerDNSClient) MakeRequests(ctx context.Context) error { } } } + +func randomString(n int) string { + var letters = []rune("abcdefghijklmnopqrstuvwxyz") + b := make([]rune, n) + + rand.New(rand.NewSource(time.Now().UnixNano())) + + for i := range b { + b[i] = letters[rand.Intn(len(letters))] + } + + return string(b) +}