Skip to content

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 ​

FieldTypeDefaultAllowed valuesDescription
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.
outboundstring(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[] ​

FieldTypeDefaultAllowed valuesDescription
urlstring(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).
filestring(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 ​

  • url must 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.
  • file must name an existing .dat file in Xray's asset directory (the directory alongside the binary, or the path set by XRAY_LOCATION_ASSET); the block replaces existing assets rather than creating them, and with cron set a missing file is a startup error. These are the same file names that geoip: / geosite: rules load.
  • cron uses standard 5-field cron syntax; an invalid expression, an @every interval under 1 minute, or more than 100 assets is a startup error. Without cron nothing is downloaded; with cron but no assets, Xray only reloads the existing files on schedule.
  • A gzip-compressed response — such as a .dat.gz asset — 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 .dat URL under https://github.com/XTLS/Xray-rules-dat/ or https://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.gz file 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-url block (asset URLs) plus geo-auto-update / geo-update-interval. See GeoX URL — mihomo.
  • sing-box fetches rule-sets on demand via route.rule_set instead of maintaining .dat files, so it has no direct equivalent.

Source: infra/conf/geodata.go:13-52 · v26.11.9 (676eaf6)

Core Tutorial by Argsment