diff --git a/core/src/foss/golang/clash b/core/src/foss/golang/clash index e928ef59..01edf45c 160000 --- a/core/src/foss/golang/clash +++ b/core/src/foss/golang/clash @@ -1 +1 @@ -Subproject commit e928ef59c1aaa5b7db01a3a01f2c97730f0d0d16 +Subproject commit 01edf45ce05900a01335ad086ff0c2e88a6eb722 diff --git a/core/src/main/golang/native/config/fetch.go b/core/src/main/golang/native/config/fetch.go index ba08ebcc..e6770341 100644 --- a/core/src/main/golang/native/config/fetch.go +++ b/core/src/main/golang/native/config/fetch.go @@ -15,6 +15,7 @@ import ( "cfa/native/app" clashHttp "github.com/metacubex/mihomo/component/http" + RB "github.com/metacubex/mihomo/rules/bundle" ) type Status struct { @@ -60,6 +61,10 @@ func fetch(url *U.URL, file string) error { defer reader.Close() + return writeFile(file, reader) +} + +func writeFile(file string, reader io.Reader) error { _ = os.MkdirAll(P.Dir(file), 0700) f, err := os.OpenFile(file, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0600) @@ -145,6 +150,22 @@ func FetchAndValid( return } + if prefix == RULES { + if pib, uok := provider["path-in-bundle"]; uok { + if pib, uok := pib.(string); uok && pib != "" { + // actually, we don't need to extract the file here; the core will do it. + // however, due to historical reasons, CMFA fetches provider content when loading profile, + // so we maintain consistency with the old behavior. + if file, err := RB.Open(pib); err == nil { + defer file.Close() + if err := writeFile(ps, file); err == nil { + return + } + } + } + } + } + _ = fetch(url, ps) })