Git Product home page Git Product logo

hostsblock's Introduction

hostsblock

Converts AdBlock Plus filter lists to hosts file entries

About

hostsblock finds any domain-only blocking rules in an AdBlock Plus filter list (e.g. of the form ||some.domain.com^ or ||some.domain.com|) and prints them as host file entries for 127.0.0.1 (e.g. 127.0.0.1 some.domain.com).

Standalone ad-blocking hosts files like http://someonewhocares.org/hosts/hosts are good, but since ABP filter lists are far more common and frequently updated, it's nice to have a tool to parse them.

Building

make

Usage

hostsblock file

If the file argument is - or omitted, hostsblock will read from stdin. For example,

curl -s https://www.fanboy.co.nz/r/fanboy-ultimate.txt | hostsblock -

If you had your original hosts file at /etc/hosts~, you could fetch an AdBlock list, read the hosts file entries from it with hostsblock, and concatenate the original hosts file with the ad-blocking entries to create the actual hosts file:

curl -s https://www.fanboy.co.nz/r/fanboy-ultimate.txt |
hostsblock |
cat /etc/hosts~ - > /etc/hosts

hostsblock's People

Contributors

wwalexander avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hostsblock's Issues

Compile error on Linux Subsystem for Windows

$ uname -a
Linux HOSTNAME 4.4.0-17134-Microsoft #471-Microsoft Fri Dec 07 20:04:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
$ make
cc -ansi -O3 -Wpedantic -Werror -o hostsblock hostsblock.c
hostsblock.c: In function ‘main’:
hostsblock.c:131:3: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
   fgets(rule, MAX_DOMAIN_RULE_LENGTH, list);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:6: recipe for target 'hostsblock' failed
make: *** [hostsblock] Error 1

Tool usage

Not sure how to use this tool. I downloaded the hostsblock.exe windows-amd64 release. Launched it and got a blank command prompt. Open hostsblock.exe via windows command prompt, copied and paste hostsblock curl -s https://www.fanboy.co.nz/r/fanboy-ultimate.txt | hostsblock -. all i get back is: usage: hostsblock [filterlist]. Can you please help? Im using Windows 10

Can't seem to get the compiled .exe to work

Greetings from the maintainer of a Norwegian adblock list, who am curious about this conversion tool that you've made.

After spending some time on learning how to get Cygwin to compile an .exe from the source code, the .exe seems to just close itself after ⅒ of a second each time I try to run it. And the hostsblock list command doesn't seem to be found by Cygwin or by Windows' command line either.

I use Windows 10 Fall Creators Edition, and I compiled the .exe from a folder that contained all of this repository's files. So is there something I'm doing wrong, or is there an issue in the code? It's probably the former, I admit, but I'm going to need help with this nevertheless.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.