From 64c1016b67aaf9c5165564fbe8e1ff441977ca61 Mon Sep 17 00:00:00 2001 From: dysf888 <47450409+dysf888@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:09:57 +0800 Subject: [PATCH] feat: Handle missing real IP header gracefully --- cmd/dashboard/rpc/rpc.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/dashboard/rpc/rpc.go b/cmd/dashboard/rpc/rpc.go index 51f6e12346..27750f8055 100644 --- a/cmd/dashboard/rpc/rpc.go +++ b/cmd/dashboard/rpc/rpc.go @@ -57,7 +57,8 @@ func getRealIp(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, } else { vals := metadata.ValueFromIncomingContext(ctx, singleton.Conf.RealIPHeader) if len(vals) == 0 { - return nil, fmt.Errorf("real ip header not found") + // 如果没有找到指定的 Header,使用NZ::Use-Peer-IP + return handler(ctx, req) } var err error ip, err = utils.GetIPFromHeader(vals[0])