From e5df9dd3ae5498c26eaa24cd2e9fe3ae8264ff7d Mon Sep 17 00:00:00 2001 From: Justin Reichardt Date: Mon, 13 Jun 2022 00:56:43 -0500 Subject: [PATCH] Moved the default cfg to a file This allows for it to be edited in a single location, be able to be copied to the share directory for easy recovery, and later be available at install when packaging --- Makefile | 22 ++++++++++++---------- src/rhosts.go | 16 ---------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 0cf8151..c9beb85 100644 --- a/Makefile +++ b/Makefile @@ -13,20 +13,22 @@ TARBALLNAME=$(TARBALLPREFIX).tar.gz GOBUILDFLAGS= GITOFF=0 -.PHONY: version -version: - echo "package main\nvar version string=\"$(VERSION)\"" > $(PROJROOT)src/version.go +.PHONY: configure +configure: + echo "package main\nvar version string=\"$(VERSION)\"" > $(PROJROOT)src/configure.go + echo 'const CFG = `' >> $(PROJROOT)src/configure.go + cat $(PROJROOT)src/rhosts_default.cfg >> $(PROJROOT)src/configure.go + echo '`' >> $(PROJROOT)src/configure.go .PHONY: build -build: version - if [ ! -d $(PROJROOT)/build ]; then \ +build: configure + if [ ! -d $(PROJROOT)build ]; then \ mkdir -p $(PROJROOT)build/share/rhosts/systemd $(PROJROOT)build/bin \ ;fi - - + cp src/rhosts_default.cfg $(PROJROOT)build/share/rhosts cd $(PROJROOT)src && go build -o $(PROJROOT)build/bin/ $(GOBUILDFLAGS) ./ cp -r $(PROJROOT)src/systemd $(PROJROOT)/build/share/rhosts/ .PHONY: build-win -build-win: version +build-win: configure cd $(PROJROOT)src && GOOS=windows go build -o $(PROJROOT) $(GOBUILDFLAGS) ./ .PHONY: install install: build @@ -67,8 +69,8 @@ clean: if [ -f $(PROJROOT)rhosts.exe ]; then \ rm -r $(PROJROOT)rhosts.exe \ ;fi - if [ -f $(PROJROOT)src/version.go ]; then \ - rm -r $(PROJROOT)src/version.go \ + if [ -f $(PROJROOT)src/configure.go ]; then \ + rm -r $(PROJROOT)src/configure.go \ ;fi if [ -f $(PROJROOT)$(TARBALLNAME) ]; then \ rm $(PROJROOT)$(TARBALLNAME) \ diff --git a/src/rhosts.go b/src/rhosts.go index 144c172..f096612 100644 --- a/src/rhosts.go +++ b/src/rhosts.go @@ -62,22 +62,6 @@ const GPL =` along with this program. If not, see . ` -const CFG =` -# There are 3 types of entries: download, site, and whitelist. Downloads are -# downloaded and stripped of comments and bad entries if possible before being -# added to a list of sites. Whitelisted urls are removed from the list of sites. -# From there all the urls are added to the hosts file for both IPv4 and IPv6. -# You can also add comments by prepending with a '#'. - -# This is a static entry -#site=www.site.xyz -# This is a download entry -#download=w3.site.xyz/location/to/config.txt -# This is a whitelist entry -#whitelist=www.site.xyz - -# A suggested download is: https://github.com/StevenBlack/hosts -#download=https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts` func main() { tmpdir := ""