Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pkg/tool/kubectl/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"crypto/tls"
"fmt"
"io/ioutil"
"math/rand"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -160,6 +161,20 @@ func ServerAccountRequest(opts K8sRequestOption) (string, error) {
request.Header.Set("Authorization", "Bearer "+token)
}

// Anonymous mode,add random ip addresses to confuse ip addresses
if opts.Anonymous {
rand.Seed(time.Now().UnixNano())
ips := make([]string, 100)

for i := 0; i < 100; i++ {
ip := fmt.Sprintf("10.%d.%d.%d", rand.Intn(256), rand.Intn(256), rand.Intn(256))
ips[i] = ip
}

randIpStr := strings.Join(ips, ",")
request.Header.Set("X-Forwarded-For", randIpStr)
}

resp, err := client.Do(request)
if err != nil {
return "", &errors.CDKRuntimeError{Err: err, CustomMsg: "err found in post request."}
Expand Down