Closed zoni-cc closed 1 year ago
routing修改为router 也一样
Your configuration has multiple structural and syntactical errors, which is understandable given that the new v5 configuration schema is still in the draft stage and lacks comprehensive documentation. It might be best to stick with the old format for now until the new one is more stable.
If you want to learn how to write v5 configuration properly, it's worth taking a look at the source code, particularly the corresponding protobuf files (usually has file extension .proto
) . Additionally, there's a project that provides a JSON schema for the new configuration format which can be used for autocomplete and validation.
That being said, I made a few modifications to your original configuration, and here it is
"router": {
"domainStrategy": "AsIs",
"rule": [
{
"tag": "direct",
"inboundTag": [
"in-01"
],
"protocol": [
"http",
"tls"
],
"networks": [
"TCP",
"UDP"
]
},
{
"tag": "out-02",
"inboundTag": [
"in-02"
],
"domainMatcher": "mph",
"geoDomain": [
{
"code": "tiktok"
},
{
"domain": [
{
"type": "RootDomain",
"value": "ibytedtos.com"
},
{
"type": "RootDomain",
"value": "ibyteimg.com"
},
{
"type": "RootDomain",
"value": "ipstatp.com"
},
{
"type": "RootDomain",
"value": "tik-tokapi.com"
},
{
"type": "RootDomain",
"value": "tiktok.com"
}
]
}
]
},
{
"inboundTag": [
"in-03"
],
"tag": "out-03",
"domainMatcher": "mph",
"geoDomain": [
{
"code": "google"
},
{
"code": "youtube"
}
]
},
{
"tag": "blocked",
"domainMatcher": "mph",
"geoip": [
{
"code": "private"
},
{
"cidr": [
{
"ipAddr": "192.168.0.0",
"prefix": 16
},
{
"ipAddr": "172.16.0.0",
"prefix": 12
},
{
"ipAddr": "10.0.0.0",
"prefix": 8
}
]
}
]
},
{
"tag": "blocked",
"domainMatcher": "mph",
"geoDomain": [
{
"code": "category-ads"
},
{
"domain": [
{
"type": "RootDomain",
"value": "epochtimes.com"
}
]
}
]
},
{
"tag": "blocked",
"protocol": [
"bittorrent"
]
}
]
}
Does it work for you?
NOTE: I changed the domain.type
in your config to RootDomain
instead of Plain
. I think Plain
in this context might not be what you meant.
调整后,依旧无法正常实现分流。(V5的写法比V4啰嗦很多) 调整后配置如下:
{
"log": {
"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "warning"
},
"inbounds": [
{
"tag": "in-10086",
"port": 10086,
"listen": "0.0.0.0",
"protocol": "shadowsocks",
"settings": {
"method": "aes-256-gcm",
"password": "password",
"network": ["tcp","udp"],
"packetEncoding": ["Packet"]
},
"sniffing": {
"enabled": true,
"destOverride": ["http", "tls","quic"],
"metadataOnly":true
}
},
{
"tag": "in-10087",
"port": 10087,
"listen": "0.0.0.0",
"protocol": "shadowsocks",
"settings": {
"method": "aes-256-gcm",
"password": "password",
"network": ["tcp","udp"],
"packetEncoding": ["Packet"]
},
"sniffing": {
"enabled": true,
"destOverride": ["http", "tls","quic"],
"metadataOnly":true
}
}
],
"outbounds": [
{
"protocol": "shadowsocks",
"settings": {
"servers": [
{
"address": "url1",
"method": "aes-256-gcm",
"password": "password",
"port": 50000
}
]
},
"tag": "out-01"
},
{
"protocol": "shadowsocks",
"settings": {
"servers": [
{
"address": "url2",
"method": "aes-256-gcm",
"password": "password",
"port": 50000
}
]
},
"tag": "out-02"
},
{
"protocol": "freedom",
"settings": {
"domainStrategy": "AsIs"
},
"tag": "direct"
},
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
],
"router": {
"domainStrategy": "AsIs",
"rule": [
{
"Tag": "direct",
"inboundTag": "in-10087",
"domainMatcher": "mph",
"protocol": ["http", "tls"],
"network": ["tcp","udp"]
},
{
"inboundTag": "in-10086",
"Tag": "out-02",
"domainMatcher": "mph",
"protocol": ["http", "tls"],
"network": ["tcp","udp"],
"geoDomain": [
{
"code": "google"
},
{
"code": "youtube"
}
]
},
{
"tag": "blocked",
"protocol": ["http", "tls"],
"geoDomain":[
{
"code": "category-ads"
},
{
"dimain":[
{
"type":"Plain",
"value":"epochtimes"
}
]
}
]
},
{
"tag": "blocked",
"protocol": ["bittorrent"]
}
]
}
}
Unluckily, the adjusted v5 configurations you provided still contain numerous structural errors (it seems you are mixed the v4 and v5 format together). It did not pass the test command v2ray test -format=jsonv5 -config config.json
.
For instance,
log.access
and log.error
should be objects, not strings. router.rule[].tag
should be in lower caserouter.rule[].networks
, not router.rule[].network
. And the value of this key should be written in ALL CAPS. These are only a few of the errors present.
Considering the current situation, it may be prudent to stick with the stable and well-documented v4 format for the time being. The v5 schema appears to be somewhat unstable and lacking in available resources and documentation. While the v5 format may have some newer features and improvements, the v4 format is still a reliable and effective configuration option. Therefore, it may be wise to postpone any attempts to use it until it is more thoroughly developed.
However, if you're still having issues or have to use v5 configuration format , feel free to ask and I'll be happy to help :)
已经用回v4.... 希望V5尽快完善 哈哈
你正在使用哪个版本的 V2Ray?
V5.3.0
你的使用场景是什么?
rule控制分流
你看到的异常现象是什么?
分流无法实现,默认走第一个outbounds
你期待看到的正常表现是怎样的?
按照域名 ip设定 实现不同标记 走不同的outbounds
请附上你的配置
服务端配置:
客户端配置:
请附上出错时软件输出的错误日志
无错误日志
服务器端错误日志:
客户端错误日志:
请附上访问日志
其它相关的配置文件(如 Nginx)和相关日志
如果 V2Ray 无法启动,请附上
--test
命令的输出如果 V2Ray 服务运行异常,请附上 journal 日志