HostsETC

You are here

One of the projects that I'm working on today involves a lot of front-facing microservices. Usually when I'm working on a particular service on my laptop, I'll create an entry in my hosts file so I can access it from a web address. However I've found that a bit cumbersome, having to open VIM when I need to make a change to the file.

To solve that problem, I came up with HostsETC, an Electron based editor for your hosts file. HostsETC provides an easy to use and manipulate UI that lets you make on the fly changes to your hosts file. Check it out on GitHub!


One of the problems I faced using solely Electron was privilages. Your host file is a secured file that requires special permissions to edit. I'm pretty adament about allowing what's essentially an embedded web browser have full admin rights, so I seperated the logic that actually modifies the host file from the GUI editor. The result was an API server that allows for programmatic access to the Host file. When you use the launcher to run HostsETC, it'll launch the API server with escalated privileges to allow it to access your hosts file, then the GUI can connect to the server to allow you to make on-the-fly changes to your hosts file!

I played around with packages such as "sudo-prompt" and "electron-sudo", but they didn't really fit my needs. For one "electron-sudo" doesn't work on Sierra, and "sudo-prompt" makes you jump through quite some hoops to escalate your privileges. Also requesting a users password for every change negates the purpose of the application, to provide a quick way to make changes.