Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ultrabenosaurus opened this issue Jul 22, 2023 · 1 comment

Comments

@Ultrabenosaurus
Copy link

Ultrabenosaurus commented Jul 22, 2023

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 then hblock will only use sources.list and not the builtin list
  • if all lines in sources.list have a prefix then hblock will parse both the builtin and the contents of sources.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
  • 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 in sources.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, and hblock 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.

@hectorm
Copy link
Owner

hectorm commented Jul 24, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants