Geodata — Xray-core
geodata 是一个顶层块,用于让 Xray 的外部数据文件 —— geoip.dat 与 geosite.dat,即 geoip: / geosite: 路由和 DNS 规则背后的文件 —— 自动保持更新。每个资源从 HTTPS url 下载到本地 file,可选地按 cron 计划并经选定的 outbound 进行。
选项
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
cron | *string | (no schedule) | <cron expression> | 标准 5 字段 cron 表达式,控制资源刷新的频率。省略则禁用计划更新。 |
outbound | string | (default routing) | <outbound tag> | 用于下载资源的出站 tag,从而让更新走代理而非直连。 |
assets | []*GeodataAssetConfig | [] | [GeodataAssetConfig] | 要抓取并保持更新的资源。 |
源码: infra/conf/geodata.go:42-46 · 锚定版本 v26.6.1 (94ffd50)
assets[]
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
url | string | (required) | https://… | 来源 URL。必须是 HTTPS —— 任何其他协议都会在配置构建时被拒绝。 |
file | string | (required) | <file name> | 要写入并加载的本地资源文件。必须能在 Xray 的资源搜索路径上解析到。 |
源码: infra/conf/geodata.go:13-16 · 锚定版本 v26.6.1 (94ffd50)
示例
每天 04:00 刷新 geoip.dat 与 geosite.dat,经 proxy 出站下载:
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"
}
]
}
}说明
url必须 是 HTTPS;任何其他协议都会在配置构建时失败。file必须能在 Xray 的资源搜索路径上解析到(二进制旁边的目录, 或由XRAY_LOCATION_ASSET设置的路径)。它们与geoip:/geosite:规则加载的文件名相同。cron使用标准 5 字段 cron 语法;无效表达式属于启动错误。省略cron以禁用计划刷新。- 这些文件内部的类目(
cn、private、apple等)驱动路由 —— 参见 Routing 页面。
跨内核说明
- mihomo 通过顶层
geox-url块(资源 URL)配合geo-auto-update/geo-update-interval配置同等能力。参见 GeoX URL — mihomo。 - sing-box 通过
route.rule_set按需抓取规则集,而非维护.dat文件,因此没有直接对应物。
源码: infra/conf/geodata.go:13-46 · v26.6.1 (94ffd50)
