mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5928] [Bug]: Geodata path in 3.5.0 changed? #4110
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#4110
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?
Originally created by @shmrv on GitHub (Jul 13, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5928
Describe the bug
After update to 3.5.0 got error:
The parameters have been changed. (xray core rejects outbound "direct": infra/conf: failed to build outbound handler for protocol freedom > common/geodata: illegal ip rule: geoip:private > common/geodata: failed to open geoip.dat > stat /usr/local/x-ui/geoip.dat: no such file or directory )
But geodata files located at /usr/local/x-ui/bin.
How to reproduce the problem
Expected behavior
Saved routing rules with correct geodata.
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.5.0
Xray-core version
26.6.27
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24.04
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jul 13, 2026):
Confirmed bug, root cause traced to source.
Root cause
Saving Xray Settings (the frontend resubmits the whole template, including Routing) runs
CheckXrayConfig(internal/web/service/xray_setting.go:38), which validates every outbound in the saved config throughxray.ValidateOutboundConfig(internal/xray/api.go:178):detour.Build()runs xray-core's real config builder in-process, inside the panel binary. When an outbound needs geo data (an IP rule referencinggeoip:/geosite:, exposed on the freedom outbound's "Final Rules" IP field in the UI), xray-core resolvesgeoip.dat/geosite.datthrough theXRAY_LOCATION_ASSETenv var, falling back to the directory of the currently running executable when it's unset. For the panel process that directory is/usr/local/x-ui/itself, not thebin/subfolder whereinstall.shactually places the Xray binary and geo assets — hencestat /usr/local/x-ui/geoip.dat: no such file or directory, even though the files are correctly at/usr/local/x-ui/bin/geoip.dat.3x-ui already has a fix for exactly this class of problem:
ensureXrayAssetLocation()(internal/xray/api.go:426) setsXRAY_LOCATION_ASSETto the absolutebin/path before an in-process build, with the comment "the panel binary lives one level above the bin folder, so an explicit location is required." It's called at the top ofApplyRoutingConfig(api.go:237), butValidateOutboundConfignever got the same guard.Why this is new in 3.5.0
ValidateOutboundConfigand the outbound-validation loop inCheckXrayConfigdo not exist inv3.4.2— diffing both files against that tag showsCheckXrayConfigthere only did a JSON-shape check. Both were added byfeat(xray): update xray-core to v26.7.11 and adapt panel(814cda3f), part of 3.5.0, to pre-validate outbounds against xray-core v26.7.11's new plaintext-vless/trojan restrictions before they reach the running core. The accompanying test (internal/xray/outbound_validation_test.go) only covers that plaintext-rejection case, so a build path needing geodata was never exercised and the missing asset-location guard went unnoticed.Workaround (no code change needed)
Pin the asset directory explicitly so xray-core's own env-var check short-circuits the executable-relative fallback. Add to
/etc/default/x-ui:then:
Title: Outbound validation on save resolves geoip.dat/geosite.dat relative to the panel binary instead of the bin/ folder
Severity: High — blocks saving any Xray Settings change (not just routing) once a saved outbound references geo data, with no in-UI workaround
Category: Correctness
Why this matters:
CheckXrayConfigruns unconditionally on every settings save and validates the full outbound list, so one outbound with a geo-data IP rule blocks all further Xray Settings saves for that install untilXRAY_LOCATION_ASSETis set manually.Recommendation: Call
ensureXrayAssetLocation()at the top ofValidateOutboundConfig, mirroringApplyRoutingConfig. Consider calling it once, unconditionally, at panel/xray-service startup rather than before each individual in-process builder call —AddOutbound/AddInbound(used by the hot-apply path inXrayService.tryHotApply,internal/web/service/xray.go:1026) run their own in-process.Build()beforeApplyRoutingConfiggets a chance to set the env var on a freshly started panel, so they carry the same latent risk.Example:
Confidence: high on the mechanism and the 3.5.0 regression window (grounded in the current source and a diff against the
v3.4.2tag). Moderate on which field put a geo reference on your outbound specifically, since your saved config isn't visible from here — the likeliest source is an IP value under a "Final Rules" entry on thedirect(freedom) outbound.@MHSanaei for a decision on the fix.
This reply was generated automatically; a maintainer may follow up.
@PA4EJIJIA commented on GitHub (Jul 19, 2026):
Confirming with a scope correction and a workaround that needs no restart.
The scope is wider than "editing geo rules"
Since
CheckXrayConfigvalidates every outbound in the submitted template, one pre-existing outbound with a geo IP rule makes the entire Xray Settings page unsaveable - unrelated edits are rejected too.In my case the
directoutbound carriesfinalRules: [{action: block, ip: [geoip:private]}, {action: allow}]as an SSRF guard. I was adding a completely unrelated new outbound, and the save was rejected with:xray core rejects outbound "direct": infra/conf: failed to build outbound handler for protocol freedom > common/geodata: illegal ip rule: geoip:private > common/geodata: failed to open geoip.dat > stat /usr/local/x-ui/geoip.dat: no such file or directory
Note it names
direct— the outbound I never touched. The panel had been silently unsaveable ever since the 3.5.0 update; there was simply no reason to notice until the next config change.Workaround that does not restart anything
Setting
XRAY_LOCATION_ASSET=/usr/local/x-ui/binin the unit works, but restarting x-ui restarts Xray and drops every live connection. Two symlinks avoid that:ln -sfn /usr/local/x-ui/bin/geoip.dat /usr/local/x-ui/geoip.dat
ln -sfn /usr/local/x-ui/bin/geosite.dat /usr/local/x-ui/geosite.dat
They satisfy the exact paths the panel already
stats, no process is touched, and geo-file updates keep working because they rewrite the targets inbin/.Detail supporting the root cause above
x-ui does export
XRAY_LOCATION_ASSET=/usr/local/x-ui/bin— but only into the spawned Xray child process./proc/<xray-pid>/environcontains it; the panel's own environment does not. So the running core resolves assets correctly and only the in-process validation path is affected, exactly matchingensureXrayAssetLocation()being called inApplyRoutingConfigbut not inValidateOutboundConfig.@MHSanaei commented on GitHub (Jul 23, 2026):
Fixed in #6083. Points the in-process loader at the bin folder before building outbound configs, so a geoip:private finalRule no longer fails with a missing geoip.dat when saving routing/template settings.