mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 17:46:58 -05: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 {
|
||||
RouterRule
|
||||
Domain *StringList `json:"domain"`
|
||||
Domains *StringList `json:"domains"`
|
||||
IP *StringList `json:"ip"`
|
||||
Port *PortList `json:"port"`
|
||||
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 {
|
||||
geoipList, err := toCidrList(*rawFieldRule.IP)
|
||||
if err != nil {
|
||||
|
@ -37,6 +37,14 @@ func TestRouterConfig(t *testing.T) {
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"domains": [
|
||||
"v2fly.org",
|
||||
"github.com"
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"ip": [
|
||||
@ -87,6 +95,21 @@ func TestRouterConfig(t *testing.T) {
|
||||
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{
|
||||
{
|
||||
@ -145,6 +168,14 @@ func TestRouterConfig(t *testing.T) {
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"domains": [
|
||||
"v2fly.org",
|
||||
"github.com"
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"ip": [
|
||||
@ -175,6 +206,21 @@ func TestRouterConfig(t *testing.T) {
|
||||
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{
|
||||
{
|
||||
@ -209,6 +255,14 @@ func TestRouterConfig(t *testing.T) {
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"domains": [
|
||||
"v2fly.org",
|
||||
"github.com"
|
||||
],
|
||||
"outboundTag": "direct"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"ip": [
|
||||
@ -238,6 +292,21 @@ func TestRouterConfig(t *testing.T) {
|
||||
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{
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user