mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5098] [MERGED] feat: synchronize access.log client IPs across nodes #5780
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5780
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5098
Author: @rqzbeh
Created: 6/8/2026
Status: ✅ Merged
Merged: 6/8/2026
Merged by: @MHSanaei
Base:
main← Head:feat/sync-client-ips-across-nodes📝 Commits (3)
a9be483feat: synchronize access.log client IPs across nodes for global fail2ban limitse554151Merge branch 'main' into feat/sync-client-ips-across-nodes4d102c5fix(nodes): harden cross-node client-IP merge for cluster fail2ban📊 Changes
9 files changed (+532 additions, -3 deletions)
View changed files
📝
frontend/public/openapi.json(+73 -0)📝
frontend/src/pages/api-docs/endpoints.ts(+15 -0)📝
web/controller/server.go(+18 -0)📝
web/job/check_client_ip_job.go(+5 -1)📝
web/job/check_client_ip_job_test.go(+21 -0)📝
web/job/node_traffic_sync_job.go(+39 -2)📝
web/runtime/remote.go(+19 -0)📝
web/service/inbound.go(+131 -0)➕
web/service/inbound_client_ips_merge_test.go(+211 -0)📄 Description
Summary
Synchronizes access.log client IPs from sub-nodes to the main server so that
fail2banlimits are correctly enforced cluster-wide.Why
Currently, when users connect to a node server, the
access.logon that node records the client IP, but this information is not synchronized back to the main server's global view. As a result, thefail2banfeature (which limits the maximum number of simultaneous IPs a client can use) fails to count connections made through remote nodes, allowing users to bypass their IP limit.This PR implements a robust synchronization mechanism where
NodeTrafficSyncJobpulls recentInboundClientIpsfrom remote nodes and safely aggregates them into the main database without double-counting identical IPs across different nodes.Closes #5080
Type of change
Areas affected
How was this tested?
GET/POST /panel/api/server/clientIpsendpoints for inter-node communication.ipMap[ipTime.IP] = ipTime.Timestamp), guaranteeing the system does not double-count the same IP accessing multiple nodes.TestPartitionLiveIps_RecentSyncedIpIsLiveincheck_client_ip_job_test.goto mathematically prove the 2-minute rolling window sync accurately labels recently-synced cluster IPs as "live" even if they weren't seen by the localaccess.logscan.go test -v ./web/job/...which passes flawlessly.Screenshots / recordings
N/A (Backend logic only).
Breaking changes
None.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.