diff --git a/infra/conf/router.go b/infra/conf/router.go index 44f9e8fa..69198d6a 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -14,11 +14,6 @@ import ( "google.golang.org/protobuf/proto" ) -type RouterRulesConfig struct { - RuleList []json.RawMessage `json:"rules"` - DomainStrategy string `json:"domainStrategy"` -} - // StrategyConfig represents a strategy config type StrategyConfig struct { Type string `json:"type"` @@ -76,7 +71,6 @@ func (r *BalancingRule) Build() (*router.BalancingRule, error) { } type RouterConfig struct { - Settings *RouterRulesConfig `json:"settings"` // Deprecated RuleList []json.RawMessage `json:"rules"` DomainStrategy *string `json:"domainStrategy"` Balancers []*BalancingRule `json:"balancers"` @@ -88,8 +82,6 @@ func (c *RouterConfig) getDomainStrategy() router.Config_DomainStrategy { ds := "" if c.DomainStrategy != nil { ds = *c.DomainStrategy - } else if c.Settings != nil { - ds = c.Settings.DomainStrategy } switch strings.ToLower(ds) { @@ -111,10 +103,6 @@ func (c *RouterConfig) Build() (*router.Config, error) { var rawRuleList []json.RawMessage if c != nil { rawRuleList = c.RuleList - if c.Settings != nil { - c.RuleList = append(c.RuleList, c.Settings.RuleList...) - rawRuleList = c.RuleList - } } for _, rawRule := range rawRuleList { diff --git a/infra/conf/router_test.go b/infra/conf/router_test.go index de4c8ed2..340b871c 100644 --- a/infra/conf/router_test.go +++ b/infra/conf/router_test.go @@ -64,36 +64,33 @@ func TestRouterConfig(t *testing.T) { runMultiTestCase(t, []TestCase{ { Input: `{ - "strategy": "rules", - "settings": { - "domainStrategy": "AsIs", - "rules": [ - { - "type": "field", - "domain": [ - "baidu.com", - "qq.com" - ], - "outboundTag": "direct" - }, - { - "type": "field", - "ip": [ - "10.0.0.0/8", - "::1/128" - ], - "outboundTag": "test" - },{ - "type": "field", - "port": "53, 443, 1000-2000", - "outboundTag": "test" - },{ - "type": "field", - "port": 123, - "outboundTag": "test" - } - ] - }, + "domainStrategy": "AsIs", + "rules": [ + { + "type": "field", + "domain": [ + "baidu.com", + "qq.com" + ], + "outboundTag": "direct" + }, + { + "type": "field", + "ip": [ + "10.0.0.0/8", + "::1/128" + ], + "outboundTag": "test" + },{ + "type": "field", + "port": "53, 443, 1000-2000", + "outboundTag": "test" + },{ + "type": "field", + "port": 123, + "outboundTag": "test" + } + ], "balancers": [ { "tag": "b1", @@ -225,28 +222,25 @@ func TestRouterConfig(t *testing.T) { }, { Input: `{ - "strategy": "rules", - "settings": { - "domainStrategy": "IPIfNonMatch", - "rules": [ - { - "type": "field", - "domain": [ - "baidu.com", - "qq.com" - ], - "outboundTag": "direct" - }, - { - "type": "field", - "ip": [ - "10.0.0.0/8", - "::1/128" - ], - "outboundTag": "test" - } - ] - } + "domainStrategy": "IPIfNonMatch", + "rules": [ + { + "type": "field", + "domain": [ + "baidu.com", + "qq.com" + ], + "outboundTag": "direct" + }, + { + "type": "field", + "ip": [ + "10.0.0.0/8", + "::1/128" + ], + "outboundTag": "test" + } + ] }`, Parser: createParser(), Output: &router.Config{ @@ -289,68 +283,5 @@ func TestRouterConfig(t *testing.T) { }, }, }, - { - Input: `{ - "domainStrategy": "AsIs", - "rules": [ - { - "type": "field", - "domain": [ - "baidu.com", - "qq.com" - ], - "outboundTag": "direct" - }, - { - "type": "field", - "ip": [ - "10.0.0.0/8", - "::1/128" - ], - "outboundTag": "test" - } - ] - }`, - Parser: createParser(), - Output: &router.Config{ - DomainStrategy: router.Config_AsIs, - Rule: []*router.RoutingRule{ - { - Domain: []*router.Domain{ - { - Type: router.Domain_Plain, - Value: "baidu.com", - }, - { - Type: router.Domain_Plain, - Value: "qq.com", - }, - }, - TargetTag: &router.RoutingRule_Tag{ - Tag: "direct", - }, - }, - { - Geoip: []*router.GeoIP{ - { - Cidr: []*router.CIDR{ - { - Ip: []byte{10, 0, 0, 0}, - Prefix: 8, - }, - { - Ip: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, - Prefix: 128, - }, - }, - }, - }, - TargetTag: &router.RoutingRule_Tag{ - Tag: "test", - }, - }, - }, - }, - }, }) } diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 6daca0f7..07f70273 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -361,11 +361,6 @@ func (c *StatsConfig) Build() (*stats.Config, error) { } type Config struct { - // Port of this Point server. - // Deprecated: Port exists for historical compatibility - // and should not be used. - Port uint16 `json:"port"` - // Deprecated: Global transport config is no longer used // left for returning error Transport map[string]json.RawMessage `json:"transport"` @@ -597,14 +592,6 @@ func (c *Config) Build() (*core.Config, error) { inbounds = append(inbounds, c.InboundConfigs...) } - // Backward compatibility. - if len(inbounds) > 0 && inbounds[0].PortList == nil && c.Port > 0 { - inbounds[0].PortList = &PortList{[]PortRange{{ - From: uint32(c.Port), - To: uint32(c.Port), - }}} - } - if len(c.Transport) > 0 { return nil, errors.New("Global transport config is deprecated") } diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index 7d3e2c4c..d225dbf9 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -74,18 +74,15 @@ func TestXrayConfig(t *testing.T) { } }], "routing": { - "strategy": "rules", - "settings": { - "rules": [ - { - "ip": [ - "10.0.0.0/8" - ], - "type": "field", - "outboundTag": "blocked" - } - ] - } + "rules": [ + { + "ip": [ + "10.0.0.0/8" + ], + "type": "field", + "outboundTag": "blocked" + } + ] } }`, Parser: createParser(),