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 StoreWARPConfig() bool
StoreMASQUEConfig() bool StoreMASQUEConfig() bool
StoreProviders() bool StoreSubscriptions() bool
StoreDNS() bool StoreDNS() bool
DNSCacheStore DNSCacheStore
+1 -1
View File
@@ -102,7 +102,7 @@
"experimental": { "experimental": {
"cache_file": { "cache_file": {
"enabled": true, "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 storeDNS bool
storeWARPConfig bool storeWARPConfig bool
storeMASQUEConfig bool storeMASQUEConfig bool
storeProviders bool storeSubscriptions bool
disableExpire bool disableExpire bool
rdrcTimeout time.Duration rdrcTimeout time.Duration
optimisticTimeout time.Duration optimisticTimeout time.Duration
@@ -106,23 +106,23 @@ func New(ctx context.Context, logger logger.Logger, options option.CacheFileOpti
} }
} }
return &CacheFile{ return &CacheFile{
ctx: ctx, ctx: ctx,
logger: logger, logger: logger,
path: filemanager.BasePath(ctx, path), path: filemanager.BasePath(ctx, path),
cacheID: cacheIDBytes, cacheID: cacheIDBytes,
cacheIDText: options.CacheID, cacheIDText: options.CacheID,
storeFakeIP: options.StoreFakeIP, storeFakeIP: options.StoreFakeIP,
storeRDRC: options.StoreRDRC, storeRDRC: options.StoreRDRC,
storeDNS: options.StoreDNS, storeDNS: options.StoreDNS,
storeWARPConfig: options.StoreWARPConfig, storeWARPConfig: options.StoreWARPConfig,
storeMASQUEConfig: options.StoreMASQUEConfig, storeMASQUEConfig: options.StoreMASQUEConfig,
storeProviders: options.StoreProviders, storeSubscriptions: options.StoreSubscriptions,
rdrcTimeout: rdrcTimeout, rdrcTimeout: rdrcTimeout,
saveDomain: make(map[netip.Addr]string), saveDomain: make(map[netip.Addr]string),
saveAddress4: make(map[string]netip.Addr), saveAddress4: make(map[string]netip.Addr),
saveAddress6: make(map[string]netip.Addr), saveAddress6: make(map[string]netip.Addr),
saveRDRC: make(map[saveCacheKey]bool), saveRDRC: make(map[saveCacheKey]bool),
saveDNSCache: make(map[saveCacheKey]saveDNSCacheEntry), saveDNSCache: make(map[saveCacheKey]saveDNSCacheEntry),
} }
} }
@@ -487,8 +487,8 @@ func (c *CacheFile) StoreMASQUEConfig() bool {
return c.storeMASQUEConfig return c.storeMASQUEConfig
} }
func (c *CacheFile) StoreProviders() bool { func (c *CacheFile) StoreSubscriptions() bool {
return c.storeProviders return c.storeSubscriptions
} }
func (c *CacheFile) LoadWARPConfig(tag string) *adapter.SavedBinary { func (c *CacheFile) LoadWARPConfig(tag string) *adapter.SavedBinary {
+10 -10
View File
@@ -11,16 +11,16 @@ type ExperimentalOptions struct {
} }
type CacheFileOptions struct { type CacheFileOptions struct {
Enabled bool `json:"enabled,omitempty"` Enabled bool `json:"enabled,omitempty"`
Path string `json:"path,omitempty"` Path string `json:"path,omitempty"`
CacheID string `json:"cache_id,omitempty"` CacheID string `json:"cache_id,omitempty"`
StoreFakeIP bool `json:"store_fakeip,omitempty"` StoreFakeIP bool `json:"store_fakeip,omitempty"`
StoreRDRC bool `json:"store_rdrc,omitempty" schema:"omit"` StoreRDRC bool `json:"store_rdrc,omitempty" schema:"omit"`
StoreWARPConfig bool `json:"store_warp_config,omitempty"` StoreWARPConfig bool `json:"store_warp_config,omitempty"`
StoreMASQUEConfig bool `json:"store_masque_config,omitempty"` StoreMASQUEConfig bool `json:"store_masque_config,omitempty"`
StoreProviders bool `json:"store_providers,omitempty"` StoreSubscriptions bool `json:"store_subscriptions,omitempty"`
RDRCTimeout badoption.Duration `json:"rdrc_timeout,omitempty"` RDRCTimeout badoption.Duration `json:"rdrc_timeout,omitempty"`
StoreDNS bool `json:"store_dns,omitempty"` StoreDNS bool `json:"store_dns,omitempty"`
} }
type ClashAPIOptions struct { 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 { func (s *ProviderRemote) Start() error {
s.cacheFile = service.FromContext[adapter.CacheFile](s.ctx) 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 { if saveSub := s.cacheFile.LoadSubscription(s.Tag()); saveSub != nil {
content, _ := boxCommon.DecodeBase64URLSafe(string(saveSub.Content)) content, _ := boxCommon.DecodeBase64URLSafe(string(saveSub.Content))
firstLine, others := getFirstLine(content) firstLine, others := getFirstLine(content)
@@ -208,7 +208,7 @@ func (s *ProviderRemote) fetch(ctx context.Context) error {
case http.StatusNotModified: case http.StatusNotModified:
s.subscriptionInfo = info s.subscriptionInfo = info
s.lastUpdated = time.Now() s.lastUpdated = time.Now()
if s.cacheFile != nil && s.cacheFile.StoreProviders() { if s.cacheFile != nil && s.cacheFile.StoreSubscriptions() {
saveSub := s.cacheFile.LoadSubscription(s.Tag()) saveSub := s.cacheFile.LoadSubscription(s.Tag())
if saveSub != nil { if saveSub != nil {
if hasInfo { if hasInfo {
@@ -252,7 +252,7 @@ func (s *ProviderRemote) fetch(ctx context.Context) error {
s.UpdateGroups() s.UpdateGroups()
s.subscriptionInfo = info s.subscriptionInfo = info
s.lastUpdated = time.Now() s.lastUpdated = time.Now()
if s.cacheFile != nil && s.cacheFile.StoreProviders() { if s.cacheFile != nil && s.cacheFile.StoreSubscriptions() {
content, _ := json.Marshal(option.Options{ content, _ := json.Marshal(option.Options{
Outbounds: s.lastOutOpts, Outbounds: s.lastOutOpts,
}) })