Skip to content

Commit

Permalink
Revert logging change
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Mar 21, 2024
1 parent 04b48d2 commit 5a4d878
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/api/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ func (wa *WalletAuthorizer) applyLimits(ctx context.Context, fullMethod string,
// * for other authorization failure return status.Errorf(codes.PermissionDenied, ...)
_, method := splitMethodName(fullMethod)

ip := wa.clientIPFromContext(ctx)
ip := clientIPFromContext(ctx)
if len(ip) == 0 {
// requests without an IP address are bucketed together as "ip_unknown"
ip = "ip_unknown"
wa.Log.Warn("no ip found", logging.String("method", fullMethod))
}
wa.Log.Info("got client ip", logging.String("client_ip", ip), logging.String("method", fullMethod))

// with no wallet apply regular limits
var isPriority bool
Expand Down Expand Up @@ -236,15 +237,13 @@ func allowedToPublish(topic string, wallet types.WalletAddr) bool {
return true
}

func (wa *WalletAuthorizer) clientIPFromContext(ctx context.Context) string {
func clientIPFromContext(ctx context.Context) string {
md, _ := metadata.FromIncomingContext(ctx)
vals := md.Get("x-forwarded-for")
if len(vals) == 0 {
p, ok := peer.FromContext(ctx)
if ok {
ip := p.Addr.String()
wa.Log.Info("got client IP without x-forwarded-for", logging.String("client_ip", ip))
return ip
return p.Addr.String()
} else {
return ""
}
Expand Down

0 comments on commit 5a4d878

Please sign in to comment.