MCPcopy Create free account
hub / github.com/AandStep/ResultV / startAdBlockFilterRefresh

Method startAdBlockFilterRefresh

app.go:1204–1236  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1202}
1203
1204func (a *App) startAdBlockFilterRefresh() {
1205 if a.ctx == nil || a.filters == nil {
1206 return
1207 }
1208 go func() {
1209 ticker := time.NewTicker(24 * time.Hour)
1210 defer ticker.Stop()
1211 for {
1212 select {
1213 case <-a.ctx.Done():
1214 return
1215 case <-ticker.C:
1216 ctx, cancel := context.WithTimeout(a.ctx, 2*time.Minute)
1217 err := a.filters.Update(ctx, a.emitAdBlockProgress)
1218 cancel()
1219 if err != nil {
1220 a.log.Warning(fmt.Sprintf("[ADBLOCK] Периодическое обновление: %v", err))
1221 continue
1222 }
1223 a.log.Info("[ADBLOCK] Периодические базы блокировки обновлены")
1224 if a.proxy != nil && a.proxy.GetStatus().IsConnected && a.config != nil {
1225 cfg := a.config.GetConfig()
1226 if cfg.Settings.AdBlock {
1227 result := a.proxy.ReconnectWithRoutingRules(a.ctx, proxy.RoutingMode(cfg.RoutingRules.Mode), cfg.RoutingRules.Whitelist, cfg.RoutingRules.AppWhitelist)
1228 if !result.Success {
1229 a.log.Warning(fmt.Sprintf("[ADBLOCK] Переподключение: %s", result.Message))
1230 }
1231 }
1232 }
1233 }
1234 }
1235 }()
1236}
1237
1238func (a *App) SetAutostart(enable bool) error {
1239 exe, err := os.Executable()

Callers 1

initAdBlockFiltersMethod · 0.95

Calls 8

RoutingModeTypeAlias · 0.92
UpdateMethod · 0.80
StopMethod · 0.65
WarningMethod · 0.65
InfoMethod · 0.65
GetStatusMethod · 0.45
GetConfigMethod · 0.45

Tested by

no test coverage detected