Hi all! In the spirit of spinning up a journal from the discussions here How do you all come up with ideas / things to tinker with? - #23 by Biky (thanks again everyone by the way), I wanted to start writing up findings about a personal project I’d find very useful: a pomodoro timer, that during the ‘work’ periods, will automatically block certain domains.
Reason / Motivation
I struggle immensely with aimlessly browsing YouTube, Reddit, Twitter, and some random news sites when I want to be focusing on something else. I also have found that using a pomodoro timer helps my brain do a mental shift, even if it is placebo, into doing some useful work. So why not combine the two ideas?
MVP: A CLI tool (that works on Linux) that acts as a pomodoro timer, that during the ‘work’ periods, blocks a given list of domains.
Limitations
-
I have roommates that visit some of the sites I want to block during work periods, and so I cannot perform this blocking on the home network level. Thus, this should be a tool that runs on and only affects the device I am working on.
-
I would like this to work across platforms, not just Linux (though for my first draft, just a Linux solution is fine). Sometimes I’m working on my Windows partition, and my team at work is a Mac shop, so a cross-platform solution would be ideal. However this could limit the approach.
First Steps
- I’m currently messing with adding a few domains manually to /etc/hosts like so:
...
0.0.0.0 www.youtube.com
...
However, this has not worked so far. I’m on Pop OS, so idk if there’s something that is superseding /etc/hosts, but all I know is, I’m either doing something wrong or it isn’t being used as the ‘last step’ for DNS resolution.
Getting this working would work for Linux, and help get a functional PoC working.
-
Explore whether the /etc/hosts approach would work on Mac / Windows (doubtful?). The idea, is that the script would automatically edit /etc/hosts and restart the local network service to make the changes, and then revert the old state of /etc/hosts back either during a short break in the timer, or when the app closes.
-
This all may lead me to needing to write a simple proxy program to block DNS requests on the list of blocked domains, I’d probably do this in Go as that is what I’m familiar with, but I’ve done very little network programming in Go (or at all, really).
Skills I hope to / probably will learn
- Solidify some basic DNS networking knowledge
- Network Programming (in Go, if I have to write a simple proxy as explained above)
- How different OS’s treat /etc/hosts and DNS requests in general.
Final Thoughts
I am open to all feedback, including some potential “This is a bad idea”, as maybe there’s an approach I’m missing out on. I do want to write my own solution though (as opposed to using existing software), as a way of both fixing a problem I have, and learning some new skills.