diff --git a/cmd/dashboard/controller/waf/waf.go b/cmd/dashboard/controller/waf/waf.go index 4a559ea..0a58ed1 100644 --- a/cmd/dashboard/controller/waf/waf.go +++ b/cmd/dashboard/controller/waf/waf.go @@ -36,12 +36,12 @@ func RealIp(c *gin.Context) { c.AbortWithStatusJSON(http.StatusOK, model.CommonResponse[any]{Success: false, Error: "real ip header not found"}) return } - ip, err := netip.ParseAddr(vals) + ip, err := netip.ParseAddrPort(vals) if err != nil { c.AbortWithStatusJSON(http.StatusOK, model.CommonResponse[any]{Success: false, Error: err.Error()}) return } - c.Set(model.CtxKeyRealIPStr, ip.String()) + c.Set(model.CtxKeyRealIPStr, ip.Addr().String()) c.Next() } diff --git a/cmd/dashboard/rpc/rpc.go b/cmd/dashboard/rpc/rpc.go index c36b443..00eb298 100644 --- a/cmd/dashboard/rpc/rpc.go +++ b/cmd/dashboard/rpc/rpc.go @@ -51,11 +51,11 @@ func getRealIp(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, } a := strings.Split(vals[0], ",") h := strings.TrimSpace(a[len(a)-1]) - ip, err := netip.ParseAddr(h) + ip, err := netip.ParseAddrPort(h) if err != nil { return nil, err } - ctx = context.WithValue(ctx, model.CtxKeyRealIP{}, ip.String()) + ctx = context.WithValue(ctx, model.CtxKeyRealIP{}, ip.Addr().String()) return handler(ctx, req) }