hblock
hblock copied to clipboard
Syntax for `sources.list` (or alternative files) to add or remove individual sources without duplicating defaults
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:
- if
sources.list
only contains URLs with no prefix thenhblock
will only usesources.list
and not the builtin list - if all lines in
sources.list
have a prefix thenhblock
will parse both the builtin and the contents ofsources.list
- URLs with a
+
prefix will be downloaded in addition to the builtin list - URLs with a
-
prefix will be excluded if found in the builtin list
- URLs with a
- INFO output will be shown if a
+
URL matches something in the builtin list or a-
URL is not in the builtin - WARNING (non-fatal error) output will be shown if a user has put the same URL in
sources.list
with both prefixes (in this case I would suggest honouring the prefix found on the last occurrence for that URL insources.list
, reading from top to bottom) - ERROR (fatal) will be shown to users if
sources.list
contains a mix of URLs with and without prefixes so they can correct things, andhblock
will terminate without updating/etc/hosts
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.
Your proposal seems like a good backwards compatible solution, I will think about it more, but a PR with this implementation would be welcome.