Skip to content

fix(app-server): rate limit direct clients by IP#361

Open
OnlyYu1996 wants to merge 1 commit into
CortexLM:mainfrom
OnlyYu1996:codex/fix-rate-limit-client-ip
Open

fix(app-server): rate limit direct clients by IP#361
OnlyYu1996 wants to merge 1 commit into
CortexLM:mainfrom
OnlyYu1996:codex/fix-rate-limit-client-ip

Conversation

@OnlyYu1996
Copy link
Copy Markdown

Summary

  • Serve the app with Axum ConnectInfo<SocketAddr> so request middleware has direct client connection metadata.
  • Use the TCP peer IP for rate-limit keys when no API key or trusted proxy header applies.
  • Preserve trusted proxy behavior by keeping X-Real-IP / X-Forwarded-For precedence when trust_proxy is enabled.
  • Add regression coverage for direct-client and trusted-proxy rate-limit keys.

Fixes PlatformNetwork/bounty-challenge#53250

Verification

  • cargo fmt --package cortex-app-server --check
  • cargo test --package cortex-app-server rate_limit_key -- --nocapture
  • cargo test --package cortex-app-server middleware::tests -- --nocapture
  • cargo check --package cortex-app-server --lib
  • git diff --check

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant