You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Go to file
Chris Bednarski aa239820f5 Removed debug output 10 years ago
cmd/hostess Renamed main.go to hostess.go so it will have the right name without having to use -o, more idiomatic 10 years ago
.gitignore Fixed gox builds 10 years ago
.travis.yml Added travis ci 10 years ago
LICENSE Initial commit 10 years ago
Makefile Changed to *V commands to switch between ipv4 and ipv6 functionality 10 years ago
README.md Added IPv6 note to readme 10 years ago
commands.go Some preliminary work and a lot of commented code 10 years ago
hostfile.go Some preliminary work and a lot of commented code 10 years ago
hostfile_test.go Some preliminary work and a lot of commented code 10 years ago
hostlist.go Removed debug output 10 years ago
hostlist_test.go Implemented domain sorting and added doc comments to hostlist 10 years ago
hostname.go Added Hostname.Equal() .EqualIp() and .IsValid() 10 years ago
hostname_test.go Some preliminary work and a lot of commented code 10 years ago

README.md

hostess

An idempotent command-line utility for managing your /etc/hosts file.

Usage

hostess add domain ip   # Add or change a hosts entry for this domain pointing to this IP
hostess add -off domain ip  # Add in a disabled state (if it already exists, disable it)
hostess del domain      # Remove a domain from your hosts file
hostess has domain      # exit code 0 or 1 if the domain is in your hostfile
hostess off domain      # Disable a domain (but don't remove it completely)
hostess on domain       # Re-enable a domain that was disabled
hostess ls              # List domains, target ips, and on/off status
hostess fix             # Read your hosts file and show warnings if there are bumps
hostess dump            # Dump your hostfile as json
hostess apply           # Add entries from a json file

Flags

-n   # Dry run. Show what will happen but don't do it; output to stdout
-f   # Forcibly rewrite the hostfile, even if there are errors or conflicts
-4   # Limit operation to ipv4 entries
-6   # Limit operation to ipv6 entries

hostess may mangle your hosts file. In general it will probably look like this, with domains pointing at the same IP grouped together and disabled domains commented out.

127.0.0.1 localhost hostname2 hostname3
127.0.1.1 machine.name
# 10.10.20.30 some.host

IPv4 and IPv6

Your hosts file can contain overlapping entries where the same hostname points to both an IPv4 and IPv6 ip. In this case, hostess commands will apply to both entries. Typically this is not the case and the default behavior is OK. However, if you need to be more granular you can pass -4 or -6 to limit operations to hostnames associated with that type of ip.

Installation

Grab a release or download the code and run make install (building probably requires go 1.4).

Configuration

By default, hostess will read / write to /etc/hosts. You can use the HOSTESS_FILE environment variable to provide an alternate path (for testing).

Disclaimer

hostess uses readme-driven-development and may not actually do any of the things listed above. When in doubt, pass the -n flag to try hostess without changing your system.