mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
[Fix]GeoSite.dat initial in logic rule
This commit is contained in:
parent
4a446c4e31
commit
7465eaafa1
|
@ -556,7 +556,7 @@ func parseRules(cfg *RawConfig, proxies map[string]C.Proxy) ([]C.Rule, map[strin
|
|||
params = trimArr(params)
|
||||
|
||||
if ruleName == "GEOSITE" {
|
||||
if err := initGeoSite(); err != nil {
|
||||
if err := InitGeoSite(); err != nil {
|
||||
return nil, nil, fmt.Errorf("can't initial GeoSite: %w", err)
|
||||
}
|
||||
}
|
||||
|
@ -701,7 +701,7 @@ func parseFallbackIPCIDR(ips []string) ([]*net.IPNet, error) {
|
|||
func parseFallbackGeoSite(countries []string, rules []C.Rule) ([]*router.DomainMatcher, error) {
|
||||
var sites []*router.DomainMatcher
|
||||
if len(countries) > 0 {
|
||||
if err := initGeoSite(); err != nil {
|
||||
if err := InitGeoSite(); err != nil {
|
||||
return nil, fmt.Errorf("can't initial GeoSite: %w", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ func downloadGeoSite(path string) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
func initGeoSite() error {
|
||||
func InitGeoSite() error {
|
||||
if _, err := os.Stat(C.Path.GeoSite()); os.IsNotExist(err) {
|
||||
log.Infoln("Need GeoSite but can't find GeoSite.dat, start download")
|
||||
if err := downloadGeoSite(C.Path.GeoSite()); err != nil {
|
||||
|
|
|
@ -3,7 +3,9 @@ package logic
|
|||
import (
|
||||
"fmt"
|
||||
"github.com/Dreamacro/clash/common/collections"
|
||||
"github.com/Dreamacro/clash/config"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/clash/log"
|
||||
RC "github.com/Dreamacro/clash/rule/common"
|
||||
"github.com/Dreamacro/clash/rule/provider"
|
||||
"regexp"
|
||||
|
@ -52,6 +54,11 @@ func payloadToRule(subPayload string) (C.Rule, error) {
|
|||
if tp == "NOT" || tp == "OR" || tp == "AND" {
|
||||
return parseRule(tp, payload, nil)
|
||||
}
|
||||
if tp == "GEOSITE" {
|
||||
if err := config.InitGeoSite(); err != nil {
|
||||
log.Errorln("can't initial GeoSite: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
param := strings.Split(payload, ",")
|
||||
return parseRule(tp, param[0], param[1:])
|
||||
|
|
Loading…
Reference in New Issue
Block a user