()
| 1202 | } |
| 1203 | |
| 1204 | func (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 | |
| 1238 | func (a *App) SetAutostart(enable bool) error { |
| 1239 | exe, err := os.Executable() |
no test coverage detected