Use RealIP instead of remoteAddr
@@ -12,7 +12,6 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
- "strings"
)
const (
@@ -178,7 +177,7 @@ func (m *ClientManager) GetConfigForClientRequestContext(c echo.Context) (*Clien
// Case #2: kubectl port-forwrd (https://github.com/kubernetes/kubernetes/blob/6ce9e71cd57d4aa6c932aabddf4129f173b9d710/pkg/kubelet/dockershim/docker_streaming_others.go#L31-L86)
// Use cluster config permission
- if strings.HasPrefix(c.Request().RemoteAddr, "127.0.0.1") || strings.HasPrefix(c.Request().RemoteAddr, "[::1]") {
+ if c.RealIP() == "127.0.0.1" || c.RealIP() == "::1" {
var name string
if m.IsInCluster() {
