Your dev tool to manage /etc/hosts like a pro!

Tests GitHub Release Go Report Card License All Contributors Coverage Mentioned in Awesome Go

hostctl

Your dev tool to manage /etc/hosts like a pro!

This tool gives you more control over the use of your hosts file. You can have multiple profiles and switch them on/off as you need.

Why?

It is a tedious task to handle the hosts file by editing manually. With this tool you can automate some aspects to do it cleaner and quick.

Features

  • Manage groups of host names by profile.
  • Enable/disable complete profiles.
  • Add/remove groups of host names.
  • Add profiles directly from a text file that you can add to your git repo or any VCS.
  • Sync a profile with Docker or Docker Compose containers.

Documentation

You can read about how to use this tool here:

Or you can start directly on the Docs homepage.

Sample Usage

sample usage

Installation

Go to release page and download the binary you prefer.

Or read about other installation methods on different systems here

Linux/Mac/Windows and permissions

The tool recognize your system and use the right hosts file, it will use /etc/hosts on Linux/Mac and C:/Windows/System32/Drivers/etc/hosts on Windows.

SUDO/ADMIN: You will need permissions for any action that modify hosts file, add sudo to the commands below when needed. If you are on windows, make sure you run it as administrator.

WARNING: it should work on any system. It's tested on Ubuntu and Windows 10. If you can confirm it works on other system, please let me know here.

Contributing

Be sure to read CONTRIBUTING and CODE_OF_CONDUCT.

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


George Kontridze

๐Ÿ’ป

Pacodes

โš ๏ธ ๐Ÿ’ป

BarbUk

๐Ÿ’ป ๐Ÿค”

Brett Mack

๐Ÿ’ป

Peter Thaleikis

๐Ÿ’ป ๐Ÿ“–

simohamed

๐Ÿค” ๐Ÿ’ป

Fabian Grutschus

๐Ÿค”

This project follows the all-contributors specification. Contributions of any kind welcome!

Author(s)

If you like this tool and think is worth it, you can invite me a coffee:

paypal.me/guumaster ko-fi.com/guumaster

LICENSE

MIT license

Comments
  • Test different installations

    Test different installations

    There is a Github Action workflow that automatically generates packages for different systems. I can only test on Linux and Windows, so I need help to test all options:

    • [x] Linux/Mac/Window binary
    • [x] deb package
    • [x] AUR package
    • [x] scoop
    • [x] Brew tap
    • [x] snap (pending add feature to work properly)

    Please add comments if you have tested it any version of this list. Thanks!

    UPDATE: Finally the snap build is approved to have proper permissions :rocket: !

  • fix aur-publish step

    fix aur-publish step

    Something change on aur publish step and it is broken.

    Check how to fix it. Here are the logs from the latest build: https://github.com/guumaster/hostctl/runs/891503728?check_suite_focus=true

    "
    ---------------- AUR Package version hostctl/1.0.12 ----------------
    # aur.archlinux.org:22 SSH-2.0-OpenSSH_8.3
    ---------------- ssh://[email protected]/hostctl.git ----------------
    Cloning into 'hostctl'...
    Warning: Permanently added the ED25519 host key for IP address '5.9.250.164' to the list of known hosts.
    ------------- BUILDING PKG hostctl ----------------
    ==> Making package: hostctl 1.0.12-2 (Mon 20 Jul 2020 08:15:26 PM UTC)
    ==> Checking runtime dependencies...
    ==> Checking buildtime dependencies...
    ==> Retrieving sources...
      -> Found v1.0.12.tar.gz
    ==> Validating source files with sha256sums...
    
  • brew install guumaster/tap/hostctl  does not work on Apple M1

    brew install guumaster/tap/hostctl does not work on Apple M1

    Error: Invalid formula: /opt/homebrew/Library/Taps/guumaster/homebrew-tap/hostctl.rb formulae require at least a URL Error: Cannot tap guumaster/tap: invalid syntax in tap!

  • Minimal Output

    Minimal Output

    Is your feature request related to a problem? Please describe. I use /etc/hosts to block websites during work and it exceeds 20,000 lines. When listing profiles, it all gets outputted.

    Describe the solution you'd like I would love there to be a minified output flag (through persistent configuration? hostctl config minimal)

    Describe alternatives you've considered outputting to /dev/null, but I want to see enabled/disabled profiles.

  • New features

    New features

    Thinks I'd like to add:

    • [ ] hostctl sync k8s -n namespace -p profile
    • [ ] hostctl sync minikube -p profile
    • [x] hostctl sync docker -p profile
    • [x] hostctl sync docker-compose -f docker-compose.yml -p profile

    Also with a --watch flag to monitor and react to changes

  • Installation via brew

    Installation via brew

    Hi, to remain in line with other projects that provide a brew tap might I suggest creating another repo called homebrew-tap. This would allow you a central point for all your homebrew formulae (I hope you go on to create more projects, this one is great) as well as allowing users to install hostctl as well as subscribe to your tap with a single command brew install guumaster/tap/hostctl. This is the same way goreleaser does it (Gotta love a tool that "eats its own dogfood").

  • Docker integration

    Docker integration

    Any ideas how to integrate this with Docker?

    I need something that recognizes when a container starts and add then a hostname to the hosts file with the ip of the container (maybe the project name from docker-compose). Would be fantastic to automate, so I donโ€™t have to remember all the service names and there port redirections.

  • Unable to handle big profile files

    Unable to handle big profile files

    Describe the bug I have a profile file with 23,000 lines that used to work just fine. With 1.0.0 (and now 1.0.2), hostctl no longer works. hostctl status didn't work. I removed all profiles to start fresh and the big file would not be added --from.

    To Reproduce Steps to reproduce the behavior:

    1. sudo hostctl add nsfw --from https://github.com/smhmd/dotfiles/blob/master/.config/hosts/nsfw -q (there's an idea. Profile files --from URLs.)

    Expected behavior hostctl to load the profile

    System OS: Linux

    Additional context Loading that profile worked in 0.10.x.

  • Wait Flag

    Wait Flag

    Is your feature request related to a problem? Please describe. blocking websites to work, I sometimes need to use a website for a limited amount of time to not sidetrack. Do you think it would be useful to add a time flag?

    Describe the solution you'd like

    $ hostctl enable -p youtube -t 15 # enable youtube profile for 15 minutes
    

    Describe alternatives you've considered

    $ hostcl enable -p youtube && sleep 900 && hostctl disable -p youtube
    
  • Fix error massage typo

    Fix error massage typo

    Error: profile 'awesome' doesn't exists in file has a typo as it should be doesn't exist. But, the error message itself is not that comprehensible.

    Proposal to change it to Error: unknown profile 'awesome'.

  • Preventing comments from getting into entries

    Preventing comments from getting into entries

    Signed-off-by: Pablo Caderno [email protected]

    Fixes issue #72

    I've also removed the spaceRemover and tabReplacer since strings.TrimSpace() should get rid of either of these.

  • installation page not found (404)

    installation page not found (404)

    https://guumaster.github.io/hostctl/docs/getting-started/installation.md is not accessible. Given that hostctl is listed here https://github.com/alexellis/arkade#catalog-of-clis , arkade get hostctl also fails like this:

    Downloading: hostctl
    2022/12/10 12:30:12 Looking up version for hostctl
    2022/12/10 12:30:13 Found: v1.1.3
    Downloading: https://github.com/guumaster/hostctl/releases/download/v1.1.3/hostctl_1.1.3_macOS_.tar.gz
    Error: incorrect status for downloading tool: 404
    
  • Windows 11 profiles are not set

    Windows 11 profiles are not set

    Describe the bug On Windows 11 hostctl do not set or list profiles when use "add/list" command. It seems to be a parsing error in hosts file.

    I use Netmaker on Windows and hostctl sets every few minutes new entries in hosts file. Netmaker gets other peers IP addresses over mqtt and set hosts entries with hostctl

    To Reproduce Steps to reproduce the behavior:

    hostctl.exe add TEST1 -f hosts.txt OR hostctl.exe add domains TEST1 test.loc --ip 10.10.10.10

    hosts (looks correct):

    ##################################################################
    # Content under this line is handled by hostctl. DO NOT EDIT.
    ##################################################################
    
    # profile.on TEST1
    10.10.10.10 test.loc
    # end
    
    

    hostctl.exe list No profile is shown

    +---------+--------+-----------------+-------------------+
    | PROFILE | STATUS |       IP        |      DOMAIN       |  
    +---------+--------+-----------------+-------------------+  
    | default | off    | 102.54.94.97    | rhino.acme.com    |  
    | default | off    | 38.25.63.10     | x.acme.com        |  
    | default | off    | 127.0.0.1       | localhost         |  
    | default | off    | ::1             | localhost         |  
    | default | on     | 10.10.10.10     | test.loc          |  
    +---------+--------+-----------------+-------------------+
    

    hostctl.exe add domains TEST2 test2.loc --ip 10.10.10.11 hosts file seams not correct parsed. Profile name is set. Content-block is set under first profile.

    # profile.on TEST1
    10.10.10.10 test.loc
    
    ##################################################################
    # Content under this line is handled by hostctl. DO NOT EDIT.
    ##################################################################
    
    # profile.on TEST2
    10.10.10.11 test2.loc
    # end
    

    hostctl.exe list No profile

    +---------+--------+---------------+-------------------+
    | PROFILE | STATUS |      IP       |      DOMAIN       |
    +---------+--------+---------------+-------------------+
    | default | off    | 102.54.94.97  | rhino.acme.com    |
    | default | off    | 38.25.63.10   | x.acme.com        |
    | default | off    | 127.0.0.1     | localhost         |
    | default | off    | ::1           | localhost         |
    | default | on     | 10.10.10.10   | test.loc          |
    | default | on     | 10.10.10.11   | test2.loc         |
    +---------+--------+---------------+-------------------+
    

    hostctl do not find profiles

    hostctl.exe disable TEST2
    [ร—] error: unknown profile name
    hostctl.exe disable TEST
    [ร—] error: unknown profile name
    

    Expected behavior Set and list profiles under windows

    System (please complete the following information):

    • OS: Windows
    • Version: 11
  • i really want to use this by yum or dnf.

    i really want to use this by yum or dnf.

    Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

    Describe the solution you'd like A clear and concise description of what you want to happen.

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Additional context Add any other context or screenshots about the feature request here.

    i really want to use this by yum or dnf ( Centos ) may i ask this package manager repo. i wish that. my god~

  • Add the ability to manage entries added from other applications

    Add the ability to manage entries added from other applications

    Is your feature request related to a problem? Please describe. This is a great tool, as the hosts file can be a b**ch to organize! The issue I am having is that I use tools to add entries to the hosts file and (maybe I simply do not understand the tool) would like to somehow manage these entries easily. I use tools like Spybot Anti-Beacon which automatically add entries specifically to the default "hosts" file.

    Describe the solution you'd like Would like to somehow combine files into one hosts file. As stated, maybe I don't fully understand how it works. If I were to divide my hosts file into profiles, then use Anti-Beacon to update its entries, I would like to be able to add all of those new entries to the "Anti-Beacon" profile basically. If this is possible already, then disregard this.

    Describe alternatives you've considered What I've considered, as hostctl (to my knowledge) can target other hosts files easily, is to have several files for each tool and use hostctl to combine these into a "master" hosts file. This is cumbersome as it involves the swapping of hosts files (e.g if I have all Anti-Beacon entries in a 'hosts.beacon' file, when I want to update these entries I have to rename it to "hosts" and then use the tool to update the entries, rename it again to 'hosts.beacon' and use hostctl to import the new entries).

    Additional context The documentation for this tool seems (to me) inadequate as I am not entirely sure how to exactly import entries to the hosts file. I just now found how to add profiles, as the set command is not part of the "CLI Usage" documentation for some reason...

  • Add an UI

    Add an UI

    I'm thinking on adding a simple UI. Maybe some Vue frontend and a web server to perform the updates.

    Or maybe something more like k9s

    Not sure if this should be splitted to a separate binary and keep it separate from core functionality.

omniparser: a native Golang ETL streaming parser and transform library for CSV, JSON, XML, EDI, text, etc.
omniparser: a native Golang ETL streaming parser and transform library for CSV, JSON, XML, EDI, text, etc.

omniparser Omniparser is a native Golang ETL parser that ingests input data of various formats (CSV, txt, fixed length/width, XML, EDI/X12/EDIFACT, JS

Jan 4, 2023
:zap: Transfer files over wifi from your computer to your mobile device by scanning a QR code without leaving the terminal.
:zap: Transfer files over wifi from your computer to your mobile device by scanning a QR code without leaving the terminal.

$ qrcp Transfer files over Wi-Fi from your computer to a mobile device by scanning a QR code without leaving the terminal. You can support development

Dec 28, 2022
A little like that j-thing, only in Go.

goquery - a little like that j-thing, only in Go goquery brings a syntax and a set of features similar to jQuery to the Go language. It is based on Go

Dec 30, 2022
agrep-like fuzzy matching, but made faster using Golang and precomputation.

goagrep There are situations where you want to take the user's input and match a primary key in a database. But, immediately a problem is introduced:

Oct 8, 2022
Mdfmt - A Markdown formatter that follow the CommonMark. Like gofmt, but for Markdown

Introduction A Markdown formatter that follow the CommonMark. Like gofmt, but fo

Dec 18, 2022
Gotabulate - Easily pretty-print your tabular data with Go

Gotabulate - Easily pretty-print tabular data Summary Go-Tabulate - Generic Go Library for easy pretty-printing of tabular data. Installation go get g

Dec 27, 2022
Your CSV pocket-knife (golang)

csvutil - Your CSV pocket-knife (golang) #WARNING I would advise against using this package. It was a language learning exercise from a time before "e

Oct 24, 2022
Simple HCL (HashiCorp Configuration Language) parser for your vars.

HCL to Markdown About To write a good documentation for terraform module, quite often we just need to print all our input variables as a fancy table.

Dec 14, 2021
Preventing 3rd Party DLLs from Injecting into your Malware

Doge-BlockDLLs Preventing 3rd Party DLLs from Injecting into your Malware ACG(Arbitrary Code Guard)็š„ๆ–นๅผ็ญ‰ๅคงไฝฌๆฅๅฎž็Žฐ Ref https://www.ired.team/offensive-secur

Dec 7, 2022
Stylesheet-based markdown rendering for your CLI apps ๐Ÿ’‡๐Ÿปโ€โ™€๏ธ
Stylesheet-based markdown rendering for your CLI apps ๐Ÿ’‡๐Ÿปโ€โ™€๏ธ

Glamour Write handsome command-line tools with Glamour. glamour lets you render markdown documents & templates on ANSI compatible terminals. You can c

Jan 1, 2023
Schedule daily tweets from markdown files in your repo, posted via github actions.

markdown-tweet-scheduler Schedule daily tweets from markdown files in your repo, posted to twitter via github actions. Setup Fork this repo Get your t

Dec 6, 2022
Convert your markdown files to PDF instantly
Convert your markdown files to PDF instantly

Will take a markdown file as input and then create a PDF file with the markdown formatting.

Nov 7, 2022
Colored RSS feeds in your console

RSS Console Feed Read colored rss feeds in your console Usage ./rss-console-feed

Dec 22, 2021
This service will help you detect any waste of resources in your AWS account

Frugal-Hero This service will help you detect any waste of resources in your AWS account. The policy is: if it is not useful, delete it! Requirements

Jan 31, 2022
Go Resume is a resume tailoring tool with super powers ๐Ÿš€

Go Resume is a resume tailoring tool with super powers ?? Building ?? Dependencies Go NodeJS Latex Installation Steps Clone the repo with gi

Jan 13, 2022
PipeIt is a text transformation, conversion, cleansing and extraction tool.
PipeIt is a text transformation, conversion, cleansing and extraction tool.

PipeIt PipeIt is a text transformation, conversion, cleansing and extraction tool. Features Split - split text to text array by given separator. Regex

Aug 15, 2022
A targeted word list generation tool
A targeted word list generation tool

dirtywords Inspired by gau, dirtywords builds targeted wordlists for a given domain using "dirty" knowledge from AlienVault's Open Threat Exchange, th

Dec 3, 2022
Automation Tool to auto generate markdown notes from online classes/talks/presentations.
Automation Tool to auto generate markdown notes from online classes/talks/presentations.

autonotes Automation tool to autocapture screenshots and join them with a supplied .srt or .txt file and output a notes file in markdown. Problem? Wat

Aug 29, 2021
This is a simple text completion/editing/auto-correction tool I created in Go.
This is a simple text completion/editing/auto-correction tool I created in Go.

Auto Text Completion Tool This is a simple text completion/editing/auto-correction tool I created in Go. The tool receives the following arguments: Th

Oct 25, 2022