diff --git a/data/StevenBlack/hosts b/data/StevenBlack/hosts index 8ade1e348..d801bfa57 100644 --- a/data/StevenBlack/hosts +++ b/data/StevenBlack/hosts @@ -2818,4 +2818,31 @@ # Added July 8, 2020 0.0.0.0 runative-syndicate.com -0.0.0.0 www.protectmobiletechieai.club \ No newline at end of file +0.0.0.0 www.protectmobiletechieai.club + +# Added July 10, 2020 +0.0.0.0 xad.dnoticias.pt +0.0.0.0 ad.dnoticias.pt +0.0.0.0 advert.puzzles.mkjigsaw.com +0.0.0.0 adtracker.mkjigsaw.com +0.0.0.0 dadsats.com + +# Added July 10, 2020 +0.0.0.0 cdn.usefathom.com + +# Added July 12, 2020 +0.0.0.0 calltracking.fathomseo.com +0.0.0.0 adtrack.voicestar.com +0.0.0.0 wildcard.directtrack.com.wipext.digitalriverws.com +0.0.0.0 collect.usefathom.com +0.0.0.0 img3.usefathom.com +0.0.0.0 akr.usesfathom.com +0.0.0.0 archsmarter.usesfathom.com +0.0.0.0 butshesagirl.usesfathom.com +0.0.0.0 gateguardian.usesfathom.com +0.0.0.0 jsfiddle.usesfathom.com +0.0.0.0 justin.usesfathom.com +0.0.0.0 paleoleap.usesfathom.com +0.0.0.0 perroverde.usesfathom.com +0.0.0.0 stats.usesfathom.com +0.0.0.0 d3lvir7538n0oi.cloudfront.net \ No newline at end of file diff --git a/readme_template.md b/readme_template.md index 00f12807f..954be6fb2 100644 --- a/readme_template.md +++ b/readme_template.md @@ -1,7 +1,8 @@ ---- **Take Note!** -- This version of the Hosts file generator, and tests, are for Python 3.5+ only. -- With the exception of issues and PRs regarding changes to `hosts/data/StevenBlack/hosts`, all other issues regarding the content of the produced hosts files should be made with the appropriate data source that contributed the content in question. The contact information for all of the data sources can be found in the `hosts/data/` directory. + +* This version of the Hosts file generator, and tests, are for Python 3.5+ only. +* With the exception of issues and PRs regarding changes to `hosts/data/StevenBlack/hosts`, all other issues regarding the content of the produced hosts files should be made with the appropriate data source that contributed the content in question. The contact information for all of the data sources can be found in the `hosts/data/` directory. ---- ![Logo](https://raw.githubusercontent.com/StevenBlack/hosts/master/.github/logo.png) @@ -155,15 +156,18 @@ to remove hosts from the generated hosts file. #### Using NixOS: To install hosts file on your machine add the following into your `configuration.nix`: -```haskell - networking.extraHosts = let + +```nix +{ + networking.extraHosts = let hostsPath = https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts; hostsFile = builtins.fetchurl hostsPath; in builtins.readFile "${hostsFile}"; +} ``` -* NOTE: Change `hostsPath` if you need other versions of hosts file. -* NOTE: The call to `fetchurl` is impure. +* NOTE: Change `hostsPath` if you need other versions of hosts file. +* NOTE: The call to `fetchurl` is impure. Use `fetchFromGitHub` with the exact commit if you want to always get the same result. diff --git a/testUpdateHostsFile.py b/testUpdateHostsFile.py index c957e3bb2..1fb72993b 100644 --- a/testUpdateHostsFile.py +++ b/testUpdateHostsFile.py @@ -1327,7 +1327,7 @@ class TestFlushDnsCache(BaseStdout): self.assertIn(expected, output) @mock.patch("os.path.isfile", side_effect=[True, False, False, True] + [False] * 10) - @mock.patch("subprocess.call", side_effect=[1, 0]) + @mock.patch("subprocess.call", side_effect=[1, 0, 0]) def test_flush_posix_fail_then_succeed(self, *_): with self.mock_property("platform.system") as obj: obj.return_value = "Linux" diff --git a/updateHostsFile.py b/updateHostsFile.py index 8eaff1717..341676e23 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -1293,6 +1293,7 @@ def flush_dns_cache(): system_prefixes = ["/usr", ""] service_types = ["NetworkManager", "wicd", "dnsmasq", "networking"] + restarted_services = [] for system_prefix in system_prefixes: systemctl = system_prefix + "/bin/systemctl" @@ -1300,18 +1301,25 @@ def flush_dns_cache(): for service_type in service_types: service = service_type + ".service" + if service in restarted_services: + continue + service_file = path_join_robust(system_dir, service) service_msg = ( "Flushing the DNS cache by restarting " + service + " {result}" ) if os.path.isfile(service_file): + if 0 != subprocess.call([systemctl, "status", service], + stdout=subprocess.DEVNULL): + continue dns_cache_found = True if subprocess.call(SUDO + [systemctl, "restart", service]): print_failure(service_msg.format(result="failed")) else: print_success(service_msg.format(result="succeeded")) + restarted_services.append(service) dns_clean_file = "/etc/init.d/dns-clean" dns_clean_msg = "Flushing the DNS cache via dns-clean executable {result}"