Interactive Tool to Deal with /etc/hosts
I block all unwanted sites, including fake news, gambling, porn, and
social media sites, which are sourced from StevenBlack/hosts. However,
occasionally, I need to access a website that has been blocked. To do
this, I manually mv the /etc/hosts/ file, access the sites, and
then move it back. To simplify this process, I wrote this tool.
- There are two files:
- A default file containing static data that doesn’t change.
- A “social” file that contains data which might change (i.e., sites that are temporarily allowed or blocked).
- The tool tracks which sites are blocked and which are allowed based
on user input and the
config file. After the process is complete, the data from both files are combined and appended to the destination fileetc/hosts.
- Add a
listsubcommand with flags:--all(boolean): If true, print both added and deleted sites separately. By default, only deleted sites are shown.
- Use
errors.Isto detect and handle permission denied errors more effectively.