public bool RefreshDomainBlocklist(string Url = "") // empty means all { if (Url.Length == 0) { ListLock.EnterReadLock(); var blocklists = Blocklists.Values.ToList(); ListLock.ExitWriteLock(); foreach (DomainBlocklist blocklist in blocklists) { if (blocklist.Enabled && blocklist.Url.Length != 0) { RefreshDomainBlocklist(blocklist.Url); } } return(true); } if (PendingDownloads.Contains(Url)) { return(true); // already in progress } PendingDownloads.Add(Url); DownloadNextFile(); return(true); }
///////////////////////////////////////////////////////// // Updater public void CheckForUpdates() { ListLock.EnterReadLock(); var blocklists = Blocklists.Values.ToList(); ListLock.ExitReadLock(); if (ReloadBlocklists != 0 && ReloadBlocklists < MiscFunc.GetUTCTimeMs()) // in case we do more changes dont reload rightaway { ReloadBlocklists = 0; foreach (DomainBlocklist blocklist in blocklists) { string fileName = App.dataPath + @"\DnsBlockLists\" + blocklist.FileName; if (blocklist.Enabled && (blocklist.FileName.Length == 0 || !File.Exists(fileName))) { RefreshDomainBlocklist(blocklist.Url); } } LoadBlockLists(); } DateTime Temp = DateTime.Now.AddDays(-App.GetConfigInt("DnsProxy", "UpdateDays", 7)); foreach (DomainBlocklist blocklist in blocklists) { if (blocklist.Enabled && (blocklist.LastUpdate == null || blocklist.LastUpdate < Temp) && !PendingDownloads.Contains(blocklist.Url)) { RefreshDomainBlocklist(blocklist.Url); } } }