provider: Rename StoreProviders to StoreSubscriptions

This commit is contained in:
Shtorm
2026-09-05 10:12:55 +03:00
parent 7afda58818
commit 217f77643f
5 changed files with 35 additions and 35 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ type CacheFile interface {
StoreWARPConfig() bool
StoreMASQUEConfig() bool
StoreProviders() bool
StoreSubscriptions() bool
StoreDNS() bool
DNSCacheStore
+1 -1
View File
@@ -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
}
}
}
+20 -20
View File
@@ -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 {
+10 -10
View File
@@ -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 {
+3 -3
View File
@@ -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,
})