From 3c0d85cdbec890f8a2304d81f51579fb812a4ff0 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Mon, 10 Aug 2020 15:17:44 +0300 Subject: [PATCH 01/10] Make skywire visor look at `/opt/skywire` for apps, config and logs by default --- pkg/skyenv/values.go | 18 ++++++++++++++---- pkg/visor/visorconfig/config.go | 5 +++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/pkg/skyenv/values.go b/pkg/skyenv/values.go index 7d9b748069..a825dfed73 100644 --- a/pkg/skyenv/values.go +++ b/pkg/skyenv/values.go @@ -6,6 +6,12 @@ import ( "github.com/skycoin/dmsg/cipher" ) +// Constants for skywire root directories. +const ( + DefaultSkywirePath = "/opt/skywire" + TestSkywirePath = "." +) + // Constants for default services. const ( DefaultTpDiscAddr = "http://transport.discovery.skywire.skycoin.com" @@ -43,7 +49,8 @@ const ( DefaultDmsgPtyCLINet = "unix" DefaultDmsgPtyCLIAddr = "/tmp/dmsgpty.sock" - DefaultDmsgPtyWhitelist = "./dmsgpty/whitelist.json" + DefaultDmsgPtyWhitelist = DefaultSkywirePath + "/dmsgpty/whitelist.json" + TestDmsgPtyWhiteList = TestSkywirePath + "/dmsgpty/whitelist.json" ) // Default STCP constants. @@ -84,14 +91,17 @@ const ( const ( DefaultAppSrvAddr = "localhost:5505" AppDiscUpdateInterval = 30 * time.Second - DefaultAppLocalPath = "./local" - DefaultAppBinPath = "./apps" + DefaultAppLocalPath = DefaultSkywirePath + "/local" + TestAppLocalPath = TestSkywirePath + "/local" + TestAppBinPath = TestSkywirePath + "/apps" + DefaultAppBinPath = DefaultSkywirePath + "/apps" DefaultLogLevel = "info" ) // Default routing constants const ( - DefaultTpLogStore = "./transport_logs" + DefaultTpLogStore = DefaultSkywirePath + "/transport_logs" + TestTpLogStore = TestSkywirePath + "/transport_logs" ) // MustPK unmarshals string PK to cipher.PubKey. It panics if unmarshaling fails. diff --git a/pkg/visor/visorconfig/config.go b/pkg/visor/visorconfig/config.go index 92209d736e..b9c1d398b6 100644 --- a/pkg/visor/visorconfig/config.go +++ b/pkg/visor/visorconfig/config.go @@ -144,5 +144,10 @@ func MakeTestConfig(log *logging.MasterLogger, confPath string, sk *cipher.SecKe conf.UptimeTracker.Addr = skyenv.TestUptimeTrackerAddr conf.Launcher.Discovery.ServiceDisc = skyenv.TestServiceDiscAddr + conf.Dmsgpty.AuthFile = skyenv.TestDmsgPtyWhiteList + conf.Transport.LogStore.Location = skyenv.TestTpLogStore + conf.Launcher.LocalPath = skyenv.TestAppLocalPath + conf.Launcher.BinPath = skyenv.TestAppBinPath + return conf, nil } From 46292aecd015c2a07949664e7262bfae6d4cb320 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Mon, 17 Aug 2020 15:45:20 +0300 Subject: [PATCH 02/10] Adapt some of Makefile targets to GNU coding standards --- Makefile | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 73ac34f22d..30720a82b2 100644 --- a/Makefile +++ b/Makefile @@ -75,9 +75,39 @@ clean: ## Clean project: remove created binaries and apps -rm -rf ./apps -rm -f ./skywire-visor ./skywire-cli ./setup-node ./hypervisor -install: ## Install `skywire-visor`, `skywire-cli`, `setup-node`, `hypervisor` +all: bin host-apps + +install: all ## Install `skywire-visor`, `skywire-cli`, `setup-node`, `hypervisor` + mkdir -p $(DESTDIR)/opt/skywire/apps + mkdir -p $(DESTDIR)/usr/bin + install -m 0755 skywire-visor $(DESTDIR)/opt/skywire/skywire-visor + install -m 0755 skywire-cli $(DESTDIR)/opt/skywire/skywire-cli + install -m 0755 apps/skychat $(DESTDIR)/opt/skywire/apps/skychat + install -m 0755 apps/skysocks $(DESTDIR)/opt/skywire/apps/skysocks + install -m 0755 apps/skysocks-client $(DESTDIR)/opt/skywire/apps/skysocks-client + install -m 0755 apps/vpn-server $(DESTDIR)/opt/skywire/apps/vpn-server + install -m 0755 apps/vpn-client $(DESTDIR)/opt/skywire/apps/vpn-client + ln -s /opt/skywire/skywire-visor $(DESTDIR)/usr/bin/skywire-visor + ln -s /opt/skywire/skywire-cli $(DESTDIR)/usr/bin/skywire-cli ${OPTS} go install ${BUILD_OPTS} ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node ./cmd/hypervisor +uninstall: + rm -rf $(DESTDIR)/usr/bin/skywire-visor + rm -rf $(DESTDIR)/usr/bin/skywire-cli + rm -rf $(DESTDIR)/opt/skywire + +clean: + rm -rf ./skywire-visor + rm -rf ./skywire-cli + rm -rf ./setup-node + rm -rf ./hypervisor + rm -rf ./apps + +distclean: clean + rm -rf ./hypervisor-config.json + rm -rf ./skywire-config.json + rm -rf ./transport_logs + rerun: stop ${OPTS} go build -race -o ./skywire-visor ./cmd/skywire-visor -./skywire-cli visor gen-config -o ./skywire.json -r From dac2ab17876b44b6f3afb40c5ab33c57f8123f24 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Mon, 17 Aug 2020 16:56:24 +0300 Subject: [PATCH 03/10] Modify Makefile --- Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 30720a82b2..d130c884c0 100644 --- a/Makefile +++ b/Makefile @@ -75,9 +75,7 @@ clean: ## Clean project: remove created binaries and apps -rm -rf ./apps -rm -f ./skywire-visor ./skywire-cli ./setup-node ./hypervisor -all: bin host-apps - -install: all ## Install `skywire-visor`, `skywire-cli`, `setup-node`, `hypervisor` +install: ## Install `skywire-visor`, `skywire-cli`, `setup-node`, `hypervisor` mkdir -p $(DESTDIR)/opt/skywire/apps mkdir -p $(DESTDIR)/usr/bin install -m 0755 skywire-visor $(DESTDIR)/opt/skywire/skywire-visor From 8a1b0c215a1d43d533d1be0c96d65f99d7a7d6c0 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Mon, 17 Aug 2020 16:58:59 +0300 Subject: [PATCH 04/10] Temporarily comment out `build` target --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d130c884c0..b41cb76b9a 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ BUILD_OPTS?=$(BUILDINFO) check: lint test ## Run linters and tests -build: dep host-apps bin ## Install dependencies, build apps and binaries. `go build` with ${OPTS} +#build: dep host-apps bin ## Install dependencies, build apps and binaries. `go build` with ${OPTS} run: stop build config ## Run skywire-visor on host ./skywire-visor skywire.json From 8b2c0631e952f6d5be1dc10b5c4c38a31068e2b9 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Mon, 17 Aug 2020 17:02:05 +0300 Subject: [PATCH 05/10] Remove more Makefile targets --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index b41cb76b9a..1bb8efe2e3 100644 --- a/Makefile +++ b/Makefile @@ -130,14 +130,14 @@ vendorcheck: ## Run vendorcheck GO111MODULE=off vendorcheck ./cmd/skywire-cli/... GO111MODULE=off vendorcheck ./cmd/skywire-visor/... -test: ## Run tests - -go clean -testcache &>/dev/null - ${OPTS} go test ${TEST_OPTS} ./internal/... - ${OPTS} go test ${TEST_OPTS} ./pkg/... - -test-no-ci: ## Run no_ci tests - -go clean -testcache - ${OPTS} go test ${TEST_OPTS_NOCI} ./pkg/transport/... -run "TCP|PubKeyTable" +#test: ## Run tests +# -go clean -testcache &>/dev/null +# ${OPTS} go test ${TEST_OPTS} ./internal/... +# ${OPTS} go test ${TEST_OPTS} ./pkg/... + +#test-no-ci: ## Run no_ci tests +# -go clean -testcache +# ${OPTS} go test ${TEST_OPTS_NOCI} ./pkg/transport/... -run "TCP|PubKeyTable" install-linters: ## Install linters - VERSION=latest ./ci_scripts/install-golangci-lint.sh From 800c429792111ab7858170ecbf31197a4ee6f4a1 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Mon, 17 Aug 2020 17:11:48 +0300 Subject: [PATCH 06/10] Remove duplicate `clean` target --- Makefile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Makefile b/Makefile index 1bb8efe2e3..1a1ce36cac 100644 --- a/Makefile +++ b/Makefile @@ -94,13 +94,6 @@ uninstall: rm -rf $(DESTDIR)/usr/bin/skywire-cli rm -rf $(DESTDIR)/opt/skywire -clean: - rm -rf ./skywire-visor - rm -rf ./skywire-cli - rm -rf ./setup-node - rm -rf ./hypervisor - rm -rf ./apps - distclean: clean rm -rf ./hypervisor-config.json rm -rf ./skywire-config.json From ef88e07116be6a4b3b25d1cf9c575ae8a4b28e3b Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Mon, 17 Aug 2020 17:15:13 +0300 Subject: [PATCH 07/10] Add dummy all target --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 1a1ce36cac..c6f3ff3e68 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,9 @@ BUILDINFO?=-ldflags="$(BUILDINFO_VERSION) $(BUILDINFO_DATE) $(BUILDINFO_COMMIT)" BUILD_OPTS?=$(BUILDINFO) +all: + echo "dummy" + check: lint test ## Run linters and tests #build: dep host-apps bin ## Install dependencies, build apps and binaries. `go build` with ${OPTS} From 0fd5ee2679e1cc199e1b62ee7205dd98e6a1c886 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Mon, 17 Aug 2020 17:18:32 +0300 Subject: [PATCH 08/10] Comment out more targets --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c6f3ff3e68..1c9ec0fb9c 100644 --- a/Makefile +++ b/Makefile @@ -27,11 +27,11 @@ DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker con TEST_OPTS_BASE:=-cover -timeout=5m -mod=vendor RACE_FLAG:=-race -GOARCH:=$(shell go env GOARCH) +#GOARCH:=$(shell go env GOARCH) -ifneq (,$(findstring 64,$(GOARCH))) - TEST_OPTS_BASE:=$(TEST_OPTS_BASE) $(RACE_FLAG) -endif +#ifneq (,$(findstring 64,$(GOARCH))) +# TEST_OPTS_BASE:=$(TEST_OPTS_BASE) $(RACE_FLAG) +#endif TEST_OPTS_NOCI:=-$(TEST_OPTS_BASE) -v TEST_OPTS:=$(TEST_OPTS_BASE) -tags no_ci From 72c381c965a25a75a97af3e3e7067361550db52c Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Tue, 18 Aug 2020 18:04:39 +0300 Subject: [PATCH 09/10] Make visor look at `/opt/skywire/` for config --- cmd/skywire-visor/commands/root.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index 5b1a6f0d78..269cd2429b 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -201,7 +201,7 @@ func initConfig(mLog *logging.MasterLogger, args []string, confPath string) *vis } if confPath == "" { - confPath = defaultConfigName + confPath = "/opt/skywire/" + defaultConfigName } fallthrough From 1c1313648a8688c1ffd4df29b5725127fb240812 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Tue, 18 Aug 2020 18:46:12 +0300 Subject: [PATCH 10/10] Revert Makefile changes --- Makefile | 48 ++++++++++++------------------------------------ 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/Makefile b/Makefile index 1c9ec0fb9c..73ac34f22d 100644 --- a/Makefile +++ b/Makefile @@ -27,11 +27,11 @@ DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker con TEST_OPTS_BASE:=-cover -timeout=5m -mod=vendor RACE_FLAG:=-race -#GOARCH:=$(shell go env GOARCH) +GOARCH:=$(shell go env GOARCH) -#ifneq (,$(findstring 64,$(GOARCH))) -# TEST_OPTS_BASE:=$(TEST_OPTS_BASE) $(RACE_FLAG) -#endif +ifneq (,$(findstring 64,$(GOARCH))) + TEST_OPTS_BASE:=$(TEST_OPTS_BASE) $(RACE_FLAG) +endif TEST_OPTS_NOCI:=-$(TEST_OPTS_BASE) -v TEST_OPTS:=$(TEST_OPTS_BASE) -tags no_ci @@ -46,12 +46,9 @@ BUILDINFO?=-ldflags="$(BUILDINFO_VERSION) $(BUILDINFO_DATE) $(BUILDINFO_COMMIT)" BUILD_OPTS?=$(BUILDINFO) -all: - echo "dummy" - check: lint test ## Run linters and tests -#build: dep host-apps bin ## Install dependencies, build apps and binaries. `go build` with ${OPTS} +build: dep host-apps bin ## Install dependencies, build apps and binaries. `go build` with ${OPTS} run: stop build config ## Run skywire-visor on host ./skywire-visor skywire.json @@ -79,29 +76,8 @@ clean: ## Clean project: remove created binaries and apps -rm -f ./skywire-visor ./skywire-cli ./setup-node ./hypervisor install: ## Install `skywire-visor`, `skywire-cli`, `setup-node`, `hypervisor` - mkdir -p $(DESTDIR)/opt/skywire/apps - mkdir -p $(DESTDIR)/usr/bin - install -m 0755 skywire-visor $(DESTDIR)/opt/skywire/skywire-visor - install -m 0755 skywire-cli $(DESTDIR)/opt/skywire/skywire-cli - install -m 0755 apps/skychat $(DESTDIR)/opt/skywire/apps/skychat - install -m 0755 apps/skysocks $(DESTDIR)/opt/skywire/apps/skysocks - install -m 0755 apps/skysocks-client $(DESTDIR)/opt/skywire/apps/skysocks-client - install -m 0755 apps/vpn-server $(DESTDIR)/opt/skywire/apps/vpn-server - install -m 0755 apps/vpn-client $(DESTDIR)/opt/skywire/apps/vpn-client - ln -s /opt/skywire/skywire-visor $(DESTDIR)/usr/bin/skywire-visor - ln -s /opt/skywire/skywire-cli $(DESTDIR)/usr/bin/skywire-cli ${OPTS} go install ${BUILD_OPTS} ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node ./cmd/hypervisor -uninstall: - rm -rf $(DESTDIR)/usr/bin/skywire-visor - rm -rf $(DESTDIR)/usr/bin/skywire-cli - rm -rf $(DESTDIR)/opt/skywire - -distclean: clean - rm -rf ./hypervisor-config.json - rm -rf ./skywire-config.json - rm -rf ./transport_logs - rerun: stop ${OPTS} go build -race -o ./skywire-visor ./cmd/skywire-visor -./skywire-cli visor gen-config -o ./skywire.json -r @@ -126,14 +102,14 @@ vendorcheck: ## Run vendorcheck GO111MODULE=off vendorcheck ./cmd/skywire-cli/... GO111MODULE=off vendorcheck ./cmd/skywire-visor/... -#test: ## Run tests -# -go clean -testcache &>/dev/null -# ${OPTS} go test ${TEST_OPTS} ./internal/... -# ${OPTS} go test ${TEST_OPTS} ./pkg/... +test: ## Run tests + -go clean -testcache &>/dev/null + ${OPTS} go test ${TEST_OPTS} ./internal/... + ${OPTS} go test ${TEST_OPTS} ./pkg/... -#test-no-ci: ## Run no_ci tests -# -go clean -testcache -# ${OPTS} go test ${TEST_OPTS_NOCI} ./pkg/transport/... -run "TCP|PubKeyTable" +test-no-ci: ## Run no_ci tests + -go clean -testcache + ${OPTS} go test ${TEST_OPTS_NOCI} ./pkg/transport/... -run "TCP|PubKeyTable" install-linters: ## Install linters - VERSION=latest ./ci_scripts/install-golangci-lint.sh