diff --git a/.gitignore b/.gitignore index 423a3ec4eb..702eeda553 100644 --- a/.gitignore +++ b/.gitignore @@ -15,13 +15,15 @@ /skywire/ /local* -pkg/node/apps/ -pkg/node/bar/ -pkg/node/foo/ +pkg/visor/apps/ +pkg/visor/bar/ +pkg/visor/foo/ /node /users.db +/hypervisor /*-node +/*-visor /*-cli /*-server /*.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b009717f2..99e8daa5a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,4 +22,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added -- First release of the mainnet Skywire node and apps for testing. +- First release of the mainnet Skywire visor and apps for testing. diff --git a/Makefile b/Makefile index c23af79f68..c51210df14 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ .PHONY : docker-run docker-stop OPTS?=GO111MODULE=on -DOCKER_IMAGE?=skywire-runner # docker image to use for running skywire-node.`golang`, `buildpack-deps:stretch-scm` is OK too +DOCKER_IMAGE?=skywire-runner # docker image to use for running skywire-visor.`golang`, `buildpack-deps:stretch-scm` is OK too DOCKER_NETWORK?=SKYNET DOCKER_NODE?=SKY01 DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker container @@ -19,27 +19,27 @@ check: lint test ## Run linters and tests build: dep host-apps bin ## Install dependencies, build apps and binaries. `go build` with ${OPTS} -run: stop build config ## Run skywire-node on host - ./skywire-node skywire.json +run: stop build config ## Run skywire-visor on host + ./skywire-visor skywire.json -stop: ## Stop running skywire-node on host - -bash -c "kill $$(ps aux |grep '[s]kywire-node' |awk '{print $$2}')" +stop: ## Stop running skywire-visor on host + -bash -c "kill $$(ps aux |grep '[s]kywire-visor' |awk '{print $$2}')" config: ## Generate skywire.json -./skywire-cli node gen-config -o ./skywire.json -r clean: ## Clean project: remove created binaries and apps -rm -rf ./apps - -rm -f ./skywire-node ./skywire-cli ./setup-node ./manager-node ./SSH-cli + -rm -f ./skywire-visor ./skywire-cli ./setup-node ./hypervisor ./SSH-cli -install: ## Install `skywire-node`, `skywire-cli`, `manager-node`, `SSH-cli` - ${OPTS} go install ./cmd/skywire-node ./cmd/skywire-cli ./cmd/setup-node ./cmd/manager-node ./cmd/therealssh-cli +install: ## Install `skywire-visor`, `skywire-cli`, `hypervisor`, `SSH-cli` + ${OPTS} go install ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node ./cmd/hypervisor ./cmd/therealssh-cli rerun: stop - ${OPTS} go build -race -o ./skywire-node ./cmd/skywire-node + ${OPTS} go build -race -o ./skywire-visor ./cmd/skywire-visor -./skywire-cli node gen-config -o ./skywire.json -r perl -pi -e 's/localhost//g' ./skywire.json - ./skywire-node skywire.json + ./skywire-visor skywire.json lint: ## Run linters. Use make install-linters first @@ -51,10 +51,10 @@ vendorcheck: ## Run vendorcheck GO111MODULE=off vendorcheck ./internal/... GO111MODULE=off vendorcheck ./pkg/... GO111MODULE=off vendorcheck ./cmd/apps/... - GO111MODULE=off vendorcheck ./cmd/manager-node/... + GO111MODULE=off vendorcheck ./cmd/hypervisor/... GO111MODULE=off vendorcheck ./cmd/setup-node/... GO111MODULE=off vendorcheck ./cmd/skywire-cli/... - GO111MODULE=off vendorcheck ./cmd/skywire-node/... + GO111MODULE=off vendorcheck ./cmd/skywire-visor/... # vendorcheck fails on ./cmd/therealssh-cli # the problem is indirect dependency to github.com/sirupsen/logrus #GO111MODULE=off vendorcheck ./cmd/therealssh-cli/... @@ -90,40 +90,40 @@ host-apps: ## Build app ${OPTS} go build ${BUILD_OPTS} -o ./apps/SSH-client.v1.0 ./cmd/apps/therealssh-client # Bin -bin: ## Build `skywire-node`, `skywire-cli`, `manager-node`, `SSH-cli` - ${OPTS} go build ${BUILD_OPTS} -o ./skywire-node ./cmd/skywire-node - ${OPTS} go build ${BUILD_OPTS} -o ./skywire-cli ./cmd/skywire-cli +bin: ## Build `skywire-visor`, `skywire-cli`, `hypervisor`, `SSH-cli` + ${OPTS} go build ${BUILD_OPTS} -o ./skywire-visor ./cmd/skywire-visor + ${OPTS} go build ${BUILD_OPTS} -o ./skywire-cli ./cmd/skywire-cli ${OPTS} go build ${BUILD_OPTS} -o ./setup-node ./cmd/setup-node ${OPTS} go build ${BUILD_OPTS} -o ./messaging-server ./cmd/messaging-server - ${OPTS} go build ${BUILD_OPTS} -o ./manager-node ./cmd/manager-node + ${OPTS} go build ${BUILD_OPTS} -o ./hypervisor ./cmd/hypervisor ${OPTS} go build ${BUILD_OPTS} -o ./SSH-cli ./cmd/therealssh-cli -release: ## Build skywire-node`, skywire-cli, manager-node, SSH-cli and apps without -race flag - ${OPTS} go build -o ./skywire-node ./cmd/skywire-node - ${OPTS} go build -o ./skywire-cli ./cmd/skywire-cli +release: ## Build `skywire-visor`, `skywire-cli`, `hypervisor`, `SSH-cli` and apps without -race flag + ${OPTS} go build -o ./skywire-visor ./cmd/skywire-visor + ${OPTS} go build -o ./skywire-cli ./cmd/skywire-cli ${OPTS} go build -o ./setup-node ./cmd/setup-node - ${OPTS} go build -o ./manager-node ./cmd/manager-node + ${OPTS} go build -o ./hypervisor ./cmd/hypervisor ${OPTS} go build -o ./SSH-cli ./cmd/therealssh-cli - ${OPTS} go build -o ./apps/skychat.v1.0 ./cmd/apps/skychat + ${OPTS} go build -o ./apps/skychat.v1.0 ./cmd/apps/skychat ${OPTS} go build -o ./apps/helloworld.v1.0 ./cmd/apps/helloworld ${OPTS} go build -o ./apps/socksproxy.v1.0 ./cmd/apps/therealproxy ${OPTS} go build -o ./apps/socksproxy-client.v1.0 ./cmd/apps/therealproxy-client ${OPTS} go build -o ./apps/SSH.v1.0 ./cmd/apps/therealssh ${OPTS} go build -o ./apps/SSH-client.v1.0 ./cmd/apps/therealssh-client -# Dockerized skywire-node +# Dockerized skywire-visor docker-image: ## Build docker image `skywire-runner` docker image build --tag=skywire-runner --rm - < skywire-runner.Dockerfile docker-clean: ## Clean docker system: remove container ${DOCKER_NODE} and network ${DOCKER_NETWORK} -docker network rm ${DOCKER_NETWORK} - -docker container rm --force ${DOCKER_NODE} + -docker container rm --force ${DOCKER_NODE} docker-network: ## Create docker network ${DOCKER_NETWORK} -docker network create ${DOCKER_NETWORK} -docker-apps: ## Build apps binaries for dockerized skywire-node. `go build` with ${DOCKER_OPTS} +docker-apps: ## Build apps binaries for dockerized skywire-visor. `go build` with ${DOCKER_OPTS} -${DOCKER_OPTS} go build -race -o ./node/apps/skychat.v1.0 ./cmd/apps/skychat -${DOCKER_OPTS} go build -race -o ./node/apps/helloworld.v1.0 ./cmd/apps/helloworld -${DOCKER_OPTS} go build -race -o ./node/apps/socksproxy.v1.0 ./cmd/apps/therealproxy @@ -131,17 +131,17 @@ docker-apps: ## Build apps binaries for dockerized skywire-node. `go build` with -${DOCKER_OPTS} go build -race -o ./node/apps/SSH.v1.0 ./cmd/apps/therealssh -${DOCKER_OPTS} go build -race -o ./node/apps/SSH-client.v1.0 ./cmd/apps/therealssh-client -docker-bin: ## Build `skywire-node`, `skywire-cli`, `manager-node`, `therealssh-cli`. `go build` with ${DOCKER_OPTS} - ${DOCKER_OPTS} go build -race -o ./node/skywire-node ./cmd/skywire-node +docker-bin: ## Build `skywire-visor`, `skywire-cli`, `hypervisor`, `therealssh-cli`. `go build` with ${DOCKER_OPTS} + ${DOCKER_OPTS} go build -race -o ./node/skywire-visor ./cmd/skywire-visor -docker-volume: dep docker-apps docker-bin bin ## Prepare docker volume for dockerized skywire-node +docker-volume: dep docker-apps docker-bin bin ## Prepare docker volume for dockerized skywire-visor -${DOCKER_OPTS} go build -o ./docker/skywire-services/setup-node ./cmd/setup-node - -./skywire-cli node gen-config -o ./node/skywire.json -r + -./skywire-cli node gen-config -o ./skywire-visor/skywire.json -r perl -pi -e 's/localhost//g' ./node/skywire.json # To make node accessible from outside with skywire-cli -docker-run: docker-clean docker-image docker-network docker-volume ## Run dockerized skywire-node ${DOCKER_NODE} in image ${DOCKER_IMAGE} with network ${DOCKER_NETWORK} +docker-run: docker-clean docker-image docker-network docker-volume ## Run dockerized skywire-visor ${DOCKER_NODE} in image ${DOCKER_IMAGE} with network ${DOCKER_NETWORK} docker run -it -v $(shell pwd)/node:/sky --network=${DOCKER_NETWORK} \ - --name=${DOCKER_NODE} ${DOCKER_IMAGE} bash -c "cd /sky && ./skywire-node skywire.json" + --name=${DOCKER_NODE} ${DOCKER_IMAGE} bash -c "cd /sky && ./skywire-visor skywire.json" docker-setup-node: ## Runs setup-node in detached state in ${DOCKER_NETWORK} -docker container rm setup-node -f @@ -150,13 +150,13 @@ docker-setup-node: ## Runs setup-node in detached state in ${DOCKER_NETWORK} --hostname=setup-node skywire-services \ bash -c "./setup-node setup-node.json" -docker-stop: ## Stop running dockerized skywire-node ${DOCKER_NODE} +docker-stop: ## Stop running dockerized skywire-visor ${DOCKER_NODE} -docker container stop ${DOCKER_NODE} docker-rerun: docker-stop - -./skywire-cli gen-config -o ./node/skywire.json -r + -./skywire-cli gen-config -o ./node/skywire.json -r perl -pi -e 's/localhost//g' ./node/skywire.json # To make node accessible from outside with skywire-cli - ${DOCKER_OPTS} go build -race -o ./node/skywire-node ./cmd/skywire-node + ${DOCKER_OPTS} go build -race -o ./node/skywire-visor ./cmd/skywire-visor docker container start -i ${DOCKER_NODE} run-syslog: ## Run syslog-ng in docker. Logs are mounted under /tmp/syslog @@ -166,7 +166,7 @@ run-syslog: ## Run syslog-ng in docker. Logs are mounted under /tmp/syslog docker run -d -p 514:514/udp -v /tmp/syslog:/var/log --name syslog-ng balabit/syslog-ng:latest -integration-startup: ## Starts up the required transports between 'skywire-node's of interactive testing environment +integration-startup: ## Starts up the required transports between `skywire-visor`s of interactive testing environment ./integration/startup.sh integration-teardown: ## Tears down all saved configs and states of integration executables @@ -192,3 +192,4 @@ mod-uncomm: ## Uncomments the 'replace' rule in go.mod help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + diff --git a/README.md b/README.md index 708180179d..95ff4c12f2 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ - [Build and run](#build-and-run) - [Requirements](#requirements) - [Build](#build) - - [Run `skywire-node`](#run-skywire-node) - - [Run `skywire-node` in docker container](#run-skywire-node-in-docker-container) + - [Run `skywire-visor`](#run-skywire-visor) + - [Run `skywire-visor` in docker container](#run-skywire-visor-in-docker-container) - [Run `skywire-cli`](#run-skywire-cli) - [Apps](#apps) - [Transports](#transports) @@ -22,7 +22,7 @@ - [$SYSLOG_OPTS](#syslog_opts) - [Updater](#updater) - [Running skywire in docker containers](#running-skywire-in-docker-containers) - - [Run dockerized `skywire-node`](#run-dockerized-skywire-node) + - [Run dockerized `skywire-visor`](#run-dockerized-skywire-visor) - [Structure of `./node`](#structure-of-node) - [Refresh and restart `SKY01`](#refresh-and-restart-sky01) - [Customization of dockers](#customization-of-dockers) @@ -30,11 +30,11 @@ - [2. DOCKER_NETWORK](#2-docker_network) - [3. DOCKER_NODE](#3-docker_node) - [4. DOCKER_OPTS](#4-docker_opts) - - [Dockerized `skywire-node` recipes](#dockerized-skywire-node-recipes) + - [Dockerized `skywire-visor` recipes](#dockerized-skywire-visor-recipes) - [1. Get Public Key of docker-node](#1-get-public-key-of-docker-node) - [2. Get an IP of node](#2-get-an-ip-of-node) - [3. Open in browser containerized `skychat` application](#3-open-in-browser-containerized-skychat-application) - - [4. Create new dockerized `skywire-nodes`](#4-create-new-dockerized-skywire-nodes) + - [4. Create new dockerized `skywire-visors`](#4-create-new-dockerized-skywire-visors) - [5. Env-vars for develoment-/testing- purposes](#5-env-vars-for-develoment-testing--purposes) - [6. "Hello-Mike-Hello-Joe" test](#6-hello-mike-hello-joe-test) @@ -48,15 +48,15 @@ The software is still under heavy development and the current version is intende Skywire is a decentralized and private network. Skywire separates the data and control plane of the network and assigns the tasks of network coordination and administration to dedicated services, while the nodes follow the rules that were created by the control plane and execute them. -The core of Skywire is the Skywire node which hosts applications and is the gateway to use the network. It establishes connections, called transports, to other nodes, requests the setup of routes and forwards packets for other nodes on a route. The Skywire node exposes an API to applications for using the networking protocol of Skywire. +The core of Skywire is the Skywire visor which hosts applications and is the gateway to use the network. It establishes connections, called transports, to other nodes, requests the setup of routes and forwards packets for other nodes on a route. The Skywire visor exposes an API to applications for using the networking protocol of Skywire. In order to detach control plane tasks from the network nodes, there are 3 other services that maintain a picture of the network topology, calculate routes (currently based on the number of hops, but will be extended to other metrics) and set the routing rules on the nodes. -The transport discovery maintains a picture of the network topology, by allowing Skywire nodes to advertise transports that they established with other nodes. It also allows to upload a status to indicate whether a given transport is currently working or not. +The transport discovery maintains a picture of the network topology, by allowing Skywire visors to advertise transports that they established with other nodes. It also allows to upload a status to indicate whether a given transport is currently working or not. On the basis of this information the route finder calculates the most efficient route in the network. Nodes request a route to a given public key and the route finder will calculate the best route and return the transports that the packet will be sent over to reach the intended node. -This information is sent from a node to the Setup Node, which sets the routing rules in all nodes along a route. Skywire nodes determine, which nodes they accept routing rules from, so only a whitelisted node can send routing rules to a node in the network. The only information the Skywire node gets for routing is a Routing ID and an associated rule that defines which transport to send a packet to (or to consume the packet). Therefore nodes along a route only know the last and next hop along the route, but not where the packet originates from and where it is sent to. Skywire supports source routing, so nodes can specify a path that a packet is supposed to take in the network. +This information is sent from a node to the Setup Node, which sets the routing rules in all nodes along a route. Skywire visors determine, which nodes they accept routing rules from, so only a whitelisted node can send routing rules to a node in the network. The only information the Skywire visor gets for routing is a Routing ID and an associated rule that defines which transport to send a packet to (or to consume the packet). Therefore nodes along a route only know the last and next hop along the route, but not where the packet originates from and where it is sent to. Skywire supports source routing, so nodes can specify a path that a packet is supposed to take in the network. There are currently two types of transports that nodes can use. The messaging transport is a transport between two nodes that uses an intermediary messaging server to relay packets between them. The connection to a specific node and the connection to a messaging server is facilitated by a discovery service, that allows nodes to advertise the messaging servers over which they can be contacted. This transport is used by the setup node to send routing rules and can be used for other applications as well. It allows nodes behind NATs to communicate. The second transport type is TCP, which sets up a connection between two servers with a public IP. More transport types will be supported in the future and custom transport implementations can be written for specific use cases. @@ -90,7 +90,7 @@ $ make $ OPTS="GSO111MODULE=on GOOS=linux GOARCH=arm" make ``` -**Install skywire-node, skywire-cli, manager-node and SSH-cli** +**Install skywire-visor, skywire-cli, hypervisor and SSH-cli** ```bash $ make install # compiles and installs all binaries @@ -102,16 +102,16 @@ $ make install # compiles and installs all binaries $ skywire-cli node gen-config ``` -### Run `skywire-node` +### Run `skywire-visor` -`skywire-node` hosts apps, proxies app's requests to remote nodes and exposes communication API that apps can use to implement communication protocols. App binaries are spawned by the node, communication between node and app is performed via unix pipes provided on app startup. +`skywire-visor` hosts apps, proxies app's requests to remote nodes and exposes communication API that apps can use to implement communication protocols. App binaries are spawned by the node, communication between node and app is performed via unix pipes provided on app startup. ```bash -# Run skywire-node. It takes one argument; the path of a configuration file (`skywire-config.json` if unspecified). -$ skywire-node skywire-config.json +# Run skywire-visor. It takes one argument; the path of a configuration file (`skywire-config.json` if unspecified). +$ skywire-visor skywire-config.json ``` -### Run `skywire-node` in docker container +### Run `skywire-visor` in docker container ```bash make docker-run @@ -119,7 +119,7 @@ make docker-run ### Run `skywire-cli` -The `skywire-cli` tool is used to control the `skywire-node`. Refer to the help menu for usage: +The `skywire-cli` tool is used to control the `skywire-visor`. Refer to the help menu for usage: ```bash $ skywire-cli -h @@ -132,7 +132,7 @@ $ skywire-cli -h # Available Commands: # help Help about any command # mdisc Contains sub-commands that interact with a remote Messaging Discovery -# node Contains sub-commands that interact with the local Skywire (App) Node +# node Contains sub-commands that interact with the local Skywire Visor # rtfind Queries the Route Finder for available routes between two nodes # tpdisc Queries the Transport Discovery to find transport(s) of given transport ID or edge public key # @@ -145,7 +145,7 @@ $ skywire-cli -h ### Apps -After `skywire-node` is up and running with default environment, default apps are run with the configuration specified in `skywire-config.json`. Refer to the following for usage of the default apps: +After `skywire-visor` is up and running with default environment, default apps are run with the configuration specified in `skywire-config.json`. Refer to the following for usage of the default apps: - [Chat](/cmd/apps/skychat) - [Hello World](/cmd/apps/helloworld) @@ -154,7 +154,7 @@ After `skywire-node` is up and running with default environment, default apps ar ### Transports -In order for a local Skywire App to communicate with an App running on a remote Skywire node, a transport to that remote Skywire node needs to be established. +In order for a local Skywire App to communicate with an App running on a remote Skywire visor, a transport to that remote Skywire visor needs to be established. Transports can be established via the `skywire-cli`. @@ -251,9 +251,9 @@ This software comes with an updater, which is located in this repo: ```bash -# Setup: run skywire-nodes on host and in docker +# Setup: run skywire-visors on host and in docker $ make run $ make docker-run # Open in browser skychat application diff --git a/ci_scripts/run-pkg-tests.sh b/ci_scripts/run-pkg-tests.sh index 9603e84409..96d4c88006 100644 --- a/ci_scripts/run-pkg-tests.sh +++ b/ci_scripts/run-pkg-tests.sh @@ -11,16 +11,7 @@ go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/app -run TestProtocol >> ./logs/pkg/TestProtocol.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/app -run TestProtocolParallel >> ./logs/pkg/TestProtocolParallel.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/cipher -run TestPubKeyString >> ./logs/pkg/TestPubKeyString.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/cipher -run TestPubKeyTextMarshaller >> ./logs/pkg/TestPubKeyTextMarshaller.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/cipher -run TestPubKeyBinaryMarshaller >> ./logs/pkg/TestPubKeyBinaryMarshaller.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/cipher -run TestSecKeyString >> ./logs/pkg/TestSecKeyString.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/cipher -run TestSecKeyTextMarshaller >> ./logs/pkg/TestSecKeyTextMarshaller.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/cipher -run TestSecKeyBinaryMarshaller >> ./logs/pkg/TestSecKeyBinaryMarshaller.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/cipher -run TestSigString >> ./logs/pkg/TestSigString.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/cipher -run TestSigTextMarshaller >> ./logs/pkg/TestSigTextMarshaller.log - -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/manager -run TestNewNode >> ./logs/pkg/TestNewNode.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/hypervisor -run TestNewNode >> ./logs/pkg/TestNewNode.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestMessagingDiscovery >> ./logs/pkg/TestMessagingDiscovery.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestTransportDiscovery >> ./logs/pkg/TestTransportDiscovery.log diff --git a/cmd/apps/helloworld/helloworld.go b/cmd/apps/helloworld/helloworld.go index 25205930c9..ab65fdbed3 100644 --- a/cmd/apps/helloworld/helloworld.go +++ b/cmd/apps/helloworld/helloworld.go @@ -1,5 +1,5 @@ /* -simple client server app for skywire node testing +simple client server app for skywire visor testing */ package main diff --git a/cmd/apps/skychat/README.md b/cmd/apps/skychat/README.md index 66aed3b624..374c9241d4 100644 --- a/cmd/apps/skychat/README.md +++ b/cmd/apps/skychat/README.md @@ -1,6 +1,6 @@ # Skywire Chat app -Chat implements basic text messaging between skywire nodes. +Chat implements basic text messaging between skywire visors. Messaging UI is exposed via web interface. @@ -13,6 +13,7 @@ Create 2 node config files: `skywire1.json` ```json +{ "apps": [ { "app": "skychat", @@ -21,11 +22,13 @@ Create 2 node config files: "port": 1 } ] +} ``` `skywire2.json` ```json +{ "apps": [ { "app": "skychat", @@ -35,14 +38,15 @@ Create 2 node config files: "args": ["-addr", ":8001"] } ] +} ``` Compile binaries and start 2 nodes: ```bash $ go build -o apps/skychat.v1.0 ./cmd/apps/skychat -$ ./skywire-node skywire1.json -$ ./skywire-node skywire2.json +$ ./skywire-visor skywire1.json +$ ./skywire-visor skywire2.json ``` Chat interface will be available on ports `8000` and `8001`. diff --git a/cmd/apps/skychat/chat.go b/cmd/apps/skychat/chat.go index ba80c6f18e..8b76bf3423 100644 --- a/cmd/apps/skychat/chat.go +++ b/cmd/apps/skychat/chat.go @@ -1,7 +1,7 @@ //go:generate esc -o static.go -prefix static static /* -skychat app for skywire node +skychat app for skywire visor */ package main diff --git a/cmd/apps/therealproxy-client/therealproxy-client.go b/cmd/apps/therealproxy-client/therealproxy-client.go index 68f8a11863..f1e7c01bd6 100644 --- a/cmd/apps/therealproxy-client/therealproxy-client.go +++ b/cmd/apps/therealproxy-client/therealproxy-client.go @@ -1,5 +1,5 @@ /* -proxy client app for skywire node +proxy client app for skywire visor */ package main diff --git a/cmd/apps/therealproxy/README.md b/cmd/apps/therealproxy/README.md index 5ad2e0bed8..e456c7c146 100644 --- a/cmd/apps/therealproxy/README.md +++ b/cmd/apps/therealproxy/README.md @@ -15,6 +15,7 @@ Create 2 node config files: - `skywire1.json` ```json +{ "apps": [ { "app": "socksproxy", @@ -24,11 +25,13 @@ Create 2 node config files: "args": ["-passcode", "123456"] } ] +} ``` - `skywire2.json` ```json +{ "apps": [ { "app": "socksproxy-client", @@ -38,6 +41,7 @@ Create 2 node config files: "args": ["-srv", "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7"] } ] +} ``` Compile binaries and start 2 nodes: @@ -45,8 +49,8 @@ Compile binaries and start 2 nodes: ```sh $ go build -o apps/socksproxy.v1.0 ./cmd/apps/therealproxy $ go build -o apps/socksproxy-client.v1.0 ./cmd/apps/therealproxy-client -$ ./skywire-node skywire1.json -$ ./skywire-node skywire2.json +$ ./skywire-visor skywire1.json +$ ./skywire-visor skywire2.json ``` You should be able to connect to a secondary node via `curl`: diff --git a/cmd/apps/therealproxy/therealproxy.go b/cmd/apps/therealproxy/therealproxy.go index 34bfdbb415..e053c5badb 100644 --- a/cmd/apps/therealproxy/therealproxy.go +++ b/cmd/apps/therealproxy/therealproxy.go @@ -1,5 +1,5 @@ /* -proxy server app for skywire node +proxy server app for skywire visor */ package main diff --git a/cmd/apps/therealssh-client/therealssh-client.go b/cmd/apps/therealssh-client/therealssh-client.go index b0ab610052..9645cb7ff0 100644 --- a/cmd/apps/therealssh-client/therealssh-client.go +++ b/cmd/apps/therealssh-client/therealssh-client.go @@ -1,5 +1,5 @@ /* -ssh client app for skywire node +ssh client app for skywire visor */ package main diff --git a/cmd/apps/therealssh/README.md b/cmd/apps/therealssh/README.md index fa0c149d41..c61dfb028d 100644 --- a/cmd/apps/therealssh/README.md +++ b/cmd/apps/therealssh/README.md @@ -20,6 +20,7 @@ Create 2 node config files: `skywire1.json` ```json +{ "apps": [ { "app": "SSH", @@ -28,11 +29,13 @@ Create 2 node config files: "port": 2 } ] +} ``` `skywire2.json` ```json +{ "apps": [ { "app": "SSH-client", @@ -41,6 +44,7 @@ Create 2 node config files: "port": 22 } ] +} ``` Compile binaries and start 2 nodes: @@ -49,15 +53,15 @@ Compile binaries and start 2 nodes: $ go build -o apps/SSH.v1.0 ./cmd/apps/therealssh $ go build -o apps/SSH-client.v1.0 ./cmd/apps/therealssh-client $ go build ./cmd/SSH-cli -$ ./skywire-node skywire1.json -$ ./skywire-node skywire2.json +$ ./skywire-visor skywire1.json +$ ./skywire-visor skywire2.json ``` Add public key of the second node to the auth file: ```bash -$ mkdir `/.therealssh -$ echo "0348c941c5015a05c455ff238af2e57fb8f914c399aab604e9abb5b32b91a4c1fe" > `/.SSH/authorized_keys +$ mkdir /.therealssh +$ echo "0348c941c5015a05c455ff238af2e57fb8f914c399aab604e9abb5b32b91a4c1fe" > /.SSH/authorized_keys ``` Connect to the first node using CLI: diff --git a/cmd/apps/therealssh/therealssh.go b/cmd/apps/therealssh/therealssh.go index 69e813baa0..c7aa0f7189 100644 --- a/cmd/apps/therealssh/therealssh.go +++ b/cmd/apps/therealssh/therealssh.go @@ -1,5 +1,5 @@ /* -ssh server app for skywire node +ssh server app for skywire visor */ package main diff --git a/cmd/manager-node/README.md b/cmd/hypervisor/README.md similarity index 57% rename from cmd/manager-node/README.md rename to cmd/hypervisor/README.md index 10af50618d..929f636f3f 100644 --- a/cmd/manager-node/README.md +++ b/cmd/hypervisor/README.md @@ -1,6 +1,6 @@ -# Manager Node +# Hypervisor -Manager node exposes node management operations via web API. +Hypervisor exposes node management operations via web API. **Generate config file:** @@ -12,14 +12,14 @@ Manager node exposes node management operations via web API. ```bash # Generate config file. -$ manager-node gen-config +$ hypervisor gen-config # Run. -$ manager-node --mock +$ hypervisor --mock ``` By default, the RESTful API is served on `:8080`. ## Endpoints Documentation -Endpoints are documented in the provided [Postman](https://www.getpostman.com/) file: `manager-node.postman_collection.json`. +Endpoints are documented in the provided [Postman](https://www.getpostman.com/) file: `hypervisor.postman_collection.json`. diff --git a/cmd/manager-node/commands/gen-config.go b/cmd/hypervisor/commands/gen-config.go similarity index 83% rename from cmd/manager-node/commands/gen-config.go rename to cmd/hypervisor/commands/gen-config.go index 3544e938d4..7ece3102f8 100644 --- a/cmd/manager-node/commands/gen-config.go +++ b/cmd/hypervisor/commands/gen-config.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" - "github.com/skycoin/skywire/pkg/manager" + "github.com/skycoin/skywire/pkg/hypervisor" "github.com/skycoin/skywire/pkg/util/pathutil" ) @@ -28,7 +28,7 @@ var genConfigCmd = &cobra.Command{ Short: "generates a configuration file", PreRun: func(_ *cobra.Command, _ []string) { if output == "" { - output = pathutil.ManagerDefaults().Get(configLocType) + output = pathutil.HypervisorDefaults().Get(configLocType) log.Infof("no 'output,o' flag is empty, using default path: %s", output) } var err error @@ -37,14 +37,14 @@ var genConfigCmd = &cobra.Command{ } }, Run: func(_ *cobra.Command, _ []string) { - var conf manager.Config + var conf hypervisor.Config switch configLocType { case pathutil.WorkingDirLoc: - conf = manager.GenerateWorkDirConfig() + conf = hypervisor.GenerateWorkDirConfig() case pathutil.HomeLoc: - conf = manager.GenerateHomeConfig() + conf = hypervisor.GenerateHomeConfig() case pathutil.LocalLoc: - conf = manager.GenerateLocalConfig() + conf = hypervisor.GenerateLocalConfig() default: log.Fatalln("invalid config type:", configLocType) } diff --git a/cmd/manager-node/commands/root.go b/cmd/hypervisor/commands/root.go similarity index 82% rename from cmd/manager-node/commands/root.go rename to cmd/hypervisor/commands/root.go index b52e6fbb0e..2e77d36837 100644 --- a/cmd/manager-node/commands/root.go +++ b/cmd/hypervisor/commands/root.go @@ -9,14 +9,14 @@ import ( "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" - "github.com/skycoin/skywire/pkg/manager" + "github.com/skycoin/skywire/pkg/hypervisor" "github.com/skycoin/skywire/pkg/util/pathutil" ) -const configEnv = "SW_MANAGER_CONFIG" +const configEnv = "SW_HYPERVISOR_CONFIG" var ( - log = logging.MustGetLogger("manager-node") + log = logging.MustGetLogger("hypervisor") mock bool mockEnableAuth bool @@ -26,7 +26,7 @@ var ( ) func init() { - rootCmd.Flags().BoolVarP(&mock, "mock", "m", false, "whether to run manager node with mock data") + rootCmd.Flags().BoolVarP(&mock, "mock", "m", false, "whether to run hypervisor with mock data") rootCmd.Flags().BoolVar(&mockEnableAuth, "mock-enable-auth", false, "whether to enable user management in mock mode") rootCmd.Flags().IntVar(&mockNodes, "mock-nodes", 5, "number of app nodes to have in mock mode") rootCmd.Flags().IntVar(&mockMaxTps, "mock-max-tps", 10, "max number of transports per mock app node") @@ -34,12 +34,12 @@ func init() { } var rootCmd = &cobra.Command{ - Use: "manager-node [config-path]", + Use: "hypervisor [config-path]", Short: "Manages Skywire App Nodes", Run: func(_ *cobra.Command, args []string) { - configPath := pathutil.FindConfigPath(args, 0, configEnv, pathutil.ManagerDefaults()) + configPath := pathutil.FindConfigPath(args, 0, configEnv, pathutil.HypervisorDefaults()) - var config manager.Config + var config hypervisor.Config config.FillDefaults() if err := config.Parse(configPath); err != nil { log.WithError(err).Fatalln("failed to parse config file") @@ -51,9 +51,9 @@ var rootCmd = &cobra.Command{ rpcAddr = config.Interfaces.RPCAddr ) - m, err := manager.NewNode(config) + m, err := hypervisor.NewNode(config) if err != nil { - log.Fatalln("Failed to start manager:", err) + log.Fatalln("Failed to start hypervisor:", err) } log.Infof("serving RPC on '%s'", rpcAddr) @@ -68,7 +68,7 @@ var rootCmd = &cobra.Command{ }() if mock { - err := m.AddMockData(manager.MockConfig{ + err := m.AddMockData(hypervisor.MockConfig{ Nodes: mockNodes, MaxTpsPerNode: mockMaxTps, MaxRoutesPerNode: mockMaxRoutes, @@ -81,7 +81,7 @@ var rootCmd = &cobra.Command{ log.Infof("serving HTTP on '%s'", httpAddr) if err := http.ListenAndServe(httpAddr, m); err != nil { - log.Fatalln("Manager exited with error:", err) + log.Fatalln("Hypervisor exited with error:", err) } log.Println("Good bye!") diff --git a/cmd/hypervisor/hypervisor.go b/cmd/hypervisor/hypervisor.go new file mode 100644 index 0000000000..b3f5d88d21 --- /dev/null +++ b/cmd/hypervisor/hypervisor.go @@ -0,0 +1,10 @@ +/* +skywire hypervisor +*/ +package main + +import "github.com/skycoin/skywire/cmd/hypervisor/commands" + +func main() { + commands.Execute() +} diff --git a/cmd/manager-node/manager-node.postman_collection.json b/cmd/hypervisor/hypervisor.postman_collection.json similarity index 99% rename from cmd/manager-node/manager-node.postman_collection.json rename to cmd/hypervisor/hypervisor.postman_collection.json index 41c1bbfcce..665b29e9a4 100644 --- a/cmd/manager-node/manager-node.postman_collection.json +++ b/cmd/hypervisor/hypervisor.postman_collection.json @@ -1,7 +1,7 @@ { "info": { "_postman_id": "daa8ec31-db75-4e92-b637-c5117644bfa8", - "name": "Skywire Manager Node", + "name": "Skywire Hypervisor", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ diff --git a/cmd/manager-node/manager-node.go b/cmd/manager-node/manager-node.go deleted file mode 100644 index 2cd0c64cc9..0000000000 --- a/cmd/manager-node/manager-node.go +++ /dev/null @@ -1,10 +0,0 @@ -/* -skywire management node -*/ -package main - -import "github.com/skycoin/skywire/cmd/manager-node/commands" - -func main() { - commands.Execute() -} diff --git a/cmd/skywire-cli/commands/node/app.go b/cmd/skywire-cli/commands/node/app.go index 23d3092341..00f267fd02 100644 --- a/cmd/skywire-cli/commands/node/app.go +++ b/cmd/skywire-cli/commands/node/app.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" "github.com/skycoin/skywire/cmd/skywire-cli/internal" - "github.com/skycoin/skywire/pkg/node" + "github.com/skycoin/skywire/pkg/visor" ) func init() { @@ -34,7 +34,7 @@ var lsAppsCmd = &cobra.Command{ for _, state := range states { status := "stopped" - if state.Status == node.AppStatusRunning { + if state.Status == visor.AppStatusRunning { status = "running" } _, err = fmt.Fprintf(w, "%s\t%s\t%t\t%s\n", state.Name, strconv.Itoa(int(state.Port)), state.AutoStart, status) diff --git a/cmd/skywire-cli/commands/node/gen-config.go b/cmd/skywire-cli/commands/node/gen-config.go index 0f16fe65a4..78b715373b 100644 --- a/cmd/skywire-cli/commands/node/gen-config.go +++ b/cmd/skywire-cli/commands/node/gen-config.go @@ -9,8 +9,8 @@ import ( "github.com/skycoin/dmsg/cipher" "github.com/spf13/cobra" - "github.com/skycoin/skywire/pkg/node" "github.com/skycoin/skywire/pkg/util/pathutil" + "github.com/skycoin/skywire/pkg/visor" ) func init() { @@ -43,7 +43,7 @@ var genConfigCmd = &cobra.Command{ } }, Run: func(_ *cobra.Command, _ []string) { - var conf *node.Config + var conf *visor.Config switch configLocType { case pathutil.WorkingDirLoc: conf = defaultConfig() @@ -58,7 +58,7 @@ var genConfigCmd = &cobra.Command{ }, } -func homeConfig() *node.Config { +func homeConfig() *visor.Config { c := defaultConfig() c.AppsPath = filepath.Join(pathutil.HomeDir(), ".skycoin/skywire/apps") c.Transport.LogStore.Location = filepath.Join(pathutil.HomeDir(), ".skycoin/skywire/transport_logs") @@ -66,7 +66,7 @@ func homeConfig() *node.Config { return c } -func localConfig() *node.Config { +func localConfig() *visor.Config { c := defaultConfig() c.AppsPath = "/usr/local/skycoin/skywire/apps" c.Transport.LogStore.Location = "/usr/local/skycoin/skywire/transport_logs" @@ -74,8 +74,8 @@ func localConfig() *node.Config { return c } -func defaultConfig() *node.Config { - conf := &node.Config{} +func defaultConfig() *visor.Config { + conf := &visor.Config{} conf.Version = "1.0" pk, sk := cipher.GenerateKeyPair() @@ -86,7 +86,7 @@ func defaultConfig() *node.Config { conf.Messaging.ServerCount = 1 passcode := base64.StdEncoding.EncodeToString(cipher.RandByte(8)) - conf.Apps = []node.AppConfig{ + conf.Apps = []visor.AppConfig{ {App: "skychat", Version: "1.0", Port: 1, AutoStart: true, Args: []string{}}, {App: "SSH", Version: "1.0", Port: 2, AutoStart: true, Args: []string{}}, {App: "socksproxy", Version: "1.0", Port: 3, AutoStart: true, Args: []string{"-passcode", passcode}}, @@ -103,16 +103,16 @@ func defaultConfig() *node.Config { conf.Routing.SetupNodes = []cipher.PubKey{sPK} conf.Routing.Table.Type = "boltdb" conf.Routing.Table.Location = "./skywire/routing.db" - conf.Routing.RouteFinderTimeout = node.Duration(10 * time.Second) + conf.Routing.RouteFinderTimeout = visor.Duration(10 * time.Second) - conf.ManagerNodes = []node.ManagerConfig{} + conf.Hypervisors = []visor.HypervisorConfig{} conf.AppsPath = "./apps" conf.LocalPath = "./local" conf.LogLevel = "info" - conf.ShutdownTimeout = node.Duration(10 * time.Second) + conf.ShutdownTimeout = visor.Duration(10 * time.Second) conf.Interfaces.RPCAddress = "localhost:3435" diff --git a/cmd/skywire-cli/commands/node/root.go b/cmd/skywire-cli/commands/node/root.go index f6fbf18bf8..75d29467a5 100644 --- a/cmd/skywire-cli/commands/node/root.go +++ b/cmd/skywire-cli/commands/node/root.go @@ -6,7 +6,7 @@ import ( "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" - "github.com/skycoin/skywire/pkg/node" + "github.com/skycoin/skywire/pkg/visor" ) var log = logging.MustGetLogger("skywire-cli") @@ -17,16 +17,16 @@ func init() { RootCmd.PersistentFlags().StringVarP(&rpcAddr, "rpc", "", "localhost:3435", "RPC server address") } -// RootCmd contains commands that interact with the skywire-node +// RootCmd contains commands that interact with the skywire-visor var RootCmd = &cobra.Command{ Use: "node", - Short: "Contains sub-commands that interact with the local Skywire (App) Node", + Short: "Contains sub-commands that interact with the local Skywire Visor", } -func rpcClient() node.RPCClient { +func rpcClient() visor.RPCClient { client, err := rpc.Dial("tcp", rpcAddr) if err != nil { log.Fatal("RPC connection failed:", err) } - return node.NewRPCClient(client, node.RPCPrefix) + return visor.NewRPCClient(client, visor.RPCPrefix) } diff --git a/cmd/skywire-cli/commands/node/routes.go b/cmd/skywire-cli/commands/node/routes.go index b80c3ab49c..995bbf622c 100644 --- a/cmd/skywire-cli/commands/node/routes.go +++ b/cmd/skywire-cli/commands/node/routes.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/cobra" "github.com/skycoin/skywire/cmd/skywire-cli/internal" - "github.com/skycoin/skywire/pkg/node" "github.com/skycoin/skywire/pkg/router" "github.com/skycoin/skywire/pkg/routing" + "github.com/skycoin/skywire/pkg/visor" ) func init() { @@ -48,7 +48,7 @@ var ruleCmd = &cobra.Command{ rule, err := rpcClient().RoutingRule(routing.RouteID(id)) internal.Catch(err) - printRoutingRules(&node.RoutingEntry{Key: rule.RouteID(), Value: rule}) + printRoutingRules(&visor.RoutingEntry{Key: rule.RouteID(), Value: rule}) }, } @@ -114,7 +114,7 @@ var addRuleCmd = &cobra.Command{ }, } -func printRoutingRules(rules ...*node.RoutingEntry) { +func printRoutingRules(rules ...*visor.RoutingEntry) { printAppRule := func(w io.Writer, id routing.RouteID, s *routing.RuleSummary) { _, err := fmt.Fprintf(w, "%d\t%s\t%d\t%d\t%s\t%d\t%s\t%s\t%s\n", id, s.Type, s.AppFields.LocalPort, s.AppFields.RemotePort, s.AppFields.RemotePK, s.AppFields.RespRID, "-", "-", s.ExpireAt) diff --git a/cmd/skywire-cli/commands/node/transports.go b/cmd/skywire-cli/commands/node/transports.go index d0a111dcc0..43b198ba80 100644 --- a/cmd/skywire-cli/commands/node/transports.go +++ b/cmd/skywire-cli/commands/node/transports.go @@ -12,7 +12,7 @@ import ( "github.com/spf13/cobra" "github.com/skycoin/skywire/cmd/skywire-cli/internal" - "github.com/skycoin/skywire/pkg/node" + "github.com/skycoin/skywire/pkg/visor" ) func init() { @@ -106,7 +106,7 @@ var rmTpCmd = &cobra.Command{ }, } -func printTransports(tps ...*node.TransportSummary) { +func printTransports(tps ...*visor.TransportSummary) { sortTransports(tps...) w := tabwriter.NewWriter(os.Stdout, 0, 0, 5, ' ', tabwriter.TabIndent) _, err := fmt.Fprintln(w, "type\tid\tremote\tmode") @@ -123,7 +123,7 @@ func printTransports(tps ...*node.TransportSummary) { internal.Catch(w.Flush()) } -func sortTransports(tps ...*node.TransportSummary) { +func sortTransports(tps ...*visor.TransportSummary) { sort.Slice(tps, func(i, j int) bool { return tps[i].ID.String() < tps[j].ID.String() }) diff --git a/cmd/skywire-cli/skywire-cli.go b/cmd/skywire-cli/skywire-cli.go index f5be516a27..0d2da60dec 100644 --- a/cmd/skywire-cli/skywire-cli.go +++ b/cmd/skywire-cli/skywire-cli.go @@ -1,5 +1,5 @@ /* -CLI for skywire node +CLI for skywire visor */ package main diff --git a/cmd/skywire-node/skywire-node.go b/cmd/skywire-node/skywire-node.go deleted file mode 100644 index 4f774a0906..0000000000 --- a/cmd/skywire-node/skywire-node.go +++ /dev/null @@ -1,12 +0,0 @@ -/* -skywire application node -*/ -package main - -import ( - "github.com/skycoin/skywire/cmd/skywire-node/commands" -) - -func main() { - commands.Execute() -} diff --git a/cmd/skywire-node/commands/root.go b/cmd/skywire-visor/commands/root.go similarity index 91% rename from cmd/skywire-node/commands/root.go rename to cmd/skywire-visor/commands/root.go index 0a2fd686dc..55bde19769 100644 --- a/cmd/skywire-node/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -8,27 +8,25 @@ import ( "io/ioutil" "log" "log/syslog" + "net/http" + _ "net/http/pprof" // no_lint "os" "os/signal" "strings" "syscall" "time" + "github.com/pkg/profile" logrus_syslog "github.com/sirupsen/logrus/hooks/syslog" "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" - "net/http" - _ "net/http/pprof" //no_lint - - "github.com/pkg/profile" - - "github.com/skycoin/skywire/pkg/node" "github.com/skycoin/skywire/pkg/util/pathutil" + "github.com/skycoin/skywire/pkg/visor" ) const configEnv = "SW_CONFIG" -const defaultShutdownTimeout = node.Duration(10 * time.Second) +const defaultShutdownTimeout = visor.Duration(10 * time.Second) type runCfg struct { syslogAddr string @@ -41,15 +39,15 @@ type runCfg struct { profileStop func() logger *logging.Logger masterLogger *logging.MasterLogger - conf node.Config - node *node.Node + conf visor.Config + node *visor.Node } var cfg *runCfg var rootCmd = &cobra.Command{ - Use: "skywire-node [config-path]", - Short: "App Node for skywire", + Use: "skywire-visor [config-path]", + Short: "Visor for skywire", Run: func(_ *cobra.Command, args []string) { cfg.args = args @@ -60,7 +58,7 @@ var rootCmd = &cobra.Command{ waitOsSignals(). stopNode() }, - Version: node.Version, + Version: visor.Version, } func init() { @@ -136,7 +134,7 @@ func (cfg *runCfg) readConfig() *runCfg { rdr = bufio.NewReader(os.Stdin) } - cfg.conf = node.Config{} + cfg.conf = visor.Config{} if err := json.NewDecoder(rdr).Decode(&cfg.conf); err != nil { cfg.logger.Fatalf("Failed to decode %s: %s", rdr, err) } @@ -144,7 +142,7 @@ func (cfg *runCfg) readConfig() *runCfg { } func (cfg *runCfg) runNode() *runCfg { - node, err := node.NewNode(&cfg.conf, cfg.masterLogger) + node, err := visor.NewNode(&cfg.conf, cfg.masterLogger) if err != nil { cfg.logger.Fatal("Failed to initialize node: ", err) } diff --git a/cmd/skywire-node/config.json b/cmd/skywire-visor/config.json similarity index 100% rename from cmd/skywire-node/config.json rename to cmd/skywire-visor/config.json diff --git a/cmd/skywire-visor/skywire-visor.go b/cmd/skywire-visor/skywire-visor.go new file mode 100644 index 0000000000..d4aa990b7f --- /dev/null +++ b/cmd/skywire-visor/skywire-visor.go @@ -0,0 +1,12 @@ +/* +skywire visor +*/ +package main + +import ( + "github.com/skycoin/skywire/cmd/skywire-visor/commands" +) + +func main() { + commands.Execute() +} diff --git a/docker/images/node/Dockerfile b/docker/images/node/Dockerfile index e79dd3cd75..4956fa5edd 100644 --- a/docker/images/node/Dockerfile +++ b/docker/images/node/Dockerfile @@ -14,7 +14,7 @@ COPY . skywire WORKDIR skywire RUN go build -mod=vendor -tags netgo -ldflags="-w -s" \ - -o skywire-node cmd/skywire-node/skywire-node.go &&\ + -o skywire-visor cmd/skywire-visor/skywire-visor.go &&\ go build -mod=vendor -ldflags="-w -s" -o skywire-cli ./cmd/skywire-cli &&\ go build -mod=vendor -ldflags="-w -s" -o ./apps/skychat.v1.0 ./cmd/apps/skychat &&\ go build -mod=vendor -ldflags="-w -s" -o ./apps/helloworld.v1.0 ./cmd/apps/helloworld &&\ @@ -27,14 +27,14 @@ RUN go build -mod=vendor -tags netgo -ldflags="-w -s" \ ## Resulting image FROM ${base} as node-runner -COPY --from=builder /go/skywire/skywire-node skywire-node +COPY --from=builder /go/skywire/skywire-visor skywire-visor COPY --from=builder /go/skywire/apps bin/apps COPY --from=builder /go/skywire/docker/images/node/update.sh update.sh COPY --from=builder /go/skywire/skywire-cli bin/skywire-cli RUN ./update.sh -ENTRYPOINT [ "./skywire-node" ] +ENTRYPOINT [ "./skywire-visor" ] # default target FROM node-runner diff --git a/integration/InteractiveEnvironments.md b/integration/InteractiveEnvironments.md index 10f3b78bcc..f031d52ee5 100644 --- a/integration/InteractiveEnvironments.md +++ b/integration/InteractiveEnvironments.md @@ -22,7 +22,7 @@ ```text integration -├── generic # Generic environmnent +├── generic # Generic environment │   ├── env-vars.sh # │   ├── nodeA.json # │   └── nodeC.json # @@ -37,13 +37,13 @@ integration ├── ssh # ssh testing environment │   ├── env-vars.sh # │   ├── nodeA.json # -│   └── nodeC.json #S +│   └── nodeC.json # ├── InteractiveEnvironments.md # You're reading it ├── intermediary-nodeB.json # NodeB configurationS ├── run-base-env.sh # base environment in detached tmux session ├── run-generic-env.sh # generic environment in tmux ├── run-proxy-env.sh # proxy environment in tmux -├── run-ssh-env.sh # ssh environment in tmuxS +├── run-ssh-env.sh # ssh environment in tmux ├── start-restart-nodeB.sh # script for restart in cycle NodeB ├── startup.sh # add transports between nodes ├── tear-down.sh # tear down everything @@ -80,7 +80,7 @@ Usage: The generic test environment will define the following: - skywire-services running on localhost -- 3 skywire-nodes: +- 3 `skywire-visor`s: - NodeA, NodeC running all apps - NodeB - intermediary node without apps @@ -151,9 +151,9 @@ The following steps will be performed: 3. TRD: transport-discovery 4. RF: route-finder 5. SN: setup-node - 6. NodeA: first skywire-node running with generic/nodeA.json - 7. NodeB: first skywire-node running with intermediary-nodeB.json - 8. NodeC: first skywire-node running with generic/nodeC.json + 6. NodeA: first skywire-visor with generic/nodeA.json + 7. NodeB: first skywire-visor with intermediary-nodeB.json + 8. NodeC: first skywire-visor with generic/nodeC.json 9. shell: new shell for interactive exploration 3. ENV-vars in shell-window: 1. $MSG_PK, $SN_PK - public keys of messaging-server and setup-node @@ -167,7 +167,7 @@ The following steps will be performed: The SSH Test Environment will define the following: - skywire-services running on localhost -- 3 skywire-nodes: +- 3 `skywire-visor`s: - NodeA - running `SSH` app - NodeB - intermediary node without apps - NodeC - running `SSH-client` app @@ -198,7 +198,7 @@ $ make integration-startup 4. NodeC with configured `SSH-client` app 2. Run `./integration/test-ssh.sh` which will run in cycle: 1. `./SSH-cli $PK_A "export n=1; loop -n $n echo A"` - 2. kill all skywire-nodes + 2. kill all `skywire-visor`s 3. Collect logs 4. Increase n by power of 2 5. Repeat @@ -208,7 +208,7 @@ $ make integration-startup The proxy test environment will define the following: - skywire-services running on localhost -- 3 skywire-nodes: +- 3 `skywire-visor`s: - NodeA - running `SSH` app - NodeB - intermediary node without apps - NodeC - running `SSH-client` app diff --git a/integration/generic/nodeA.json b/integration/generic/nodeA.json index 9584d24361..67baf6ec32 100644 --- a/integration/generic/nodeA.json +++ b/integration/generic/nodeA.json @@ -49,7 +49,7 @@ } ], "trusted_nodes": [], - "manager_nodes": [], + "hypervisors": [], "apps_path": "./apps", "local_path": "./local/nodeA", "log_level": "info", diff --git a/integration/generic/nodeC.json b/integration/generic/nodeC.json index 832d4cb74f..684caa34f3 100644 --- a/integration/generic/nodeC.json +++ b/integration/generic/nodeC.json @@ -55,7 +55,7 @@ } ], "trusted_nodes": [], - "manager_nodes": [], + "hypervisors": [], "apps_path": "./apps", "local_path": "./local/nodeC", "log_level": "info", diff --git a/integration/intermediary-nodeB.json b/integration/intermediary-nodeB.json index 928c9cc80c..ca657feb45 100644 --- a/integration/intermediary-nodeB.json +++ b/integration/intermediary-nodeB.json @@ -28,7 +28,7 @@ }, "apps": [], "trusted_nodes": [], - "manager_nodes": [], + "hypervisors": [], "apps_path": "./bin/apps", "local_path": "./local/localB", "log_level": "info", diff --git a/integration/messaging/env-vars.sh b/integration/messaging/env-vars.sh index 8c5f41f47b..1110e42eb2 100644 --- a/integration/messaging/env-vars.sh +++ b/integration/messaging/env-vars.sh @@ -18,9 +18,9 @@ alias CLI_A='./skywire-cli --rpc $RPC_A' alias CLI_B='./skywire-cli --rpc $RPC_B' alias CLI_C='./skywire-cli --rpc $RPC_C' -alias RUN_A='./skywire-node ./integration/messaging/nodeA.json --tag NodeA' -alias RUN_B='./skywire-node ./integration/messaging/intermediary-nodeB.json --tag NodeB' -alias RUN_C='./skywire-node ./integration/messaging/nodeC.json --tag NodeC' +alias RUN_A='./skywire-visor ./integration/messaging/nodeA.json --tag NodeA' +alias RUN_B='./skywire-visor ./integration/messaging/intermediary-nodeB.json --tag NodeB' +alias RUN_C='./skywire-visor ./integration/messaging/nodeC.json --tag NodeC' echo PK_A: $PK_A echo PK_B: $PK_B diff --git a/integration/messaging/nodeA.json b/integration/messaging/nodeA.json index f3865229b4..3f95613c34 100644 --- a/integration/messaging/nodeA.json +++ b/integration/messaging/nodeA.json @@ -36,7 +36,7 @@ } ], "trusted_nodes": [], - "manager_nodes": [], + "hypervisors": [], "apps_path": "./apps", "shutdown_timeout": "30s", "local_path": "./local/nodeA", diff --git a/integration/messaging/nodeC.json b/integration/messaging/nodeC.json index 4abccc7dc7..f864ecd0da 100644 --- a/integration/messaging/nodeC.json +++ b/integration/messaging/nodeC.json @@ -39,7 +39,7 @@ } ], "trusted_nodes": [], - "manager_nodes": [], + "hypervisors": [], "apps_path": "./apps", "shutdown_timeout": "30s", "local_path": "./local/nodeC", diff --git a/integration/proxy/env-vars.sh b/integration/proxy/env-vars.sh index 07a9aca479..945a17cd81 100644 --- a/integration/proxy/env-vars.sh +++ b/integration/proxy/env-vars.sh @@ -15,9 +15,9 @@ export MSGD=https://messaging.discovery.skywire.skycoin.net export TRD=https://transport.discovery.skywire.skycoin.net export RF=https://routefinder.skywire.skycoin.net -alias RUN_A='go run ./cmd/skywire-node ./integration/messaging/nodeA.json --tag NodeA' -alias RUN_B='go run ./cmd/skywire-node ./integration/intermediary-nodeB.json --tag NodeB' -alias RUN_C='go run ./cmd/skywire-node ./integration/messaging/nodeC.json --tag NodeC' +alias RUN_A='go run ./cmd/skywire-visor ./integration/messaging/nodeA.json --tag NodeA' +alias RUN_B='go run ./cmd/skywire-visor ./integration/intermediary-nodeB.json --tag NodeB' +alias RUN_C='go run ./cmd/skywire-visor ./integration/messaging/nodeC.json --tag NodeC' echo PK_A: $PK_A echo PK_B: $PK_B diff --git a/integration/proxy/nodeA.json b/integration/proxy/nodeA.json index 8bd204583b..ea4352493a 100644 --- a/integration/proxy/nodeA.json +++ b/integration/proxy/nodeA.json @@ -35,7 +35,7 @@ } ], "trusted_nodes": [], - "manager_nodes": [], + "hypervisors": [], "apps_path": "./apps", "local_path": "./local/nodeA", "log_level": "info", diff --git a/integration/proxy/nodeC.json b/integration/proxy/nodeC.json index 052a6bb254..31a6c51626 100644 --- a/integration/proxy/nodeC.json +++ b/integration/proxy/nodeC.json @@ -38,7 +38,7 @@ } ], "trusted_nodes": [], - "manager_nodes": [], + "hypervisors": [], "apps_path": "./apps", "local_path": "./local/nodeC", "log_level": "info", diff --git a/integration/run-generic-env.sh b/integration/run-generic-env.sh index 894d0b7e1c..8e993b9460 100755 --- a/integration/run-generic-env.sh +++ b/integration/run-generic-env.sh @@ -10,13 +10,13 @@ echo "Checking transport-discovery is up" curl --retry 5 --retry-connrefused 1 --connect-timeout 5 https://transport.discovery.skywire.skycoin.net/security/nonces/$PK_A tmux rename-window -t skywire NodeA -tmux send-keys -t NodeA -l "./skywire-node ./integration/generic/nodeA.json --tag NodeA $SYSLOG_OPTS" +tmux send-keys -t NodeA -l "./skywire-visor ./integration/generic/nodeA.json --tag NodeA $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n NodeB -tmux send-keys -t NodeB -l "./skywire-node ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" +tmux send-keys -t NodeB -l "./skywire-visor ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n NodeC -tmux send-keys -t NodeC -l "./skywire-node ./integration/generic/nodeC.json --tag NodeC $SYSLOG_OPTS" +tmux send-keys -t NodeC -l "./skywire-visor ./integration/generic/nodeC.json --tag NodeC $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n shell diff --git a/integration/run-messaging-env.sh b/integration/run-messaging-env.sh index be1091fa14..2afdb95601 100755 --- a/integration/run-messaging-env.sh +++ b/integration/run-messaging-env.sh @@ -10,13 +10,13 @@ echo "Checking transport-discovery is up" curl --retry 5 --retry-connrefused 1 --connect-timeout 5 https://transport.discovery.skywire.skycoin.net/security/nonces/$PK_A tmux rename-window -t skywire NodeA -tmux send-keys -t NodeA -l "./skywire-node ./integration/messaging/nodeA.json --tag NodeA $SYSLOG_OPTS" +tmux send-keys -t NodeA -l "./skywire-visor ./integration/messaging/nodeA.json --tag NodeA $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n NodeB -tmux send-keys -t NodeB -l "./skywire-node ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" +tmux send-keys -t NodeB -l "./skywire-visor ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n NodeC -tmux send-keys -t NodeC -l "./skywire-node ./integration/messaging/nodeC.json --tag NodeC $SYSLOG_OPTS" +tmux send-keys -t NodeC -l "./skywire-visor ./integration/messaging/nodeC.json --tag NodeC $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n shell diff --git a/integration/run-proxy-env.sh b/integration/run-proxy-env.sh index bae9473f26..3aa2247671 100755 --- a/integration/run-proxy-env.sh +++ b/integration/run-proxy-env.sh @@ -10,13 +10,13 @@ echo "Checking transport-discovery is up" curl --retry 5 --retry-connrefused 1 --connect-timeout 5 https://transport.discovery.skywire.skycoin.net/security/nonces/$PK_A tmux rename-window -t skywire NodeA -tmux send-keys -t NodeA -l "./skywire-node ./integration/proxy/nodeA.json --tag NodeA $SYSLOG_OPTS" +tmux send-keys -t NodeA -l "./skywire-visor ./integration/proxy/nodeA.json --tag NodeA $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n NodeB -tmux send-keys -t NodeB -l "./skywire-node ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" +tmux send-keys -t NodeB -l "./skywire-visor ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n NodeC -tmux send-keys -t NodeC -l "./skywire-node ./integration/proxy/nodeC.json --tag NodeC $SYSLOG_OPTS" +tmux send-keys -t NodeC -l "./skywire-visor ./integration/proxy/nodeC.json --tag NodeC $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n shell diff --git a/integration/run-ssh-env.sh b/integration/run-ssh-env.sh index c1b6b561c6..758d8b01fe 100755 --- a/integration/run-ssh-env.sh +++ b/integration/run-ssh-env.sh @@ -10,13 +10,13 @@ echo "Checking transport-discovery is up" curl --retry 5 --retry-connrefused 1 --connect-timeout 5 https://transport.discovery.skywire.skycoin.net/security/nonces/$PK_A tmux rename-window -t skywire NodeA -tmux send-keys -t NodeA -l "./skywire-node ./integration/ssh/nodeA.json --tag NodeA $SYSLOG_OPTS" +tmux send-keys -t NodeA -l "./skywire-visor ./integration/ssh/nodeA.json --tag NodeA $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n NodeB -tmux send-keys -t NodeB -l "./skywire-node ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" +tmux send-keys -t NodeB -l "./skywire-visor ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n NodeC -tmux send-keys -t NodeC -l "./skywire-node ./integration/ssh/nodeC.json --tag NodeC $SYSLOG_OPTS" +tmux send-keys -t NodeC -l "./skywire-visor ./integration/ssh/nodeC.json --tag NodeC $SYSLOG_OPTS" tmux send-keys C-m tmux new-window -t skywire -n shell diff --git a/integration/ssh/env-vars.sh b/integration/ssh/env-vars.sh index d938a1b5a9..bf0cab2ad9 100644 --- a/integration/ssh/env-vars.sh +++ b/integration/ssh/env-vars.sh @@ -15,9 +15,9 @@ export MSGD=https://messaging.discovery.skywire.skycoin.net export TRD=https://transport.discovery.skywire.skycoin.net export RF=https://routefinder.skywire.skycoin.net -alias RUN_A='go run ./cmd/skywire-node ./integration/messaging/nodeA.json --tag NodeA' -alias RUN_B='go run ./cmd/skywire-node ./integration/intermediary-nodeB.json --tag NodeB' -alias RUN_C='go run ./cmd/skywire-node ./integration/messaging/nodeC.json --tag NodeC' +alias RUN_A='go run ./cmd/skywire-visor ./integration/messaging/nodeA.json --tag NodeA' +alias RUN_B='go run ./cmd/skywire-visor ./integration/intermediary-nodeB.json --tag NodeB' +alias RUN_C='go run ./cmd/skywire-visor ./integration/messaging/nodeC.json --tag NodeC' echo PK_A: $PK_A echo PK_B: $PK_B diff --git a/integration/ssh/nodeA.json b/integration/ssh/nodeA.json index 9584d24361..67baf6ec32 100644 --- a/integration/ssh/nodeA.json +++ b/integration/ssh/nodeA.json @@ -49,7 +49,7 @@ } ], "trusted_nodes": [], - "manager_nodes": [], + "hypervisors": [], "apps_path": "./apps", "local_path": "./local/nodeA", "log_level": "info", diff --git a/integration/ssh/nodeC.json b/integration/ssh/nodeC.json index 832d4cb74f..684caa34f3 100644 --- a/integration/ssh/nodeC.json +++ b/integration/ssh/nodeC.json @@ -55,7 +55,7 @@ } ], "trusted_nodes": [], - "manager_nodes": [], + "hypervisors": [], "apps_path": "./apps", "local_path": "./local/nodeC", "log_level": "info", diff --git a/integration/start-restart-nodeB.sh b/integration/start-restart-nodeB.sh index dbf9c0e5de..4b6c20f394 100755 --- a/integration/start-restart-nodeB.sh +++ b/integration/start-restart-nodeB.sh @@ -4,7 +4,7 @@ mkdir -p ./logs echo Press Ctrl-C to exit for ((;;)) do - ./bin/skywire-node ./integration/intermediary-nodeB.json --tag NodeB 2>> ./logs/nodeB.log >> ./logs/nodeB.log & + ./bin/skywire-visor ./integration/intermediary-nodeB.json --tag NodeB 2>> ./logs/nodeB.log >> ./logs/nodeB.log & echo node starting NodeB sleep 25 echo Killing NodeB on $(ps aux |grep "[N]odeB" |awk '{print $2}') diff --git a/integration/tear-down.sh b/integration/tear-down.sh index 37c685deed..72dbdf8150 100755 --- a/integration/tear-down.sh +++ b/integration/tear-down.sh @@ -1,6 +1,6 @@ #!/bin/sh -# In case skywire-nodes are not stopped properly. +# In case skywire-visors are not stopped properly. kill $(ps aux |grep "[N]odeA" |awk '{print $2}') kill $(ps aux |grep "[N]odeB" |awk '{print $2}') kill $(ps aux |grep "[N]odeC" |awk '{print $2}') diff --git a/integration/test-proxy.sh b/integration/test-proxy.sh index 1c72d0a6f3..5ccf5f9e6d 100755 --- a/integration/test-proxy.sh +++ b/integration/test-proxy.sh @@ -11,7 +11,7 @@ do echo Test with $N requests mkdir -p ./logs/proxy/$N - echo Killing nodes + echo Killing nodes echo Killing $(ps aux |grep "[N]odeA\|[N]odeB\|[N]odeC" |awk '{print $2}') kill $(ps aux |grep "[N]odeA\|[N]odeB\|[N]odeC" |awk '{print $2}') @@ -19,13 +19,13 @@ do sleep 10 echo Restarting nodeA and NodeB - ./bin/skywire-node ./integration/proxy/nodeA.json --tag NodeA &> ./logs/proxy/$N/nodeA.log & - ./bin/skywire-node ./integration/intermediary-nodeB.json --tag NodeB &> ./logs/proxy/$N/nodeB.log & + ./bin/skywire-visor ./integration/proxy/nodeA.json --tag NodeA &> ./logs/proxy/$N/nodeA.log & + ./bin/skywire-visor ./integration/intermediary-nodeB.json --tag NodeB &> ./logs/proxy/$N/nodeB.log & # TODO: improve this sleep sleep 5 echo Restarting nodeC - ./bin/skywire-node ./integration/proxy/nodeC.json --tag NodeC &> ./logs/proxy/$N/nodeC.log & + ./bin/skywire-visor ./integration/proxy/nodeC.json --tag NodeC &> ./logs/proxy/$N/nodeC.log & sleep 20 echo Trying socks5 proxy @@ -37,4 +37,4 @@ do done export N=$(($N*2)) -done \ No newline at end of file +done diff --git a/integration/test-ssh.sh b/integration/test-ssh.sh index 2aad08ab6a..5bcb91cc4e 100755 --- a/integration/test-ssh.sh +++ b/integration/test-ssh.sh @@ -16,9 +16,9 @@ do kill $(ps aux |grep "[N]odeA\|[N]odeB\|[N]odeC\|[s]kywire/SSH-cli" |awk '{print $2}') echo Restarting nodes - ./bin/skywire-node ./integration/ssh/nodeA.json --tag NodeA &> ./logs/ssh/$N/nodeA.log & - ./bin/skywire-node ./integration/intermediary-nodeB.json --tag NodeB &> ./logs/ssh/$N/nodeB.log & - ./bin/skywire-node ./integration/ssh/nodeC.json --tag NodeC &> ./logs/ssh/$N/nodeC.log & + ./bin/skywire-visor ./integration/ssh/nodeA.json --tag NodeA &> ./logs/ssh/$N/nodeA.log & + ./bin/skywire-visor ./integration/intermediary-nodeB.json --tag NodeB &> ./logs/ssh/$N/nodeB.log & + ./bin/skywire-visor ./integration/ssh/nodeC.json --tag NodeC &> ./logs/ssh/$N/nodeC.log & sleep 20 echo Trying SSH-cli diff --git a/pkg/manager/config.go b/pkg/hypervisor/config.go similarity index 91% rename from pkg/manager/config.go rename to pkg/hypervisor/config.go index d3bfe20de6..f35e6f6a71 100644 --- a/pkg/manager/config.go +++ b/pkg/hypervisor/config.go @@ -1,4 +1,4 @@ -package manager +package hypervisor import ( "encoding/hex" @@ -33,7 +33,7 @@ func (hk *Key) UnmarshalText(text []byte) error { return err } -// Config configures the manager node. +// Config configures the hypervisor. type Config struct { PK cipher.PubKey `json:"public_key"` SK cipher.SecKey `json:"secret_key"` @@ -69,14 +69,14 @@ func GenerateWorkDirConfig() Config { // GenerateHomeConfig generates a config with default values and uses db from user's home folder. func GenerateHomeConfig() Config { c := makeConfig() - c.DBPath = filepath.Join(pathutil.HomeDir(), ".skycoin/skywire-manager/users.db") + c.DBPath = filepath.Join(pathutil.HomeDir(), ".skycoin/hypervisor/users.db") return c } // GenerateLocalConfig generates a config with default values and uses db from shared folder. func GenerateLocalConfig() Config { c := makeConfig() - c.DBPath = "/usr/local/skycoin/skywire-manager/users.db" + c.DBPath = "/usr/local/skycoin/hypervisor/users.db" return c } @@ -100,7 +100,7 @@ func (c *Config) Parse(path string) error { return json.NewDecoder(f).Decode(c) } -// CookieConfig configures cookies used for manager. +// CookieConfig configures cookies used for hypervisor. type CookieConfig struct { HashKey Key `json:"hash_key"` // Signs the cookie: 32 or 64 bytes. BlockKey Key `json:"block_key"` // Encrypts the cookie: 16 (AES-128), 24 (AES-192), 32 (AES-256) bytes. (optional) @@ -123,7 +123,7 @@ func (c *CookieConfig) FillDefaults() { c.SameSite = http.SameSiteDefaultMode } -// InterfaceConfig configures the interfaces exposed by manager. +// InterfaceConfig configures the interfaces exposed by hypervisor. type InterfaceConfig struct { HTTPAddr string `json:"http_address"` RPCAddr string `json:"rpc_addr"` diff --git a/pkg/manager/node.go b/pkg/hypervisor/hypervisor.go similarity index 96% rename from pkg/manager/node.go rename to pkg/hypervisor/hypervisor.go index c03fd31eca..5fa6ac75b0 100644 --- a/pkg/manager/node.go +++ b/pkg/hypervisor/hypervisor.go @@ -1,5 +1,5 @@ -// Package manager implements management node -package manager +// Package hypervisor implements management node +package hypervisor import ( "encoding/hex" @@ -17,22 +17,21 @@ import ( "github.com/go-chi/chi/middleware" "github.com/google/uuid" "github.com/skycoin/dmsg/cipher" - "github.com/skycoin/skycoin/src/util/logging" - "github.com/skycoin/dmsg/noise" + "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire/pkg/httputil" - "github.com/skycoin/skywire/pkg/node" "github.com/skycoin/skywire/pkg/routing" + "github.com/skycoin/skywire/pkg/visor" ) var ( - log = logging.MustGetLogger("manager") + log = logging.MustGetLogger("hypervisor") ) type appNodeConn struct { Addr *noise.Addr - Client node.RPCClient + Client visor.RPCClient } // Node manages AppNodes. @@ -70,7 +69,7 @@ func (m *Node) ServeRPC(lis net.Listener) error { m.mu.RLock() m.nodes[addr.PK] = appNodeConn{ Addr: addr, - Client: node.NewRPCClient(rpc.NewClient(conn), node.RPCPrefix), + Client: visor.NewRPCClient(rpc.NewClient(conn), visor.RPCPrefix), } m.mu.RUnlock() } @@ -89,11 +88,11 @@ type MockConfig struct { EnableAuth bool } -// AddMockData adds mock data to Manager Node. +// AddMockData adds mock data to Node. func (m *Node) AddMockData(config MockConfig) error { r := rand.New(rand.NewSource(time.Now().UnixNano())) for i := 0; i < config.Nodes; i++ { - pk, client := node.NewMockRPCClient(r, config.MaxTpsPerNode, config.MaxRoutesPerNode) + pk, client := visor.NewMockRPCClient(r, config.MaxTpsPerNode, config.MaxRoutesPerNode) m.mu.Lock() m.nodes[pk] = appNodeConn{ Addr: &noise.Addr{ @@ -150,7 +149,7 @@ func (m *Node) ServeHTTP(w http.ResponseWriter, req *http.Request) { type summaryResp struct { TCPAddr string `json:"tcp_addr"` - *node.Summary + *visor.Summary } // provides summary of all nodes. @@ -162,7 +161,7 @@ func (m *Node) getNodes() http.HandlerFunc { summary, err := c.Client.Summary() if err != nil { log.Printf("failed to obtain summary from AppNode with pk %s. Error: %v", pk, err) - summary = &node.Summary{PubKey: pk} + summary = &visor.Summary{PubKey: pk} } summaries = append(summaries, summaryResp{ TCPAddr: c.Addr.Addr.String(), @@ -429,7 +428,7 @@ type loopResp struct { FwdRule routing.RuleForwardFields `json:"resp"` } -func makeLoopResp(info node.LoopInfo) loopResp { +func makeLoopResp(info visor.LoopInfo) loopResp { if len(info.FwdRule) == 0 || len(info.AppRule) == 0 { return loopResp{} } @@ -458,7 +457,7 @@ func (m *Node) getLoops() http.HandlerFunc { <<< Helper functions >>> */ -func (m *Node) client(pk cipher.PubKey) (*noise.Addr, node.RPCClient, bool) { +func (m *Node) client(pk cipher.PubKey) (*noise.Addr, visor.RPCClient, bool) { m.mu.RLock() conn, ok := m.nodes[pk] m.mu.RUnlock() @@ -469,13 +468,13 @@ type httpCtx struct { // Node PK cipher.PubKey Addr *noise.Addr - RPC node.RPCClient + RPC visor.RPCClient // App - App *node.AppState + App *visor.AppState // Transport - Tp *node.TransportSummary + Tp *visor.TransportSummary // Route RtKey routing.RouteID @@ -546,7 +545,7 @@ func (m *Node) tpCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { } tp, err := ctx.RPC.Transport(tid) if err != nil { - if err.Error() == node.ErrNotFound.Error() { + if err.Error() == visor.ErrNotFound.Error() { httputil.WriteJSON(w, r, http.StatusNotFound, fmt.Errorf("transport of ID %s is not found", tid)) return nil, false diff --git a/pkg/manager/node_test.go b/pkg/hypervisor/hypervisor_test.go similarity index 99% rename from pkg/manager/node_test.go rename to pkg/hypervisor/hypervisor_test.go index 44d2d72dc1..74becc374e 100644 --- a/pkg/manager/node_test.go +++ b/pkg/hypervisor/hypervisor_test.go @@ -1,4 +1,4 @@ -package manager +package hypervisor import ( "encoding/json" @@ -36,7 +36,7 @@ func TestMain(m *testing.M) { func TestNewNode(t *testing.T) { config := makeConfig() - confDir, err := ioutil.TempDir(os.TempDir(), "SWM") + confDir, err := ioutil.TempDir(os.TempDir(), "SWHV") require.NoError(t, err) config.DBPath = filepath.Join(confDir, "users.db") diff --git a/pkg/manager/user.go b/pkg/hypervisor/user.go similarity index 98% rename from pkg/manager/user.go rename to pkg/hypervisor/user.go index 2438f1bebd..7dd0bfe765 100644 --- a/pkg/manager/user.go +++ b/pkg/hypervisor/user.go @@ -1,4 +1,4 @@ -package manager +package hypervisor import ( "bytes" @@ -22,7 +22,7 @@ func init() { gob.Register(User{}) } -// User represents a user of the manager. +// User represents a user of the hypervisor. type User struct { Name string PwSalt []byte diff --git a/pkg/manager/user_manager.go b/pkg/hypervisor/user_manager.go similarity index 99% rename from pkg/manager/user_manager.go rename to pkg/hypervisor/user_manager.go index 7795a0bfdb..05f15c9e70 100644 --- a/pkg/manager/user_manager.go +++ b/pkg/hypervisor/user_manager.go @@ -1,4 +1,4 @@ -package manager +package hypervisor import ( "context" diff --git a/pkg/route-finder/client/client.go b/pkg/route-finder/client/client.go index fea92a846e..61c4993355 100644 --- a/pkg/route-finder/client/client.go +++ b/pkg/route-finder/client/client.go @@ -69,7 +69,7 @@ func NewHTTP(addr string, apiTimeout time.Duration) Client { } } -// PairedRoutes returns routes from source skywire node to destiny, that has at least the given minHops and as much +// PairedRoutes returns routes from source skywire visor to destiny, that has at least the given minHops and as much // the given maxHops as well as the reverse routes from destiny to source. func (c *apiClient) PairedRoutes(source, destiny cipher.PubKey, minHops, maxHops uint16) ([]routing.Route, []routing.Route, error) { requestBody := &GetRoutesRequest{ diff --git a/pkg/router/router.go b/pkg/router/router.go index 6f4dbeaa3b..a341836c74 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -1,4 +1,4 @@ -// Package router implements package router for skywire node. +// Package router implements package router for skywire visor. package router import ( diff --git a/pkg/router/app_manager.go b/pkg/router/visor.go similarity index 100% rename from pkg/router/app_manager.go rename to pkg/router/visor.go diff --git a/pkg/router/app_manager_test.go b/pkg/router/visor_test.go similarity index 100% rename from pkg/router/app_manager_test.go rename to pkg/router/visor_test.go diff --git a/pkg/routing/packet.go b/pkg/routing/packet.go index c152a4c9d4..136c69415d 100644 --- a/pkg/routing/packet.go +++ b/pkg/routing/packet.go @@ -8,7 +8,7 @@ import ( // RouteID represents ID of a Route in a Packet. type RouteID uint32 -// Packet defines generic packet recognized by all skywire nodes. +// Packet defines generic packet recognized by all skywire visors. type Packet []byte // MakePacket constructs a new Packet. If payload size is more than diff --git a/pkg/util/pathutil/configpath.go b/pkg/util/pathutil/configpath.go index a29c0c6207..591ba23da2 100644 --- a/pkg/util/pathutil/configpath.go +++ b/pkg/util/pathutil/configpath.go @@ -71,7 +71,7 @@ func (dp ConfigPaths) Get(cpType ConfigLocationType) string { return "" } -// NodeDefaults returns the default config paths for skywire-node. +// NodeDefaults returns the default config paths for skywire-visor. func NodeDefaults() ConfigPaths { paths := make(ConfigPaths) if wd, err := os.Getwd(); err == nil { @@ -82,14 +82,14 @@ func NodeDefaults() ConfigPaths { return paths } -// ManagerDefaults returns the default config paths for manager-node. -func ManagerDefaults() ConfigPaths { +// HypervisorDefaults returns the default config paths for hypervisor. +func HypervisorDefaults() ConfigPaths { paths := make(ConfigPaths) if wd, err := os.Getwd(); err == nil { - paths[WorkingDirLoc] = filepath.Join(wd, "manager-config.json") + paths[WorkingDirLoc] = filepath.Join(wd, "hypervisor-config.json") } - paths[HomeLoc] = filepath.Join(HomeDir(), ".skycoin/skywire-manager/manager-config.json") - paths[LocalLoc] = "/usr/local/skycoin/skywire-manager/manager-config.json" + paths[HomeLoc] = filepath.Join(HomeDir(), ".skycoin/hypervisor/hypervisor-config.json") + paths[LocalLoc] = "/usr/local/skycoin/hypervisor/hypervisor-config.json" return paths } diff --git a/pkg/node/config.go b/pkg/visor/config.go similarity index 94% rename from pkg/node/config.go rename to pkg/visor/config.go index 8184ec1e3a..9652567223 100644 --- a/pkg/node/config.go +++ b/pkg/visor/config.go @@ -1,4 +1,4 @@ -package node +package visor import ( "encoding/json" @@ -51,8 +51,8 @@ type Config struct { Apps []AppConfig `json:"apps"` - TrustedNodes []cipher.PubKey `json:"trusted_nodes"` - ManagerNodes []ManagerConfig `json:"manager_nodes"` + TrustedNodes []cipher.PubKey `json:"trusted_nodes"` + Hypervisors []HypervisorConfig `json:"hypervisors"` AppsPath string `json:"apps_path"` LocalPath string `json:"local_path"` @@ -158,8 +158,8 @@ func ensureDir(path string) (string, error) { return absPath, nil } -// ManagerConfig represents a connection to a manager. -type ManagerConfig struct { +// HypervisorConfig represents a connection to a hypervisor. +type HypervisorConfig struct { PubKey cipher.PubKey `json:"public_key"` Addr string `json:"address"` } @@ -173,7 +173,7 @@ type AppConfig struct { Args []string `json:"args"` } -// InterfaceConfig defines listening interfaces for skywire Node. +// InterfaceConfig defines listening interfaces for skywire visor. type InterfaceConfig struct { RPCAddress string `json:"rpc"` // RPC address and port for command-line interface (leave blank to disable RPC interface). } diff --git a/pkg/node/config_test.go b/pkg/visor/config_test.go similarity index 99% rename from pkg/node/config_test.go rename to pkg/visor/config_test.go index abc7a6a746..a76ebcdeb9 100644 --- a/pkg/node/config_test.go +++ b/pkg/visor/config_test.go @@ -1,4 +1,4 @@ -package node +package visor import ( "encoding/json" diff --git a/pkg/node/rpc.go b/pkg/visor/rpc.go similarity index 99% rename from pkg/node/rpc.go rename to pkg/visor/rpc.go index 1465103f87..2b4711f583 100644 --- a/pkg/node/rpc.go +++ b/pkg/visor/rpc.go @@ -1,4 +1,4 @@ -package node +package visor import ( "context" diff --git a/pkg/node/rpc_client.go b/pkg/visor/rpc_client.go similarity index 99% rename from pkg/node/rpc_client.go rename to pkg/visor/rpc_client.go index 638d857226..56ff83b948 100644 --- a/pkg/node/rpc_client.go +++ b/pkg/visor/rpc_client.go @@ -1,4 +1,4 @@ -package node +package visor import ( "encoding/binary" diff --git a/pkg/node/rpc_test.go b/pkg/visor/rpc_test.go similarity index 99% rename from pkg/node/rpc_test.go rename to pkg/visor/rpc_test.go index b8ec54c11d..2deec3176f 100644 --- a/pkg/node/rpc_test.go +++ b/pkg/visor/rpc_test.go @@ -1,4 +1,4 @@ -package node +package visor import ( "context" diff --git a/pkg/node/node.go b/pkg/visor/visor.go similarity index 98% rename from pkg/node/node.go rename to pkg/visor/visor.go index 1d5066b2b2..ecd999c4dd 100644 --- a/pkg/node/node.go +++ b/pkg/visor/visor.go @@ -1,5 +1,5 @@ -// Package node implements skywire node. -package node +// Package visor implements skywire visor. +package visor import ( "bufio" @@ -19,9 +19,8 @@ import ( "syscall" "time" - "github.com/skycoin/skycoin/src/util/logging" - "github.com/skycoin/dmsg/noise" + "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire/pkg/app" routeFinder "github.com/skycoin/skywire/pkg/route-finder/client" @@ -189,8 +188,8 @@ func NewNode(config *Config, masterLogger *logging.MasterLogger) (*Node, error) } node.rpcListener = l } - node.rpcDialers = make([]*noise.RPCClientDialer, len(config.ManagerNodes)) - for i, entry := range config.ManagerNodes { + node.rpcDialers = make([]*noise.RPCClientDialer, len(config.Hypervisors)) + for i, entry := range config.Hypervisors { node.rpcDialers[i] = noise.NewRPCClientDialer(entry.Addr, noise.HandshakeXK, noise.Config{ LocalPK: pk, LocalSK: sk, diff --git a/pkg/node/node_test.go b/pkg/visor/visor_test.go similarity index 99% rename from pkg/node/node_test.go rename to pkg/visor/visor_test.go index 59768e3e52..e9f7498190 100644 --- a/pkg/node/node_test.go +++ b/pkg/visor/visor_test.go @@ -1,4 +1,4 @@ -package node +package visor import ( "context" diff --git a/vendor/github.com/skycoin/dmsg/disc/entry.go b/vendor/github.com/skycoin/dmsg/disc/entry.go index 4cecbfa5e4..958fd899c5 100644 --- a/vendor/github.com/skycoin/dmsg/disc/entry.go +++ b/vendor/github.com/skycoin/dmsg/disc/entry.go @@ -4,9 +4,8 @@ import ( "encoding/json" "errors" "fmt" - "time" - "strings" + "time" "github.com/skycoin/dmsg/cipher" ) diff --git a/vendor/github.com/skycoin/dmsg/noise/net.go b/vendor/github.com/skycoin/dmsg/noise/net.go index 3115684105..4904157197 100644 --- a/vendor/github.com/skycoin/dmsg/noise/net.go +++ b/vendor/github.com/skycoin/dmsg/noise/net.go @@ -131,7 +131,7 @@ func (d *RPCClientDialer) clearDone() { d.mu.Unlock() } -// Addr is the address of a either an AppNode or ManagerNode. +// Addr is the address of a either an Visor or Hypervisor. type Addr struct { PK cipher.PubKey Addr net.Addr