mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-06-02 22:21:19 +00:00
Routing: consistent with domains key in DNS configuration (#502)
This commit is contained in:
parent
0dcd6ee838
commit
6858a7b0a7
|
@ -396,6 +396,7 @@ func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
|
||||||
type RawFieldRule struct {
|
type RawFieldRule struct {
|
||||||
RouterRule
|
RouterRule
|
||||||
Domain *StringList `json:"domain"`
|
Domain *StringList `json:"domain"`
|
||||||
|
Domains *StringList `json:"domains"`
|
||||||
IP *StringList `json:"ip"`
|
IP *StringList `json:"ip"`
|
||||||
Port *PortList `json:"port"`
|
Port *PortList `json:"port"`
|
||||||
Network *NetworkList `json:"network"`
|
Network *NetworkList `json:"network"`
|
||||||
|
@ -436,6 +437,16 @@ func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rawFieldRule.Domains != nil {
|
||||||
|
for _, domain := range *rawFieldRule.Domains {
|
||||||
|
rules, err := parseDomainRule(domain)
|
||||||
|
if err != nil {
|
||||||
|
return nil, newError("failed to parse domain rule: ", domain).Base(err)
|
||||||
|
}
|
||||||
|
rule.Domain = append(rule.Domain, rules...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if rawFieldRule.IP != nil {
|
if rawFieldRule.IP != nil {
|
||||||
geoipList, err := toCidrList(*rawFieldRule.IP)
|
geoipList, err := toCidrList(*rawFieldRule.IP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -37,6 +37,14 @@ func TestRouterConfig(t *testing.T) {
|
||||||
],
|
],
|
||||||
"outboundTag": "direct"
|
"outboundTag": "direct"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "field",
|
||||||
|
"domains": [
|
||||||
|
"v2fly.org",
|
||||||
|
"github.com"
|
||||||
|
],
|
||||||
|
"outboundTag": "direct"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "field",
|
"type": "field",
|
||||||
"ip": [
|
"ip": [
|
||||||
|
@ -87,6 +95,21 @@ func TestRouterConfig(t *testing.T) {
|
||||||
Tag: "direct",
|
Tag: "direct",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Domain: []*router.Domain{
|
||||||
|
{
|
||||||
|
Type: router.Domain_Plain,
|
||||||
|
Value: "v2fly.org",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: router.Domain_Plain,
|
||||||
|
Value: "github.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TargetTag: &router.RoutingRule_Tag{
|
||||||
|
Tag: "direct",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Geoip: []*router.GeoIP{
|
Geoip: []*router.GeoIP{
|
||||||
{
|
{
|
||||||
|
@ -145,6 +168,14 @@ func TestRouterConfig(t *testing.T) {
|
||||||
],
|
],
|
||||||
"outboundTag": "direct"
|
"outboundTag": "direct"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "field",
|
||||||
|
"domains": [
|
||||||
|
"v2fly.org",
|
||||||
|
"github.com"
|
||||||
|
],
|
||||||
|
"outboundTag": "direct"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "field",
|
"type": "field",
|
||||||
"ip": [
|
"ip": [
|
||||||
|
@ -175,6 +206,21 @@ func TestRouterConfig(t *testing.T) {
|
||||||
Tag: "direct",
|
Tag: "direct",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Domain: []*router.Domain{
|
||||||
|
{
|
||||||
|
Type: router.Domain_Plain,
|
||||||
|
Value: "v2fly.org",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: router.Domain_Plain,
|
||||||
|
Value: "github.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TargetTag: &router.RoutingRule_Tag{
|
||||||
|
Tag: "direct",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Geoip: []*router.GeoIP{
|
Geoip: []*router.GeoIP{
|
||||||
{
|
{
|
||||||
|
@ -209,6 +255,14 @@ func TestRouterConfig(t *testing.T) {
|
||||||
],
|
],
|
||||||
"outboundTag": "direct"
|
"outboundTag": "direct"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "field",
|
||||||
|
"domains": [
|
||||||
|
"v2fly.org",
|
||||||
|
"github.com"
|
||||||
|
],
|
||||||
|
"outboundTag": "direct"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "field",
|
"type": "field",
|
||||||
"ip": [
|
"ip": [
|
||||||
|
@ -238,6 +292,21 @@ func TestRouterConfig(t *testing.T) {
|
||||||
Tag: "direct",
|
Tag: "direct",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Domain: []*router.Domain{
|
||||||
|
{
|
||||||
|
Type: router.Domain_Plain,
|
||||||
|
Value: "v2fly.org",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: router.Domain_Plain,
|
||||||
|
Value: "github.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TargetTag: &router.RoutingRule_Tag{
|
||||||
|
Tag: "direct",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Geoip: []*router.GeoIP{
|
Geoip: []*router.GeoIP{
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user