diff --git a/adapter/provider/parser.go b/adapter/provider/parser.go index f04bb77a..d885a546 100644 --- a/adapter/provider/parser.go +++ b/adapter/provider/parser.go @@ -73,7 +73,7 @@ func ParseProxyProvider(name string, mapping map[string]any) (types.ProxyProvide } vehicle = resource.NewHTTPVehicle(schema.URL, path) } else { - path := C.Path.GetRandomPath("proxies", schema.URL) + path := C.Path.GetPathByHash("proxies", schema.URL) vehicle = resource.NewHTTPVehicle(schema.URL, path) } default: diff --git a/constant/path.go b/constant/path.go index 68129838..897dcfdc 100644 --- a/constant/path.go +++ b/constant/path.go @@ -74,7 +74,7 @@ func (p *path) IsSafePath(path string) bool { return !strings.Contains(rel, "..") } -func (p *path) GetRandomPath(prefix, name string) string { +func (p *path) GetPathByHash(prefix, name string) string { hash := md5.Sum([]byte(name)) filename := hex.EncodeToString(hash[:]) return filepath.Join(p.HomeDir(), prefix, filename) diff --git a/rules/provider/parse.go b/rules/provider/parse.go index ef7beec5..0fbfb2cc 100644 --- a/rules/provider/parse.go +++ b/rules/provider/parse.go @@ -67,7 +67,7 @@ func ParseRuleProvider(name string, mapping map[string]interface{}, parse func(t } vehicle = resource.NewHTTPVehicle(schema.URL, path) } else { - path := C.Path.GetRandomPath("rules", schema.URL) + path := C.Path.GetPathByHash("rules", schema.URL) vehicle = resource.NewHTTPVehicle(schema.URL, path) }