fix(job): handle access-log errors and resolve IP-limit clients relationally#5496
fix(job): handle access-log errors and resolve IP-limit clients relationally#5496n0ctal wants to merge 2 commits into
Conversation
|
This PR contains three real fixes and one correctness bug introduced in the new code. The fixes for swallowed errors, the nil-pointer-on-failed-open panic, and the substring-match false-positive are all sound. One error-variable mistake in the fallback path needs attention before merge. Blocking issueWrong error returned in
|
8d45599 to
daa9cea
Compare
…ionally The IP-limit job swallowed access-log open/copy/truncate errors and matched a client's inbound with a fragile settings LIKE '%email%' substring query. Handle those errors with early returns, verify the access log is readable, and resolve the client to its inbound via the clients/client_inbounds join, keeping the substring scan only as a fallback.
daa9cea to
69c10f9
Compare
The IP-limit job tracks per-client IPs via the core's online-stats API; the access-log parser only ran as a fallback for cores predating that API (which the panel never bundles). Remove the parser, the availability check, and the hourly rotation that truncated a log the job no longer reads.
Move the user-enabled access-log wipe to the daily clear-logs job, guarded so a disabled ('none') or missing log is left alone. Retire the now-unwritten 3xipl-ap persistent-log machinery.
Also resolve IP-limit clients via the exact clients/client_inbounds relation instead of a fragile settings LIKE '%email%' substring, keeping the JSON scan only as a fallback (carried from #5496).
Summary
The client IP-limit job ignored errors when opening/copying/truncating the Xray access log, and located a client's inbound with a fragile
settings LIKE '%email%'substring query. This adds error handling with early returns, verifies the access log is actually readable, and resolves the client-to-inbound mapping via theclients/client_inboundsrelation, keeping the substring scan only as a fallback.Why
j.checkError(err)with no return) let the job keep running after a failed log open/copy/truncate, operating on inconsistent state.WHERE settings LIKE '%email%'can match the wrong inbound: an email that is a substring of another email, or text that merely appears elsewhere in the settings JSON. The relational lookup is exact; the JSON scan remains as a fallback so nothing regresses when the relation has no row.Scope
internal/web/job/check_client_ip_job.go:clearAccessLog,processLogFile: check each file error and return early instead of continuing.checkAccessLogAvailable: actually open the log to confirm readability (not just stat).getInboundByEmail: joinclient_inbounds/clientsonclients.email; on miss fall back to the previousLIKE+ JSON parse.internal/web/job/check_client_ip_job_integration_test.go: integration coverage.Validation
go vet ./internal/web/job/,go build ./..., and the fullinternal/web/jobpackage under-raceall pass.Risk
getInboundByEmailnow prefers the relational tables and falls back to the prior substring+JSON scan, so the result is unchanged when the join finds nothing. No schema change; no behavioral change for the common single-match case.