perf: ip check#6850
Merged
Merged
Conversation
Coverage Report
File CoverageNo changed files found. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR replaces request-ip with a centralized, proxy-aware client IP resolver and updates rate limiting / logging / internal endpoints to use the new logic, aiming to prevent spoofed forwarding headers and improve correctness/performance.
Changes:
- Added
packages/service/common/security/clientIp.ts(proxy-addr + normalization + trusted proxy allowlist viaTRUSTED_PROXY_IPS) and comprehensive tests. - Updated multiple API/middleware locations to use
getClientIpFromRequest/normalizeClientIpinstead ofrequest-ipor raw headers. - Removed
request-ipdependencies and introducedproxy-addr(+ types); updated docs to mention the stronger IP checks.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/app/src/pages/api/support/user/account/loginByPassword.ts | Uses new client IP resolver when creating user sessions. |
| projects/app/src/pages/api/core/sandbox/proxyCSPassword.ts | Normalizes socket IP before internal-only allowlist check. |
| projects/app/package.json | Removes request-ip and its types from app deps. |
| pnpm-workspace.yaml | Adds proxy-addr (+ types) to catalog; request-ip catalog entries still present. |
| pnpm-lock.yaml | Adds proxy-addr (+ types) resolutions; request-ip entries still present. |
| packages/service/type/env.ts | Adds TRUSTED_PROXY_IPS env typing. |
| packages/service/env.ts | Adds USE_IP_LIMIT and TRUSTED_PROXY_IPS to env schema/metadata. |
| packages/service/common/system/frequencyLimit/utils.ts | Fixes rate-limit signaling by throwing/rethrowing tooManyRequest. |
| packages/service/common/security/clientIp.ts | New trusted-proxy-aware client IP parsing + normalization utilities. |
| packages/service/common/middle/reqFrequencyLimit.ts | Switches IP extraction to new resolver and changes enable/disable gating logic. |
| packages/service/common/middle/entry.ts | Uses new resolver for request logging IP field. |
| packages/service/common/geo/index.ts | Uses new resolver for geo IP extraction. |
| packages/service/test/common/security/clientIp.test.ts | Adds unit tests for normalization, proxy trust, and header parsing behavior. |
| packages/service/test/common/middle/reqFrequencyLimit.test.ts | Adds tests ensuring rate limiting uses non-spoofable client IP keys. |
| packages/service/test/common/geo/index.test.ts | Updates/adds tests to reflect trusted-proxy behavior and spoof prevention. |
| document/data/doc-last-modified.json | Updates doc last-modified timestamp. |
| document/content/self-host/upgrading/4-15/4150.mdx | Notes stronger IP detection/spoofing prevention in release notes. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
✅ Docs Preview Deployed! 🔗 👀 Click here to visit preview |
|
✅ Build Successful - Preview code-sandbox Image for this PR: |
|
✅ Build Successful - Preview fastgpt Image for this PR: |
|
✅ Build Successful - Preview mcp_server Image for this PR: |
|
✅ Admin Preview Image Ready! |
xqvvu
force-pushed
the
ip
branch
2 times, most recently
from
May 6, 2026 08:20
dd3e1f9 to
20516e7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.