Geodata — Xray-core
geodata is a top-level block that keeps Xray's external data files — geoip.dat and geosite.dat, the files behind geoip: / geosite: routing and DNS rules — automatically up to date. On every tick of its cron schedule, each asset is downloaded from an HTTPS url — optionally through a chosen outbound — and replaces a local file, after which the rules are reloaded.
Options
| Field | Type | Default | Allowed values | Description |
|---|---|---|---|---|
cron | *string | (no schedule) | <cron expression> | Standard 5-field cron expression (descriptors such as @daily or @every 6h also work) controlling when assets are re-downloaded and the rules reloaded. An @every interval must be at least 1 minute. Without cron the block does nothing — no downloads, and file is not checked. |
outbound | string | (default routing) | <outbound tag> | Tag of the outbound used to download assets, so updates can go through a proxy instead of direct. |
assets | []*GeodataAssetConfig | [] | [GeodataAssetConfig] | Assets to fetch and keep up to date — at most 100. |
Source: infra/conf/geodata.go:48-52 · pinned at v26.11.9 (676eaf6)
assets[]
| Field | Type | Default | Allowed values | Description |
|---|---|---|---|---|
url | string | (required) | https://… | Source URL. Must be HTTPS — any other scheme is rejected at config build, and redirects must stay on HTTPS. .dat URLs of XTLS/Xray-rules-dat are rewritten to .dat.gz (see Notes). |
file | string | (required) | <file name> | Asset file to replace — a .dat name relative to Xray's asset directory (absolute paths and .. are rejected). It must already exist when Xray starts (checked only when cron is set). |
Source: infra/conf/geodata.go:13-16 · pinned at v26.11.9 (676eaf6)
Example
Refresh geoip.dat and geosite.dat every day at 04:00, downloading through the proxy outbound:
json
{
"geodata": {
"cron": "0 4 * * *",
"outbound": "proxy",
"assets": [
{
"url": "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat",
"file": "geoip.dat"
},
{
"url": "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat",
"file": "geosite.dat"
}
]
}
}Notes
urlmust be HTTPS; any other scheme fails at config build. Downloads use HTTP/2 and follow at most 20 redirects, all of which must stay on HTTPS.filemust name an existing.datfile in Xray's asset directory (the directory alongside the binary, or the path set byXRAY_LOCATION_ASSET); the block replaces existing assets rather than creating them, and withcronset a missing file is a startup error. These are the same file names thatgeoip:/geosite:rules load.cronuses standard 5-field cron syntax; an invalid expression, an@everyinterval under 1 minute, or more than 100 assets is a startup error. Withoutcronnothing is downloaded; withcronbut noassets, Xray only reloads the existing files on schedule.- A gzip-compressed response — such as a
.dat.gzasset — is decompressed while it streams to disk. A download that is empty or larger than 256 MiB (after decompression) fails. All assets are fetched first and swapped in together; if reloading the new files fails, the previous files are restored. - A
.datURL underhttps://github.com/XTLS/Xray-rules-dat/orhttps://raw.githubusercontent.com/XTLS/Xray-rules-dat/is deprecated: Xray appends.gz, downloads the compressed file instead and logs a warning — point such URLs at the.dat.gzfile directly. - The categories inside these files (
cn,private,apple, …) drive routing — see the Routing page.
Cross-core notes
- mihomo configures the equivalent through the top-level
geox-urlblock (asset URLs) plusgeo-auto-update/geo-update-interval. See GeoX URL — mihomo. - sing-box fetches rule-sets on demand via
route.rule_setinstead of maintaining.datfiles, so it has no direct equivalent.
Source: infra/conf/geodata.go:13-52 · v26.11.9 (676eaf6)
