Git Product home page Git Product logo

website_blocker's Introduction

Website Blocker aka. Hosts File Swapper

This Rust program allows you to swap the /etc/hosts file on your machine with a prepared hosts file. The prepared hosts file can be used to redirect the URLs of popular social media sites to localhost, or to block access to them altogether.

Prerequisites

  • Rust 1.64 or higher

Usage:

  1. Clone this repository:
    git clone https://github.com/kubabialy/website_blocker
    cd website-blocker
  1. Build and run the program:
cargo build --release
  1. Run it with either prepared ./my-hosts file or provide path to one of your choice using -s or --source-file param.
// This one uses default value -> ./my-hosts
sudo target/release/website-blocker
sudo target/release/website-blocker -s path/to/my/file
sudo target/release/website-blocker --source-file path/to/my/file

Note that modifying the /etc/hosts file requires administrative privileges, so you may need to run the program with sudo or as the root user.

In case of need to rollback to previous config this program prepares a backup file with the same name affixed with -backup. So in case of hosts file you should expect hosts-backup file to be in your etc directory.

Example

Here is an example of an /etc/hosts file that redirects the URLs of some popular social media sites to localhost:

127.0.0.1 www.facebook.com
127.0.0.1 www.instagram.com
127.0.0.1 www.twitter.com
127.0.0.1 www.linkedin.com
127.0.0.1 www.pinterest.com
127.0.0.1 www.reddit.com
127.0.0.1 www.youtube.com

Testing

To run the unit tests, use the following command:

cargo test

License

This project is licensed under the MIT License - see the LICENSE file for details.

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.