介绍 #
FoXray 使用本地配置 + Xray Json 的方式生成最终的配置文件。此举主要为了使用户在编写 Xray Json 时聚焦于 Routing 和 DNS,而无需关注 FoXray 的实现方式。
差异 #
FoXray 仅支持 Xray 的配置子集。
相比较原版 Xray 配置,FoXray 做了如下限制。
DNS #
-
servers 仅支持 ServerObject 。
-
不支持 FakeDNS 。
-
hosts 仅支持
"域名": ["地址 1","地址 2"]
格式。 -
tag 固定为 dnsQuery 。即使您将 tag 指定为其他值,在生成配置文件时,也将被修复为 dnsQuery 。
Routing #
-
routing 不支持自定义 domainMatcher 。
-
routing 不支持 balancers 。
-
RuleObject 不支持自定义 domainMatcher 。
-
RuleObject 不支持 user ,attrs ,balancerTag 。
开启和关闭 #
FoXray 判断开启 Routing 或 DNS 的依据为:Xray Json 中是否包含 routing
或 dns
字段。
若您只想使用 Routing ,则仅配置 routing
字段。
若您只想使用 DNS ,则仅配置 dns
字段。
注意:
-
若您开启了 DNS,则即使您关闭 Routing,FoXray 也会生成两条规则,用以处理 DNS 查询。
-
若您关闭了 DNS,FoXray 将使用 8.8.8.8 作为默认 DNS.
规则数据集 #
当新建路由和 DNS 配置时,默认包含 geosite 和 geoip 。若您使用其他数据集,需自行将其他规则数据集与配置进行关联,否则无法通过校验。
您可为规则数据集自定义一个局部名称,该名称仅在当前路由和 DNS 配置内生效。
当删除一个规则数据集时,默认将删除所有与该规则数据集相关联的路由和 DNS 配置。
注意:根据经验,当路由和 DNS 配置中包含的规则数量达到 数万 时,在 iOS 上 VPN 大概率无法启动。FoXray 已为您统计了规则数据集中每个分类下的规则数量,您可自行计算配置使用的规则总数。
流量探测 #
从 2.6 版本开始,FoXray 支持自定义流量探测。
注意:
- FoXray 仅解析第一个 inbound 的 sniffing 配置。
{
"inbounds" : [
{
"sniffing" : {
"destOverride" : [
"http",
"tls",
"quic"
],
"domainsExcluded" : [
"courier.push.apple.com"
],
"enabled" : true
}
}
]
}
完整配置 #
{
"dns": {
"hosts": {
"baidu.com": ["127.0.0.1"],
"dns.google": ["8.8.8.8", "8.8.4.4"]
},
"servers": [
{
"address": "1.2.3.4",
"port": 53,
"domains": [
"domain:xray.com",
"geosite:cn"
],
"expectIPs": [
"geoip:cn"
],
"skipFallback": false
},
{
"address": "localhost"
}
],
"queryStrategy": "UseIP",
"disableCache": false,
"disableFallback": false,
"disableFallbackIfMatch": false,
"tag": "dnsQuery"
},
"inbounds" : [
{
"sniffing" : {
"destOverride" : [
"http",
"tls",
"quic"
],
"domainsExcluded" : [
"courier.push.apple.com"
],
"enabled" : true
}
}
],
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"domain": [
"baidu.com",
"qq.com",
"geosite:cn"
],
"ip": [
"0.0.0.0/8",
"10.0.0.0/8",
"fc00::/7",
"fe80::/10",
"geoip:cn"
],
"port": "53,443,1000-2000",
"sourcePort": "53,443,1000-2000",
"network": "tcp",
"source": [
"10.0.0.1",
"geoip:cn"
],
"inboundTag": [
"tag-vmess"
],
"protocol": [
"http",
"tls",
"bittorrent"
],
"outboundTag": "direct"
}
]
}
}
分享和订阅 #
注意:当 FoXray 解析配置时,会自动下载配置中关联的 geo data ,若下载失败,该配置将无法通过校验。
分享 #
路由和 DNS 的分享格式为 xray://base64RoutingDNS
。
订阅 #
订阅支持路由和 DNS 配置。订阅需以文本形式提供,并按照如下格式排版。
xray://base64RoutingDNS
xray://base64RoutingDNS
人工编写 #
FoXray 如何转换路由和 DNS 配置为 Xary Json ? #
FoXray 使用一个扩展字段 ext
来保存名称和规则数据集。
所有转换关系如下:
名称
{
"ext" : {
"name" : "share"
}
}
默认出口
{
"outbounds" : [
{
"tag" : "proxy"
}
]
}
ipQuery 出口
{
"routing" : {
"rules" : [
{
"inboundTag" : [
"dnsQuery"
],
"outboundTag" : "proxy",
"type" : "field"
}
]
}
}
nonIPQuery
{
"outbounds" : [
{
"protocol" : "dns",
"settings" : {
"nonIPQuery" : "skip",
}
}
]
}
nonIpQuery 出口
{
"outbounds" : [
{
"protocol" : "dns",
"streamSettings" : {
"sockopt" : {
"dialerProxy" : "proxy"
}
}
}
]
}
nonIPQuery DNS
{
"outbounds" : [
{
"protocol" : "dns",
"settings" : {
"address" : "8.8.8.8"
}
}
]
}
规则数据集
{
"ext" : {
"dat" : [
{
"name" : "geoip",
"type" : "ip",
"url" : "https://github.com/v2fly/geoip/releases/latest/download/geoip.dat"
},
{
"name" : "geosite",
"type" : "domain",
"url" : "https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat"
}
]
}
}
当 FoXray 解析分享链接时,将按照上述对应关系进行设置。
编写 #
routing
中的前两条规则必须为以下形式。
{
"routing" : {
"rules" : [
{
"inboundTag" : [
"dnsQuery"
],
"outboundTag" : "proxy",
"type" : "field"
},
{
"outboundTag" : "dnsOut",
"port" : "53",
"type" : "field"
}
]
}
}
其中,第一条规则的 outboundTag
代表 ipQuery 出口。这两条规则将在解析时被移除。
注意:在 FoXray 中,您无需编写这两条规则,程序将自动生成它们。
- 关于
ext
ext 存储配置名称和关联的 geo data 。其中 name
为必填字段,当省略时,该配置将无法通过校验。
dat
存储配置关联的 geo data 。
样例 #
{
"dns" : {
"servers" : [
{
"address" : "8.8.8.8"
}
]
},
"ext" : {
"dat" : [
{
"name" : "geoip",
"type" : "ip",
"url" : "https://github.com/v2fly/geoip/releases/latest/download/geoip.dat"
},
{
"name" : "geosite",
"type" : "domain",
"url" : "https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat"
}
],
"name" : "share"
},
"outbounds" : [
{
"tag" : "proxy"
},
{
"protocol" : "dns",
"settings" : {
"address" : "8.8.8.8",
"nonIPQuery" : "skip",
"userLevel" : 0
},
"streamSettings" : {
"sockopt" : {
"dialerProxy" : "proxy"
}
},
"tag" : "dnsOut"
}
],
"routing" : {
"rules" : [
{
"inboundTag" : [
"dnsQuery"
],
"outboundTag" : "proxy",
"type" : "field"
},
{
"outboundTag" : "dnsOut",
"port" : "53",
"type" : "field"
},
{
"domain" : [
"geosite:private",
"geosite:bing",
"geosite:cn"
],
"outboundTag" : "direct",
"type" : "field"
},
{
"ip" : [
"geoip:private"
],
"outboundTag" : "direct",
"type" : "field"
}
]
}
}