From 217f77643f19e915ea38ba2a9ac7e28e22a0cec5 Mon Sep 17 00:00:00 2001 From: Shtorm <108103062+shtorm-7@users.noreply.github.com> Date: Sat, 5 Sep 2026 10:12:55 +0300 Subject: [PATCH] provider: Rename StoreProviders to StoreSubscriptions --- adapter/experimental.go | 2 +- examples/provider/remote.json | 2 +- experimental/cachefile/cache.go | 40 ++++++++++++++++----------------- option/experimental.go | 20 ++++++++--------- provider/remote/provider.go | 6 ++--- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/adapter/experimental.go b/adapter/experimental.go index d591d218..9d84fe1e 100644 --- a/adapter/experimental.go +++ b/adapter/experimental.go @@ -43,7 +43,7 @@ type CacheFile interface { StoreWARPConfig() bool StoreMASQUEConfig() bool - StoreProviders() bool + StoreSubscriptions() bool StoreDNS() bool DNSCacheStore diff --git a/examples/provider/remote.json b/examples/provider/remote.json index ba25cb22..a2dce172 100644 --- a/examples/provider/remote.json +++ b/examples/provider/remote.json @@ -102,7 +102,7 @@ "experimental": { "cache_file": { "enabled": true, - "store_providers": true // For persisting fetched subscriptions across restarts + "store_subscriptions": true // For persisting fetched subscriptions across restarts } } } diff --git a/experimental/cachefile/cache.go b/experimental/cachefile/cache.go index f930a531..833ef5fa 100644 --- a/experimental/cachefile/cache.go +++ b/experimental/cachefile/cache.go @@ -51,7 +51,7 @@ type CacheFile struct { storeDNS bool storeWARPConfig bool storeMASQUEConfig bool - storeProviders bool + storeSubscriptions bool disableExpire bool rdrcTimeout time.Duration optimisticTimeout time.Duration @@ -106,23 +106,23 @@ func New(ctx context.Context, logger logger.Logger, options option.CacheFileOpti } } return &CacheFile{ - ctx: ctx, - logger: logger, - path: filemanager.BasePath(ctx, path), - cacheID: cacheIDBytes, - cacheIDText: options.CacheID, - storeFakeIP: options.StoreFakeIP, - storeRDRC: options.StoreRDRC, - storeDNS: options.StoreDNS, - storeWARPConfig: options.StoreWARPConfig, - storeMASQUEConfig: options.StoreMASQUEConfig, - storeProviders: options.StoreProviders, - rdrcTimeout: rdrcTimeout, - saveDomain: make(map[netip.Addr]string), - saveAddress4: make(map[string]netip.Addr), - saveAddress6: make(map[string]netip.Addr), - saveRDRC: make(map[saveCacheKey]bool), - saveDNSCache: make(map[saveCacheKey]saveDNSCacheEntry), + ctx: ctx, + logger: logger, + path: filemanager.BasePath(ctx, path), + cacheID: cacheIDBytes, + cacheIDText: options.CacheID, + storeFakeIP: options.StoreFakeIP, + storeRDRC: options.StoreRDRC, + storeDNS: options.StoreDNS, + storeWARPConfig: options.StoreWARPConfig, + storeMASQUEConfig: options.StoreMASQUEConfig, + storeSubscriptions: options.StoreSubscriptions, + rdrcTimeout: rdrcTimeout, + saveDomain: make(map[netip.Addr]string), + saveAddress4: make(map[string]netip.Addr), + saveAddress6: make(map[string]netip.Addr), + saveRDRC: make(map[saveCacheKey]bool), + saveDNSCache: make(map[saveCacheKey]saveDNSCacheEntry), } } @@ -487,8 +487,8 @@ func (c *CacheFile) StoreMASQUEConfig() bool { return c.storeMASQUEConfig } -func (c *CacheFile) StoreProviders() bool { - return c.storeProviders +func (c *CacheFile) StoreSubscriptions() bool { + return c.storeSubscriptions } func (c *CacheFile) LoadWARPConfig(tag string) *adapter.SavedBinary { diff --git a/option/experimental.go b/option/experimental.go index 74df3f39..bb2e1012 100644 --- a/option/experimental.go +++ b/option/experimental.go @@ -11,16 +11,16 @@ type ExperimentalOptions struct { } type CacheFileOptions struct { - Enabled bool `json:"enabled,omitempty"` - Path string `json:"path,omitempty"` - CacheID string `json:"cache_id,omitempty"` - StoreFakeIP bool `json:"store_fakeip,omitempty"` - StoreRDRC bool `json:"store_rdrc,omitempty" schema:"omit"` - StoreWARPConfig bool `json:"store_warp_config,omitempty"` - StoreMASQUEConfig bool `json:"store_masque_config,omitempty"` - StoreProviders bool `json:"store_providers,omitempty"` - RDRCTimeout badoption.Duration `json:"rdrc_timeout,omitempty"` - StoreDNS bool `json:"store_dns,omitempty"` + Enabled bool `json:"enabled,omitempty"` + Path string `json:"path,omitempty"` + CacheID string `json:"cache_id,omitempty"` + StoreFakeIP bool `json:"store_fakeip,omitempty"` + StoreRDRC bool `json:"store_rdrc,omitempty" schema:"omit"` + StoreWARPConfig bool `json:"store_warp_config,omitempty"` + StoreMASQUEConfig bool `json:"store_masque_config,omitempty"` + StoreSubscriptions bool `json:"store_subscriptions,omitempty"` + RDRCTimeout badoption.Duration `json:"rdrc_timeout,omitempty"` + StoreDNS bool `json:"store_dns,omitempty"` } type ClashAPIOptions struct { diff --git a/provider/remote/provider.go b/provider/remote/provider.go index fec616f9..ca034e94 100644 --- a/provider/remote/provider.go +++ b/provider/remote/provider.go @@ -107,7 +107,7 @@ func NewProviderRemote(ctx context.Context, router adapter.Router, logFactory lo func (s *ProviderRemote) Start() error { s.cacheFile = service.FromContext[adapter.CacheFile](s.ctx) - if s.cacheFile != nil && s.cacheFile.StoreProviders() { + if s.cacheFile != nil && s.cacheFile.StoreSubscriptions() { if saveSub := s.cacheFile.LoadSubscription(s.Tag()); saveSub != nil { content, _ := boxCommon.DecodeBase64URLSafe(string(saveSub.Content)) firstLine, others := getFirstLine(content) @@ -208,7 +208,7 @@ func (s *ProviderRemote) fetch(ctx context.Context) error { case http.StatusNotModified: s.subscriptionInfo = info s.lastUpdated = time.Now() - if s.cacheFile != nil && s.cacheFile.StoreProviders() { + if s.cacheFile != nil && s.cacheFile.StoreSubscriptions() { saveSub := s.cacheFile.LoadSubscription(s.Tag()) if saveSub != nil { if hasInfo { @@ -252,7 +252,7 @@ func (s *ProviderRemote) fetch(ctx context.Context) error { s.UpdateGroups() s.subscriptionInfo = info s.lastUpdated = time.Now() - if s.cacheFile != nil && s.cacheFile.StoreProviders() { + if s.cacheFile != nil && s.cacheFile.StoreSubscriptions() { content, _ := json.Marshal(option.Options{ Outbounds: s.lastOutOpts, })