Skip to content

Keep your digital world clean and protect your laptop from harmful and malware websites.

Notifications You must be signed in to change notification settings

feruzoripov/block-unwanted-hosts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Block Unwanted Hosts

License Build Status

Block Unwanted Hosts is an open-source tool written in Go designed to block unwanted websites by updating the system's hosts file. It fetches a list of blocked websites from various sources and appends them to the hosts file, effectively preventing access to these sites.

More info: https://en.wikipedia.org/wiki/Shock_site

Blocked Websites Sources

Features

  • Fetches and blocks websites from predefined sources.
  • Appends entries to the hosts file - /etc/hosts.
  • Clears the DNS cache to apply changes immediately.

Usage

To block unwanted hosts, import the github.com/feruzoripov/block-unwanted-hosts/internal/app/blocking package in your Go code and call blocking.FetchAndBlockWebsites().

package main

import (
	"log"

	"github.com/feruzoripov/block-unwanted-hosts/internal/app/blocking"
)

func main() {
	err := blocking.FetchAndBlockWebsites()
	if err != nil {
		log.Fatal("Error: ", err)
	}
}

Note: Ensure that you have the necessary permissions to update the hosts file, and you may need to run the tool with administrative privileges (sudo).

Command Line Usage

Prerequisites

  • Go installed
  • git installed

Installation Steps

  1. Clone the repository:

    git clone https://github.com/feruzoripov/block-unwanted-hosts.git
    cd block-unwanted-hosts/cmd
  2. Build:

    go build -o blocking
  3. Run (requires sudo for updating /etc/hosts and clearing DNS cache):

    sudo ./blocking

Supported Operating Systems

Block Unwanted Hosts is designed to run on the following operating systems:

  • macOS
  • Debian-based Linux (e.g., Ubuntu)

Please note that these are the currently supported operating systems. While it may work on other Linux distributions, the tool has been tested and optimized for macOS and Debian-based systems.

If you encounter any issues on a different operating system, feel free to submit an issue or contribute to improve compatibility.

Licence

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

About

Keep your digital world clean and protect your laptop from harmful and malware websites.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages