中文 | English
hosts-go is a command-line tool for fetching and merging hosts files from the internet. It can periodically fetch hosts files from specified URLs and merge them into the local hosts file.
curl https://github.com/hunshcn/hosts-go/releases/latest/download/hosts-go_linux_amd64 -L -o /usr/bin/hosts-go && chmod +x /usr/bin/hosts-go
go install github.com/hunshcn/hosts-go@latest
hosts-go provides the following command-line options:
--url
or-u
: Specify the URLs to fetch hosts files from. Multiple URLs can be specified.--test
or-t
: Only output the merged hosts file content.--content-only
: Only output the fetched hosts file content.--service
or-s
: Install or uninstall hosts-go as a system service.--duration
or-d
: Specify the duration between each fetch of hosts files. The default is 1 hour.--reload-command
:Command to execute after successfully updating the hosts file.
Fetch and merge hosts files:
hosts-go -u https://gitlab.com/ineo6/hosts/-/raw/master/next-hosts
Install hosts-go as a system service:
hosts-go -u https://gitlab.com/ineo6/hosts/-/raw/master/next-hosts -s install
Uninstall hosts-go service:
hosts-go -s uninstall
- Before running the hosts-go command, make sure you have sufficient permissions to read and write the hosts file.
MIT License.