Add cache_id option for Clash cache file

This commit is contained in:
世界
2023-05-09 17:58:59 +08:00
parent 6266d2df7e
commit 3741394269
5 changed files with 56 additions and 12 deletions

View File

@@ -48,6 +48,7 @@ type Server struct {
storeSelected bool
storeFakeIP bool
cacheFilePath string
cacheID string
cacheFile adapter.ClashCacheFile
externalUI string
@@ -88,6 +89,7 @@ func NewServer(ctx context.Context, router adapter.Router, logFactory log.Observ
cachePath = filemanager.BasePath(ctx, cachePath)
}
server.cacheFilePath = cachePath
server.cacheID = options.CacheID
}
cors := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
@@ -130,7 +132,7 @@ func NewServer(ctx context.Context, router adapter.Router, logFactory log.Observ
func (s *Server) PreStart() error {
if s.cacheFilePath != "" {
cacheFile, err := cachefile.Open(s.cacheFilePath)
cacheFile, err := cachefile.Open(s.cacheFilePath, s.cacheID)
if err != nil {
return E.Cause(err, "open cache file")
}