diff --git a/infra/conf/router.go b/infra/conf/router.go index 9c7ce789..5a6ca8fe 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -8,8 +8,8 @@ import ( "github.com/xtls/xray-core/app/router" "github.com/xtls/xray-core/common/net" - "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/platform/filesystem" + "github.com/xtls/xray-core/common/serial" "google.golang.org/protobuf/proto" ) @@ -663,55 +663,5 @@ func ParseRule(msg json.RawMessage) (*router.RoutingRule, error) { } return fieldrule, nil } - if strings.EqualFold(rawRule.Type, "chinaip") { - chinaiprule, err := parseChinaIPRule(msg) - if err != nil { - return nil, newError("invalid chinaip rule").Base(err) - } - return chinaiprule, nil - } - if strings.EqualFold(rawRule.Type, "chinasites") { - chinasitesrule, err := parseChinaSitesRule(msg) - if err != nil { - return nil, newError("invalid chinasites rule").Base(err) - } - return chinasitesrule, nil - } return nil, newError("unknown router rule type: ", rawRule.Type) } - -func parseChinaIPRule(data []byte) (*router.RoutingRule, error) { - rawRule := new(RouterRule) - err := json.Unmarshal(data, rawRule) - if err != nil { - return nil, newError("invalid router rule").Base(err) - } - chinaIPs, err := loadGeoIP("CN") - if err != nil { - return nil, newError("failed to load geoip:cn").Base(err) - } - return &router.RoutingRule{ - TargetTag: &router.RoutingRule_Tag{ - Tag: rawRule.OutboundTag, - }, - Cidr: chinaIPs, - }, nil -} - -func parseChinaSitesRule(data []byte) (*router.RoutingRule, error) { - rawRule := new(RouterRule) - err := json.Unmarshal(data, rawRule) - if err != nil { - return nil, newError("invalid router rule").Base(err).AtError() - } - domains, err := loadGeositeWithAttr("geosite.dat", "CN") - if err != nil { - return nil, newError("failed to load geosite:cn.").Base(err) - } - return &router.RoutingRule{ - TargetTag: &router.RoutingRule_Tag{ - Tag: rawRule.OutboundTag, - }, - Domain: domains, - }, nil -}