Repository navigation
fix(xray): honor log "none" and stop traffic lines from failing startup - #123
xmohammad1 wants to merge 3 commits into
Conversation
Xray accepts "none" for log.access and log.error to turn that log off. The node passes the configured values to its own logger, which opened "none" as a relative path: with "access": "none" every access entry was appended to /app/none inside the container, with no rotation. openLogFile now skips "none" the same way it skips an empty path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ToBytes clears the log paths because the node reads Xray's stdout and writes the files itself. It also cleared "none", which Xray then reads as "log to stdout", so "access": "none" never turned the access log off: every connection was still logged and streamed to the panel. Keep "none" for both logs; real paths are still cleared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
isStartupFailureLog looks for keywords such as "fatal", "panic" and "failed to open" in every line Xray prints before its API answers. Clients reconnect during that window, so ordinary traffic lines failed healthy starts and the node stopped Xray, e.g.: from <ip> accepted tcp:fatal-error.example:443 [in >> direct] email: <user> [Info] [id] ... proxy/freedom: failed to open connection to tcp:<ip>:443 > ... connection refused Skip access entries, accepted and rejected (matched on fields, because Xray writes two spaces after "rejected"), and Info/Debug lines. A failed start still matches through "Failed to start:", panics and Warning/Error lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Summary
Three bugs in how the node handles Xray's log output, found on a production node (v0.5.4, Xray 26.3.27, ~200k users). The same code is in v0.5.7 and
dev."log": {"access": "none"}does not turn the access log off.Config.ToBytes()clearsaccessanderrorbefore starting Xray,"none"included. Xray reads an empty value as "log to stdout", so every connection is still logged and streamed to the panel."none"is opened as a file.Core.Startpasses the configured value tologger.SetLogFile, andopenLogFileonly skips"". With"access": "none", the node appended every access entry to/app/nonein the container, with no rotation: 27.5 MB in the first 25 minutes on that node (~18 KB/s).isStartupFailureLoglooks for its keywords in every line Xray prints before its API answers, and clients reconnect during that window. Seen in production:fatal(accepted tcp:…fatal…:443) returnedfailed to start xray: … accepted tcp:…, the node stopped Xray, and the node stayed down until the panel retried about 40 s later;[Info] … proxy/freedom: failed to open connection to …lines failed the start the same way on three nodes during one panel restart.Changes
logger: addDisabledLog = "none";openLogFiletreats it like an empty path.backend/xray/config.go:ToByteskeeps"none"for access/error. Real paths are still cleared.backend/xray/startup_diagnostics.go: skip access entries and[Info]/[Debug]lines. Access entries are matched by the newisAccessLogEntry, which also coversrejectedentries: Xray writes two spaces afterrejectedwhen there is no destination, so the existing"rejected proxy/"check never matched a real line. Real failures still match:Failed to start: …, panics, Warning/Error lines.Tests
TestToBytesKeepsDisabledLogs,TestSetLogFileTreatsNoneAsDisabled,TestIsAccessLogEntry, and new cases inTestIsStartupFailureLog(the false positives above, plus realFailed to start:lines that must still fail).run-tests.yml(WireGuard integration tests not run):TEST_INTEGRATION=true go test ./... -v -p 1gives 276 passed, 0 failed with Xray v26.10.31, and theTestCoreStartedrace run passes.dev. The only failure,TestConvertLivePartsUsesTheInstalledXray, fails ondevtoo, because that Xray still accepts the VLESS outbound the test expects it to refuse.Not changed
A config without a
logsection still gets"loglevel": "info"fromGetLogFiles(). Xray's own default is warning with the access log off, so these nodes stream every connection plus all Info lines. That may be intended, so this PR leaves it alone.🤖 Generated with Claude Code