/chomper

Internet blocker written in Python for the Linux desktop.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Chomper

../assets/chomper_example.gif?raw=true

Chomper is a Python command-line program for use on Linux which can either create blacklists of blocked websites or whitelists of allowed websites for specified periods of time. The program is intended to help people with issues being productive on a computer due to Internet distractions.

Most internet blocking programs operate just by modifying the hosts file. This approach only allows for creating blacklists. Additionally, the hosts file approach does not allow you to block particular URLs - it only allows you to block particular domains.

Chomper instead filters outgoing requests through a transparent proxy, which allows for filtering requests at the URL level. This means you can make nuanced blacklists and whitelists, so that you can block websites without sacrificing your ability to do work.

You can read more about my motivation for developing Chomper here.

Installation

Before beginning installation, you should have git and screen installed. Additionally, it would be good to have pyenv installed and on your PATH. Finally, when installing Chomper, you need to use an account which has admin privileges.

  1. Clone Chomper into some repository, e.g. ~/chomper, and change directories to the repository.
  2. Execute make init into your terminal.
    • When prompted, enter your password.

You’re now ready to use Chomper!

Usage

Chomper is configured through a simple YAML file. The first level defines the names of the rules, and the second level defines whether a rules is a blacklist or whitelist, and the addresses involved in a rule. An example configuration file which I use is found below.

coding:
  - block_type:
      - whitelist
  - addresses:
    - github.com/coleifer/peewee
    - stackoverflow.com
    - unix.stackexchange.com
    - aws.amazon.com
    - upwork.com
    - doc.peewee-orm.com
    - pandas.pydata.org
    - python.org
    - amazonaws.com
nosocial:
  - block_type:
      - blacklist
  - addresses:
      - facebook.com
      - instagram.com
      - twitter.com
      - snapchat.com
allon:
  - block_type:
      - blacklist
  - addresses:
      - abcxyz.com
alloff:
  - block_type:
      - whitelist 
  - addresses:
      - abcdxyz.com

The easiest way to use Chomper is through the chomper shell script in the bin directory. chomper takes two arguments - the rule and the block_length. chomper assumes you are using the YAML file in ./data/rules.yaml. With the above YAML file, ./chomper coding 10 will enact the whitelist for the addresses underneath coding for 10 minutes. If you attempt to use chomper again before the 10 minutes are up, you will be prevented from doing so. The allon/alloff rules are temporary hacks to either allow or blacklist all sites. If you want to be able to use the chomper shell script from any directory, you can add it to your PATH environment variable.

Alternatively, you can use chomper directly through the command-line interface defined in ./chomper/block.py. This is the best entry point for anyone who wants to create their own scripts.

If you enact a block using chomper and change your mind, if you have sudo privileges, you can reset the block with make reset.

Hardcore Mode

If you use Linux and have root privileges, it is impossible to prevent yourself from breaking any sort of Internet block. If you want to use Chomper seriously, I suggest that after installing Chopmer, you do the following:

  1. Create a new account with administrative privileges. Give this account a very long, complicated password. Write down the password, and store it in some secure, but difficult to access location.
  2. While your main account still has root privileges, run make lock from the base directory and enter your password where prompted.
  3. Remove your administrative privileges, log out, and log back in.

You will now be able to use Chomper through chomp as described above, but you will not be able to edit the code, or kill any processes started by Chomper to block websites.

If you want to keep a back-door which allows you to have delayed access to root privileges, I suggest the nifty delayed-admin tool.

Support

You can ask questions and join the development discussion on the Chomper Gitter channel.

Please post bug reports and feature requests (only) in GitHub issues.

License

Chomper is licensed according to the GPLv3. See the COPYING file for more details.

Contributing

Interested in contributing? Awesome! Please read the CONTRIBUTING.org file.

About

Chomper was created and is maintained by Aniket Panjwani. For a full list of contributors, go here.