Skip to content

Commit

Permalink
feat: Handle missing real IP header gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
dysf888 committed Jan 6, 2025
1 parent f6683ad commit 64c1016
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/dashboard/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 64c1016

Please sign in to comment.