feat: separate real ip header of frontend/agent (#1057)

* test(deps): use self admin-frontend

* feat: separate real ip header of frontend/agent

* test(ci): test

* Revert "test(ci): test"

This reverts commit 1634c7e7d7bca2873c13955abb582ea88645844f.

* test(ci): test

* test(ci): test

* test(ci): test

* Revert "test(ci): test"

This reverts commit 8fce20a07e5a9503f665937337050d4373ca7e78.

* Revert "test(ci): test"

This reverts commit 3267cccbfb81776a711e8cb34e676536f0852d1c.

* Revert "test(ci): test"

This reverts commit 566660c0c6a9875864aa46537bcc6788769337eb.

* Revert "test(deps): use self admin-frontend"

This reverts commit 16a838b374ff040800b2c1c5f8e5ede577645669.
This commit is contained in:
TomyJan
2025-04-13 18:41:28 +08:00
committed by GitHub
parent 6c42fdcf92
commit 6493911d45
5 changed files with 12 additions and 9 deletions

View File

@@ -47,16 +47,16 @@ func getRealIp(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler
}
ctx = context.WithValue(ctx, model.CtxKeyConnectingIP{}, connectingIp)
if singleton.Conf.RealIPHeader == "" {
if singleton.Conf.AgentRealIPHeader == "" {
return handler(ctx, req)
}
if singleton.Conf.RealIPHeader == model.ConfigUsePeerIP {
if singleton.Conf.AgentRealIPHeader == model.ConfigUsePeerIP {
if connectingIp == "" {
return nil, fmt.Errorf("connecting ip not found")
}
} else {
vals := metadata.ValueFromIncomingContext(ctx, singleton.Conf.RealIPHeader)
vals := metadata.ValueFromIncomingContext(ctx, singleton.Conf.AgentRealIPHeader)
if len(vals) == 0 {
return nil, fmt.Errorf("real ip header not found")
}