Skip to content

Commit

Permalink
tool: update kapinger to make random dns requests
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Castilio dos Santos <[email protected]>
  • Loading branch information
alexcastilio committed Nov 22, 2024
1 parent 95200c6 commit 594fb1c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion hack/tools/kapinger/clients/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"math/rand"
"net"
"time"
)
Expand All @@ -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) + ".com"

ips, err := net.LookupIP(domain)
if err != nil {
Expand All @@ -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)
}

0 comments on commit 594fb1c

Please sign in to comment.