hectorm / hblock

Improve your security and privacy by blocking ads, tracking and malware domains.
https://hblock.molinero.dev
MIT License
1.63k stars 104 forks source link

Syntax for `sources.list` (or alternative files) to add or remove individual sources without duplicating defaults #134

Open Ultrabenosaurus opened 1 year ago

Ultrabenosaurus commented 1 year ago

Is your feature request related to a problem? Please describe: I prefer to use one of the other hosts lists from StevenBlack over his base list. To do this with hblock I have to copy all sources from the hblock source code into a sources.list file and replace a single line with my desired StevenBlock URL.

If an update to hblock changes the builtin sources, such as between 3.4.0 and 3.4.2 which I've just downloaded, these changes are not implemented on my computer until I manually update my sources.list file accordingly.

I would like some way to add and / or exclude specific hosts lists without completely overriding the whole builtin list, which then "breaks" any updates to the list within hblock itself.

Describe the solution you'd like: I propose to either add some sort of syntax to the sources.list file or to add 2 more source files. Users can then add and exclude individual URLs, or substitute builtin sources by using both add and exclude together.

Adding new source list files is rather self-explanatory: the existing sources.list to ignore builtins and only parse the user's list, a sources-add.list file for URLs to download as well as the builtins, and a sources-exclude.list file for sources which are in the builtin list but the user wants hblock to ignore.

For the idea of keeping a single sources.list file but giving it some form of syntax, I was thinking something like:

Of course, lines with the # prefix should continue to be totally ignored as they currently are, to allow users to temporarily disable custom sources or to comment their source list.

For example:

-https://raw.githubusercontent.com/hectorm/hmirror/master/data/easylist-ara/list.txt
-https://raw.githubusercontent.com/hectorm/hmirror/master/data/easylist-bul/list.txt
-https://raw.githubusercontent.com/hectorm/hmirror/master/data/easylist-ces-slk/list.txt
-https://raw.githubusercontent.com/hectorm/hmirror/master/data/easylist-zho/list.txt
#https://hosts.oisd.nl/
+https://raw.githubusercontent.com/smed79/blacklist/master/abp.txt
+https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling/hosts
-https://raw.githubusercontent.com/hectorm/hmirror/master/data/turkish-ad-hosts/list.txt

Describe alternatives you've considered: I have looked through the .md files in this repo and the output of hblock --help but cannot see any way to create a list of custom sources which is update-safe.

Additional context: None.

hectorm commented 1 year ago

Your proposal seems like a good backwards compatible solution, I will think about it more, but a PR with this implementation would be welcome.