[GH-ISSUE #5928] [Bug]: Geodata path in 3.5.0 changed? #4110

Closed
opened 2026-10-31 20:37:14 +07:00 by bsakaguchi · 3 comments
Owner

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

  1. Open routing
  2. Change anything with geoip or geosite
  3. Click save
  4. Got error

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

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
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 1. Open routing 2. Change anything with geoip or geosite 3. Click save 4. Got error ### Expected behavior Saved routing rules with correct geodata. ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### 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 - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:37:14 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@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 through xray.ValidateOutboundConfig (internal/xray/api.go:178):

func ValidateOutboundConfig(outbound []byte) error {
	detour := new(conf.OutboundDetourConfig)
	if err := json.Unmarshal(outbound, detour); err != nil {
		return err
	}
	_, err := detour.Build()
	return err
}

detour.Build() runs xray-core's real config builder in-process, inside the panel binary. When an outbound needs geo data (an IP rule referencing geoip:/geosite:, exposed on the freedom outbound's "Final Rules" IP field in the UI), xray-core resolves geoip.dat/geosite.dat through the XRAY_LOCATION_ASSET env 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 the bin/ subfolder where install.sh actually places the Xray binary and geo assets — hence stat /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) sets XRAY_LOCATION_ASSET to the absolute bin/ 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 of ApplyRoutingConfig (api.go:237), but ValidateOutboundConfig never got the same guard.

Why this is new in 3.5.0

ValidateOutboundConfig and the outbound-validation loop in CheckXrayConfig do not exist in v3.4.2 — diffing both files against that tag shows CheckXrayConfig there only did a JSON-shape check. Both were added by feat(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:

XRAY_LOCATION_ASSET=/usr/local/x-ui/bin

then:

systemctl restart x-ui

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: CheckXrayConfig runs 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 until XRAY_LOCATION_ASSET is set manually.
Recommendation: Call ensureXrayAssetLocation() at the top of ValidateOutboundConfig, mirroring ApplyRoutingConfig. 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 in XrayService.tryHotApply, internal/web/service/xray.go:1026) run their own in-process .Build() before ApplyRoutingConfig gets a chance to set the env var on a freshly started panel, so they carry the same latent risk.
Example:

// internal/xray/api.go:178
func ValidateOutboundConfig(outbound []byte) error {
	ensureXrayAssetLocation()
	detour := new(conf.OutboundDetourConfig)
	...

Confidence: high on the mechanism and the 3.5.0 regression window (grounded in the current source and a diff against the v3.4.2 tag). 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 the direct (freedom) outbound.

@MHSanaei for a decision on the fix.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4955693388 --> @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 through `xray.ValidateOutboundConfig` (`internal/xray/api.go:178`): ```go func ValidateOutboundConfig(outbound []byte) error { detour := new(conf.OutboundDetourConfig) if err := json.Unmarshal(outbound, detour); err != nil { return err } _, err := detour.Build() return err } ``` `detour.Build()` runs xray-core's real config builder in-process, inside the panel binary. When an outbound needs geo data (an IP rule referencing `geoip:`/`geosite:`, exposed on the freedom outbound's "Final Rules" IP field in the UI), xray-core resolves `geoip.dat`/`geosite.dat` through the `XRAY_LOCATION_ASSET` env 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 the `bin/` subfolder where `install.sh` actually places the Xray binary and geo assets — hence `stat /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`) sets `XRAY_LOCATION_ASSET` to the absolute `bin/` 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 of `ApplyRoutingConfig` (`api.go:237`), but `ValidateOutboundConfig` never got the same guard. **Why this is new in 3.5.0** `ValidateOutboundConfig` and the outbound-validation loop in `CheckXrayConfig` do not exist in `v3.4.2` — diffing both files against that tag shows `CheckXrayConfig` there only did a JSON-shape check. Both were added by `feat(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`: ``` XRAY_LOCATION_ASSET=/usr/local/x-ui/bin ``` then: ``` systemctl restart x-ui ``` --- 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: `CheckXrayConfig` runs 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 until `XRAY_LOCATION_ASSET` is set manually. Recommendation: Call `ensureXrayAssetLocation()` at the top of `ValidateOutboundConfig`, mirroring `ApplyRoutingConfig`. 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 in `XrayService.tryHotApply`, `internal/web/service/xray.go:1026`) run their own in-process `.Build()` before `ApplyRoutingConfig` gets a chance to set the env var on a freshly started panel, so they carry the same latent risk. Example: ```go // internal/xray/api.go:178 func ValidateOutboundConfig(outbound []byte) error { ensureXrayAssetLocation() detour := new(conf.OutboundDetourConfig) ... ``` Confidence: high on the mechanism and the 3.5.0 regression window (grounded in the current source and a diff against the `v3.4.2` tag). 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 the `direct` (freedom) outbound. @MHSanaei for a decision on the fix. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@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 CheckXrayConfig validates 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 direct outbound carries finalRules: [{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/bin in 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 in bin/.

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>/environ contains 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 matching ensureXrayAssetLocation() being called in ApplyRoutingConfig but not in ValidateOutboundConfig.

<!-- gh-comment-id:5017432568 --> @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 `CheckXrayConfig` validates *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 `direct` outbound carries `finalRules: [{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/bin` in 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 `stat`s, no process is touched, and geo-file updates keep working because they rewrite the targets in `bin/`. **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>/environ` contains 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 matching `ensureXrayAssetLocation()` being called in `ApplyRoutingConfig` but not in `ValidateOutboundConfig`.
Author
Owner

@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.

<!-- gh-comment-id:5059091745 --> @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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4110
No description provided.