From 78b7513eaa03f51852db285c52142b53dcfe273f Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Mon, 1 Jul 2019 11:42:26 +0300 Subject: [PATCH 01/10] Rename node to visor, rename manager node to hypervisor --- .gitignore | 10 +- Makefile | 94 +++---- README.md | 178 ++++++------- ROADMAP.md | 2 +- ci_scripts/run-pkg-tests.sh | 30 +-- cmd/apps/helloworld/helloworld.go | 6 +- cmd/apps/skychat/README.md | 18 +- cmd/apps/skychat/chat.go | 2 +- cmd/apps/therealproxy-client/README.md | 2 +- .../therealproxy-client.go | 2 +- cmd/apps/therealproxy/README.md | 18 +- cmd/apps/therealproxy/therealproxy.go | 2 +- cmd/apps/therealssh-client/README.md | 2 +- .../therealssh-client/therealssh-client.go | 2 +- cmd/apps/therealssh/README.md | 24 +- cmd/apps/therealssh/therealssh.go | 2 +- cmd/{manager-node => hypervisor}/README.md | 10 +- .../commands/gen-config.go | 12 +- .../commands/root.go | 40 +-- cmd/hypervisor/hypervisor.go | 10 + .../hypervisor.postman_collection.json} | 24 +- cmd/manager-node/manager-node.go | 10 - cmd/setup-node/commands/root.go | 2 +- cmd/skywire-cli/commands/mdisc/root.go | 4 +- cmd/skywire-cli/commands/root.go | 4 +- cmd/skywire-cli/commands/rtfind/root.go | 4 +- .../commands/{node => visor}/app.go | 8 +- .../commands/{node => visor}/gen-config.go | 30 +-- .../commands/{node => visor}/pk.go | 4 +- .../commands/{node => visor}/root.go | 14 +- .../commands/{node => visor}/routes.go | 10 +- .../commands/{node => visor}/transports.go | 10 +- cmd/skywire-cli/skywire-cli.go | 2 +- cmd/skywire-node/skywire-node.go | 12 - cmd/{skywire-node => visor}/commands/root.go | 48 ++-- cmd/{skywire-node => visor}/config.json | 2 +- cmd/visor/visor.go | 12 + integration/InteractiveEnvironments.md | 92 +++---- integration/generic/env-vars.sh | 14 +- .../generic/{nodeA.json => visorA.json} | 12 +- .../generic/{nodeC.json => visorC.json} | 12 +- ...ry-nodeB.json => intermediary-visorB.json} | 10 +- integration/messaging/env-vars.sh | 20 +- .../messaging/{nodeA.json => visorA.json} | 12 +- .../messaging/{nodeC.json => visorC.json} | 12 +- integration/proxy/env-vars.sh | 18 +- integration/proxy/{nodeA.json => visorA.json} | 12 +- integration/proxy/{nodeC.json => visorC.json} | 12 +- integration/run-generic-env.sh | 12 +- integration/run-messaging-env.sh | 12 +- integration/run-proxy-env.sh | 12 +- integration/run-ssh-env.sh | 12 +- integration/ssh/env-vars.sh | 18 +- integration/ssh/{nodeA.json => visorA.json} | 12 +- integration/ssh/{nodeC.json => visorC.json} | 12 +- integration/start-restart-nodeB.sh | 14 - integration/start-restart-visorB.sh | 14 + integration/startup.sh | 12 +- integration/tear-down.sh | 8 +- integration/test-proxy.sh | 20 +- integration/test-ssh.sh | 16 +- internal/noise/net.go | 2 +- internal/therealssh/client.go | 2 +- pkg/app/app.go | 10 +- pkg/app/packet.go | 2 +- pkg/app/protocol.go | 2 +- pkg/{manager => hypervisor}/config.go | 12 +- .../node.go => hypervisor/hypervisor.go} | 169 ++++++------ .../hypervisor_test.go} | 36 +-- pkg/{manager => hypervisor}/user.go | 4 +- pkg/{manager => hypervisor}/user_manager.go | 2 +- pkg/messaging-discovery/client/entry.go | 3 +- pkg/messaging/factory.go | 4 +- pkg/route-finder/client/client.go | 2 +- pkg/router/router.go | 4 +- pkg/routing/route.go | 2 +- pkg/setup/protocol.go | 2 +- pkg/transport/manager.go | 10 +- pkg/transport/tcp_transport.go | 2 +- pkg/transport/transport.go | 4 +- pkg/util/pathutil/configpath.go | 20 +- pkg/util/pathutil/homedir.go | 4 +- pkg/{node => visor}/config.go | 24 +- pkg/{node => visor}/config_test.go | 6 +- pkg/{node => visor}/rpc.go | 78 +++--- pkg/{node => visor}/rpc_client.go | 4 +- pkg/{node => visor}/rpc_test.go | 20 +- pkg/{node/node.go => visor/visor.go} | 248 +++++++++--------- .../node_test.go => visor/visor_test.go} | 24 +- 89 files changed, 888 insertions(+), 880 deletions(-) rename cmd/{manager-node => hypervisor}/README.md (57%) rename cmd/{manager-node => hypervisor}/commands/gen-config.go (83%) rename cmd/{manager-node => hypervisor}/commands/root.go (67%) create mode 100644 cmd/hypervisor/hypervisor.go rename cmd/{manager-node/manager-node.postman_collection.json => hypervisor/hypervisor.postman_collection.json} (98%) delete mode 100644 cmd/manager-node/manager-node.go rename cmd/skywire-cli/commands/{node => visor}/app.go (92%) rename cmd/skywire-cli/commands/{node => visor}/gen-config.go (84%) rename cmd/skywire-cli/commands/{node => visor}/pk.go (84%) rename cmd/skywire-cli/commands/{node => visor}/root.go (67%) rename cmd/skywire-cli/commands/{node => visor}/routes.go (94%) rename cmd/skywire-cli/commands/{node => visor}/transports.go (93%) delete mode 100644 cmd/skywire-node/skywire-node.go rename cmd/{skywire-node => visor}/commands/root.go (83%) rename cmd/{skywire-node => visor}/config.json (98%) create mode 100644 cmd/visor/visor.go rename integration/generic/{nodeA.json => visorA.json} (87%) rename integration/generic/{nodeC.json => visorC.json} (86%) rename integration/{intermediary-nodeB.json => intermediary-visorB.json} (84%) rename integration/messaging/{nodeA.json => visorA.json} (85%) rename integration/messaging/{nodeC.json => visorC.json} (83%) rename integration/proxy/{nodeA.json => visorA.json} (84%) rename integration/proxy/{nodeC.json => visorC.json} (83%) rename integration/ssh/{nodeA.json => visorA.json} (87%) rename integration/ssh/{nodeC.json => visorC.json} (86%) delete mode 100755 integration/start-restart-nodeB.sh create mode 100755 integration/start-restart-visorB.sh rename pkg/{manager => hypervisor}/config.go (91%) rename pkg/{manager/node.go => hypervisor/hypervisor.go} (75%) rename pkg/{manager/node_test.go => hypervisor/hypervisor_test.go} (92%) rename pkg/{manager => hypervisor}/user.go (98%) rename pkg/{manager => hypervisor}/user_manager.go (99%) rename pkg/{node => visor}/config.go (90%) rename pkg/{node => visor}/config_test.go (97%) rename pkg/{node => visor}/rpc.go (73%) rename pkg/{node => visor}/rpc_client.go (99%) rename pkg/{node => visor}/rpc_test.go (93%) rename pkg/{node/node.go => visor/visor.go} (56%) rename pkg/{node/node_test.go => visor/visor_test.go} (91%) diff --git a/.gitignore b/.gitignore index b8589c08e5..d02184724a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,15 +9,15 @@ .idea/ -/skywire.json +/visor.json /*-config.json /apps/ /skywire/ /local* -pkg/node/apps/ -pkg/node/bar/ -pkg/node/foo/ +pkg/visor/apps/ +pkg/visor/bar/ +pkg/visor/foo/ /node /users.db @@ -26,4 +26,4 @@ pkg/node/foo/ /*-server /*.json /*.sh -/*.log \ No newline at end of file +/*.log diff --git a/Makefile b/Makefile index 377338bb15..bae5087d5b 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 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 visor on host + ./visor visor.json -stop: ## Stop running skywire-node on host - -bash -c "kill $$(ps aux |grep '[s]kywire-node' |awk '{print $$2}')" +stop: ## Stop running visor on host + -bash -c "kill $$(ps aux |grep '[v]isor' |awk '{print $$2}')" -config: ## Generate skywire.json - -./skywire-cli node gen-config -o ./skywire.json -r +config: ## Generate visor.json + -./skywire-cli visor gen-config -o ./visor.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 ./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 `visor`, `skywire-cli`, `hypervisor`, `SSH-cli` + ${OPTS} go install ./cmd/visor ./cmd/skywire-cli ./cmd/setup-node ./cmd/hypervisor ./cmd/therealssh-cli rerun: stop - ${OPTS} go build -race -o ./skywire-node ./cmd/skywire-node - -./skywire-cli node gen-config -o ./skywire.json -r - perl -pi -e 's/localhost//g' ./skywire.json - ./skywire-node skywire.json + ${OPTS} go build -race -o ./visor ./cmd/visor + -./skywire-cli visor gen-config -o ./visor.json -r + perl -pi -e 's/localhost//g' ./visor.json + ./visor visor.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/visor/... # vendorcheck fails on ./cmd/therealssh-cli # the problem is indirect dependency to github.com/sirupsen/logrus #GO111MODULE=off vendorcheck ./cmd/therealssh-cli/... @@ -66,15 +66,15 @@ test: ## Run tests ${OPTS} go test ${TEST_OPTS} ./pkg/app/... ${OPTS} go test ${TEST_OPTS} ./pkg/cipher/... ${OPTS} go test ${TEST_OPTS} ./pkg/dmsg/... - ${OPTS} go test ${TEST_OPTS} ./pkg/manager/... + ${OPTS} go test ${TEST_OPTS} ./pkg/hypervisor/... ${OPTS} go test ${TEST_OPTS} ./pkg/messaging-discovery/... - ${OPTS} go test ${TEST_OPTS} ./pkg/node/... ${OPTS} go test ${TEST_OPTS} ./pkg/route-finder/... ${OPTS} go test ${TEST_OPTS} ./pkg/router/... ${OPTS} go test ${TEST_OPTS} ./pkg/routing/... ${OPTS} go test ${TEST_OPTS} ./pkg/setup/... ${OPTS} go test ${TEST_OPTS} ./pkg/transport/... ${OPTS} go test ${TEST_OPTS} ./pkg/transport-discovery/... + ${OPTS} go test ${TEST_OPTS} ./pkg/visor/... ${OPTS} go test -tags no_ci -cover -timeout=5m ./pkg/messaging/... @@ -104,21 +104,21 @@ 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 `hypervisor`, `skywire-cli`, `SSH-cli`, `visor` + ${OPTS} go build ${BUILD_OPTS} -o ./hypervisor ./cmd/hypervisor + ${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 ./SSH-cli ./cmd/therealssh-cli + ${OPTS} go build ${BUILD_OPTS} -o ./visor ./cmd/visor -release: ## Build skywire-node`, skywire-cli, manager-node, SSH-cli and apps without -race flag - ${OPTS} go build -o ./skywire-node ./cmd/skywire-node +release: ## Build `hypervisor`, `skywire-cli`, `SSH-cli`, `visor` and apps without -race flag + ${OPTS} go build -o ./hypervisor ./cmd/hypervisor ${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 ./SSH-cli ./cmd/therealssh-cli + ${OPTS} go build -o ./visor ./cmd/visor ${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 @@ -126,7 +126,7 @@ release: ## Build skywire-node`, skywire-cli, manager-node, SSH-cli and apps wit ${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 visor docker-image: ## Build docker image `skywire-runner` docker image build --tag=skywire-runner --rm - < skywire-runner.Dockerfile @@ -137,40 +137,40 @@ docker-clean: ## Clean docker system: remove container ${DOCKER_NODE} and networ 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_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 - -${DOCKER_OPTS} go build -race -o ./node/apps/socksproxy-client.v1.0 ./cmd/apps/therealproxy-client - -${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-apps: ## Build apps binaries for dockerized visor. `go build` with ${DOCKER_OPTS} + -${DOCKER_OPTS} go build -race -o ./visor/apps/skychat.v1.0 ./cmd/apps/skychat + -${DOCKER_OPTS} go build -race -o ./visor/apps/helloworld.v1.0 ./cmd/apps/helloworld + -${DOCKER_OPTS} go build -race -o ./visor/apps/socksproxy.v1.0 ./cmd/apps/therealproxy + -${DOCKER_OPTS} go build -race -o ./visor/apps/socksproxy-client.v1.0 ./cmd/apps/therealproxy-client + -${DOCKER_OPTS} go build -race -o ./visor/apps/SSH.v1.0 ./cmd/apps/therealssh + -${DOCKER_OPTS} go build -race -o ./visor/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 `visor`, `skywire-cli`, `visor`, `therealssh-cli`. `go build` with ${DOCKER_OPTS} + ${DOCKER_OPTS} go build -race -o ./visor/visor ./cmd/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 visor -${DOCKER_OPTS} go build -o ./docker/skywire-services/setup-node ./cmd/setup-node - -./skywire-cli node 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 + -./skywire-cli visor gen-config -o ./visor/visor.json -r + perl -pi -e 's/localhost//g' ./visor/visor.json # To make visor 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 -it -v $(shell pwd)/node:/sky --network=${DOCKER_NETWORK} \ - --name=${DOCKER_NODE} ${DOCKER_IMAGE} bash -c "cd /sky && ./skywire-node skywire.json" +docker-run: docker-clean docker-image docker-network docker-volume ## Run dockerized visor ${DOCKER_NODE} in image ${DOCKER_IMAGE} with network ${DOCKER_NETWORK} + docker run -it -v $(shell pwd)/visor:/sky --network=${DOCKER_NETWORK} \ + --name=${DOCKER_NODE} ${DOCKER_IMAGE} bash -c "cd /sky && ./visor visor.json" -docker-setup-node: ## Runs setup-node in detached state in ${DOCKER_NETWORK} +docker-setup-node: ## Runs setup-visor in detached state in ${DOCKER_NETWORK} -docker container rm setup-node -f docker run -d --network=${DOCKER_NETWORK} \ --name=setup-node \ --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 visor ${DOCKER_NODE} -docker container stop ${DOCKER_NODE} docker-rerun: docker-stop - -./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 + -./skywire-cli gen-config -o ./visor/visor.json -r + perl -pi -e 's/localhost//g' ./visor/visor.json # To make visor accessible from outside with skywire-cli + ${DOCKER_OPTS} go build -race -o ./visor/visor ./cmd/visor docker container start -i ${DOCKER_NODE} run-syslog: ## Run syslog-ng in docker. Logs are mounted under /tmp/syslog @@ -180,7 +180,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 'visor's of interactive testing environment ./integration/startup.sh integration-teardown: ## Tears down all saved configs and states of integration executables diff --git a/README.md b/README.md index 0b70d4b351..23db5f1a5a 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 `visor`](#Run-visor) + - [Run `visor` in docker container](#Run-visor-in-docker-container) - [Run `skywire-cli`](#Run-skywire-cli) - [Apps](#Apps) - [Transports](#Transports) @@ -22,19 +22,19 @@ - [$SYSLOG_OPTS](#SYSLOGOPTS) - [Updater](#Updater) - [Running skywire in docker containers](#Running-skywire-in-docker-containers) - - [Run dockerized `skywire-node`](#Run-dockerized-skywire-node) - - [Structure of `./node`](#Structure-of-node) + - [Run dockerized `visor`](#Run-dockerized-visor) + - [Structure of `./visor`](#Structure-of-visor) - [Refresh and restart `SKY01`](#Refresh-and-restart-SKY01) - [Customization of dockers](#Customization-of-dockers) - [1. DOCKER_IMAGE](#1-DOCKERIMAGE) - [2.DOCKER_NETWORK](#2DOCKERNETWORK) - [3. DOCKER_NODE](#3-DOCKERNODE) - [4. DOCKER_OPTS](#4-DOCKEROPTS) - - [Dockerized `skywire-node` recipes](#Dockerized-skywire-node-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) + - [Dockerized `visor` recipes](#Dockerized-visor-recipes) + - [1. Get Public Key of docker-visor](#1-Get-Public-Key-of-docker-visor) + - [2. Get an IP of visor](#2-Get-an-IP-of-visor) - [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 `visors`](#4-Create-new-dockerized-visors) - [5. Env-vars for develoment-/testing- purposes](#5-Env-vars-for-develoment-testing--purposes) - [6. "Hello-Mike-Hello-Joe" test](#6-%22Hello-Mike-Hello-Joe%22-test) @@ -46,19 +46,19 @@ The software is still under heavy development and the current version is intende ## Architecture -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. +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 visors 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 visors, requests the setup of routes and forwards packets for other visors 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. +In order to detach control plane tasks from the network visors, 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 visors. -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 visors. 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. +On the basis of this information the route finder calculates the most efficient route in the network. Visors 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 visor. -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 visor to the Setup Node, which sets the routing rules in all visors along a route. Skywire visors determine, which visors they accept routing rules from, so only a whitelisted visor can send routing rules to a visor 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 visors 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 visors 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. +There are currently two types of transports that visors can use. The messaging transport is a transport between two visors that uses an intermediary messaging server to relay packets between them. The connection to a specific visor and the connection to a messaging server is facilitated by a discovery service, that allows visors to advertise the messaging servers over which they can be contacted. This transport is used by the setup visor to send routing rules and can be used for other applications as well. It allows visors 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. ## Build and run @@ -90,7 +90,7 @@ $ make $ OPTS="GSO111MODULE=on GOOS=linux GOARCH=arm" make ``` -**Install skywire-node, skywire-cli, manager-node and SSH-cli** +**Install visor, skywire-cli, hypervisor and SSH-cli** ```bash $ make install # compiles and installs all binaries @@ -99,19 +99,19 @@ $ make install # compiles and installs all binaries **Generate default json config** ```bash -$ skywire-cli node gen-config +$ skywire-cli visor gen-config ``` -### Run `skywire-node` +### Run `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. +`visor` hosts apps, proxies app's requests to remote visors and exposes communication API that apps can use to implement communication protocols. App binaries are spawned by the visor, communication between visor 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 +visor +$ visor visor-config.json ``` -### Run `skywire-node` in docker container +### Run `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 `visor`. Refer to the help menu for usage: ```bash $ skywire-cli -h @@ -132,8 +132,8 @@ $ 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 -# rtfind Queries the Route Finder for available routes between two nodes +visor +# rtfind Queries the Route Finder for available routes between two visors # tpdisc Queries the Transport Discovery to find transport(s) of given transport ID or edge public key # # Flags: @@ -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 `visor` is up and running with default environment, default apps are run with the configuration specified in `visor-config.json`. Refer to the following for usage of the default apps: - [Chat](/cmd/apps/skychat) - [Hello World](/cmd/apps/helloworld) @@ -154,23 +154,23 @@ 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`. ```bash # Establish transport to `0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881`. -$ skywire-cli node add-tp 0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881 +$ skywire-cli visor add-tp 0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881 # List established transports. -$ skywire-cli node ls-tp +$ skywire-cli visor ls-tp ``` ## App programming API -App is a generic binary that can be executed by the node. On app -startup node will open pair of unix pipes that will be used for -communication between app and node. `app` packages exposes +App is a generic binary that can be executed by the visor. On app +startup visor will open pair of unix pipes that will be used for +communication between app and visor. `app` packages exposes communication API over the pipe. ```golang @@ -179,13 +179,13 @@ communication API over the pipe. // Setup setups app using default pair of pipes func Setup(config *Config) (*App, error) {} -// Accept awaits for incoming loop confirmation request from a Node and +// Accept awaits for incoming loop confirmation request from a Visor and // returns net.Conn for a received loop. func (app *App) Accept() (net.Conn, error) {} // Addr implements net.Addr for App connections. &Addr{PubKey: pk, Port: 12} -// Dial sends create loop request to a Node and returns net.Conn for created loop. +// Dial sends create loop request to a Visor and returns net.Conn for created loop. func (app *App) Dial(raddr *Addr) (net.Conn, error) {} // Close implements io.Closer for App. @@ -242,7 +242,7 @@ E.g. $ make run_syslog ## run syslog-ng in docker container with logs mounted to /tmp/syslog $ export SYSLOG_OPTS='--syslog localhost:514' $ make integration-run-messaging ## or other integration-run-* goal -$ sudo cat /tmp/syslog/messages ## collected logs from NodeA, NodeB, NodeC instances +$ sudo cat /tmp/syslog/messages ## collected logs from VisorA, VisorB, VisorC instances ``` ## Updater @@ -251,9 +251,9 @@ This software comes with an updater, which is located in this repo: https://gith ## Running skywire in docker containers -There are two make goals for running in development environment dockerized `skywire-node`. +There are two make goals for running in development environment dockerized `visor`. -### Run dockerized `skywire-node` +### Run dockerized `visor` ```bash $ make docker-run @@ -261,16 +261,16 @@ $ make docker-run This will: -- create docker image `skywire-runner` for running `skywire-node` +- create docker image `skywire-runner` for running `visor` - create docker network `SKYNET` (can be customized) -- create docker volume ./node with linux binaries and apps +- create docker volume ./visor with linux binaries and apps - create container `SKY01` and starts it (can be customized) -#### Structure of `./node` +#### Structure of `./visor` ``` -./node -├── apps # node `apps` compiled with DOCKER_OPTS +./visor +├── apps # visor `apps` compiled with DOCKER_OPTS │   ├── skychat.v1.0 # │   ├── helloworld.v1.0 # │   ├── socksproxy-client.v1.0 # @@ -278,45 +278,45 @@ This will: │   ├── SSH-client.v1.0 # │   └── SSH.v1.0 # ├── local # **Created inside docker** -│   ├── skychat # according to "local_path" in skywire-config.json +│   ├── skychat # according to "local_path" in visor-config.json │   ├── socksproxy # │   └── SSH # -├── PK # contains public key of node +├── PK # contains public key of visor ├── skywire # db & logs. **Created inside docker** │   ├── routing.db # │   └── transport_logs # -├── skywire-config.json # config of node -└── skywire-node # `skywire-node binary` compiled with DOCKER_OPTS +├── visor-config.json # config of visor +└── visor # `visor binary` compiled with DOCKER_OPTS ``` -Directory `./node` is mounted as docker volume for `skywire-node` container. +Directory `./visor` is mounted as docker volume for `visor` container. Inside docker container it is mounted on `/sky` -Structure of `./node` partially replicates structure of project root directory. +Structure of `./visor` partially replicates structure of project root directory. Note that files created inside docker container has ownership `root:root`, -so in case you want to `rm -rf ./node` (or other file operations) - you will need `sudo` it. +so in case you want to `rm -rf ./visor` (or other file operations) - you will need `sudo` it. -Look at "Recipes: Creating new dockerized node" for further details. +Look at "Recipes: Creating new dockerized visor" for further details. ### Refresh and restart `SKY01` ```bash -$ make refresh-node +$ make refresh-visor ``` This will: - - stops running node - - recompiles `skywire-node` for container - - start node again + - stops running visor + - recompiles `visor` for container + - start visor again ### Customization of dockers #### 1. DOCKER_IMAGE -Docker image for running `skywire-node`. +Docker image for running `visor`. Default value: `skywire-runner` (built with `make docker-image`) @@ -329,13 +329,13 @@ DOCKER_IMAGE=golang make docker-run #buildpack-deps:stretch-scm is OK too #### 2.DOCKER_NETWORK -Name of virtual network for `skywire-node` +Name of virtual network for `visor` Default value: SKYNET #### 3. DOCKER_NODE -Name of container for `skywire-node` +Name of container for `visor` Default value: SKY01 @@ -345,16 +345,16 @@ Default value: SKY01 Default value: "GO111MODULE=on GOOS=linux" -### Dockerized `skywire-node` recipes +### Dockerized `visor` recipes -#### 1. Get Public Key of docker-node +#### 1. Get Public Key of docker-visor ```bash -$ cat ./node/skywire-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ' +$ cat ./visor/visor.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ' # 029be6fa68c13e9222553035cc1636d98fb36a888aa569d9ce8aa58caa2c651b45 ``` -#### 2. Get an IP of node +#### 2. Get an IP of visor ```bash $ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01 @@ -367,37 +367,37 @@ $ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' S $ firefox http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01):8000 ``` -#### 4. Create new dockerized `skywire-nodes` +#### 4. Create new dockerized `visors` -In case you need more dockerized nodes or maybe it's needed to customize node -let's look how to create new node. +In case you need more dockerized visors or maybe it's needed to customize visor +let's look how to create new visor. ```bash # 1. We need a folder for docker volume -$ mkdir /tmp/SKYNODE -# 2. compile `skywire-node` -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/skywire-node ./cmd/skywire-node +$ mkdir /tmp/SKYVISOR +visor +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/visor ./cmd/visor # 3. compile apps -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/skychat.v1.0 ./cmd/apps/skychat -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/helloworld.v1.0 ./cmd/apps/helloworld -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/socksproxy.v1.0 ./cmd/apps/therealproxy -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/SSH.v1.0 ./cmd/apps/SSH -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/SSH-client.v1.0 ./cmd/apps/SSH-client -# 4. Create skywire-config.json for node -$ skywire-cli node gen-config -o /tmp/SKYNODE/skywire-config.json +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/apps/skychat.v1.0 ./cmd/apps/skychat +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/apps/helloworld.v1.0 ./cmd/apps/helloworld +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/apps/socksproxy.v1.0 ./cmd/apps/therealproxy +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/apps/SSH.v1.0 ./cmd/apps/SSH +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/apps/SSH-client.v1.0 ./cmd/apps/SSH-client +visor +$ skywire-cli visor gen-config -o /tmp/SKYVISOR/visor-config.json # 2019/03/15 16:43:49 Done! -$ tree /tmp/SKYNODE -# /tmp/SKYNODE +$ tree /tmp/SKYVISOR +# /tmp/SKYVISOR # ├── apps # │   ├── skychat.v1.0 # │   ├── helloworld.v1.0 # │   ├── socksproxy.v1.0 # │   ├── SSH-client.v1.0 # │   └── SSH.v1.0 -# ├── skywire-config.json -# └── skywire-node +# ├── visor-config.json +visor # So far so good. We prepared docker volume. Now we can: -$ docker run -it -v /tmp/SKYNODE:/sky --network=SKYNET --name=SKYNODE skywire-runner bash -c "cd /sky && ./skywire-node" +$ docker run -it -v /tmp/SKYVISOR:/sky --network=SKYNET --name=SKYVISOR skywire-runner bash -c "visor" # [2019-03-15T13:55:08Z] INFO [messenger]: Opened new link with the server # 02a49bc0aa1b5b78f638e9189be4ed095bac5d6839c828465a8350f80ac07629c0 # [2019-03-15T13:55:08Z] INFO [messenger]: Updating discovery entry # [2019-03-15T13:55:10Z] INFO [skywire]: Connected to messaging servers @@ -427,10 +427,10 @@ Instead of skywire-runner you can use: #### 5. Env-vars for develoment-/testing- purposes ```bash -export SW_NODE_A=127.0.0.1 -export SW_NODE_A_PK=$(cat ./skywire-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ') -export SW_NODE_B=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01) -export SW_NODE_B_PK=$(cat ./node/skywire-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ') +export SW_VISOR_A=127.0.0.1 +export SW_VISOR_A_PK=$(cat ./visor-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ') +export SW_VISOR_B=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01) +export SW_VISOR_B_PK=$(cat ./visor/visor-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ') ``` #### 6. "Hello-Mike-Hello-Joe" test @@ -438,17 +438,17 @@ export SW_NODE_B_PK=$(cat ./node/skywire-config.json|grep static_public_key |cut Idea of test from Erlang classics: https://youtu.be/uKfKtXYLG78?t=120 ```bash -# Setup: run skywire-nodes on host and in docker +# Setup: run visors on host and in docker $ make run $ make docker-run # Open in browser skychat application -$ firefox http://$SW_NODE_B:8000 & +$ firefox http://$SW_VISOR_B:8000 & # add transport -$ ./skywire-cli add-transport $SW_NODE_B_PK +$ ./skywire-cli add-transport $SW_VISOR_B_PK # "Hello Mike!" - "Hello Joe!" - "System is working!" -$ curl --data {'"recipient":"'$SW_NODE_A_PK'", "message":"Hello Mike!"}' -X POST http://$SW_NODE_B:8000/message -$ curl --data {'"recipient":"'$SW_NODE_B_PK'", "message":"Hello Joe!"}' -X POST http://$SW_NODE_A:8000/message -$ curl --data {'"recipient":"'$SW_NODE_A_PK'", "message":"System is working!"}' -X POST http://$SW_NODE_B:8000/message +$ curl --data {'"recipient":"'$SW_VISOR_A_PK'", "message":"Hello Mike!"}' -X POST http://$SW_VISOR_B:8000/message +$ curl --data {'"recipient":"'$SW_VISOR_B_PK'", "message":"Hello Joe!"}' -X POST http://$SW_VISOR_A:8000/message +$ curl --data {'"recipient":"'$SW_VISOR_A_PK'", "message":"System is working!"}' -X POST http://$SW_VISOR_B:8000/message # Teardown $ make stop && make docker-stop ``` diff --git a/ROADMAP.md b/ROADMAP.md index e7e48f9e6d..3855908d6f 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -5,7 +5,7 @@ This document defines a high level roadmap for Skywire mainnet development. It d - [ ] Implement bandwidth settlement system for monetization of network services - [ ] Integrate Coin Hour Bank / CoinJoin with the settlement system - [ ] Integrate the new manager interface with the manager backend -- [ ] Add support for remote management of unlimited nodes via messaging system +- [ ] Add support for remote management of unlimited visors via messaging system - [ ] Integrate CXO with Skywire - [ ] Create service discovery for peer discovery - [ ] Document the software and provide tutorials and help for developing applications using Skywire and to contribute to the development diff --git a/ci_scripts/run-pkg-tests.sh b/ci_scripts/run-pkg-tests.sh index f782b6960c..87de4cb384 100644 --- a/ci_scripts/run-pkg-tests.sh +++ b/ci_scripts/run-pkg-tests.sh @@ -20,7 +20,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/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 TestNew >> ./logs/pkg/TestNewHyperVisor.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestChannelRead >> ./logs/pkg/TestChannelRead.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestChannelWrite >> ./logs/pkg/TestChannelWrite.log @@ -54,20 +54,20 @@ 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/messaging-discovery/client -run TestCopy>> ./logs/pkg/TestCopy.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 -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestTransportLogStore >> ./logs/pkg/TestTransportLogStore.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestRoutingTable >> ./logs/pkg/TestRoutingTable.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestAppsConfig >> ./logs/pkg/TestAppsConfig.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestAppsDir >> ./logs/pkg/TestAppsDir.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestLocalDir >> ./logs/pkg/TestLocalDir.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -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 TestNodeStartClose >> ./logs/pkg/TestNodeStartClose.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestNodeSpawnApp >> ./logs/pkg/TestNodeSpawnApp.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestNodeSpawnAppValidations >> ./logs/pkg/TestNodeSpawnAppValidations.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestListApps >> ./logs/pkg/TestListApps.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestStartStopApp >> ./logs/pkg/TestStartStopApp.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestRPC >> ./logs/pkg/TestRPC.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -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/visor -run TestTransportDiscovery >> ./logs/pkg/TestTransportDiscovery.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestTransportLogStore >> ./logs/pkg/TestTransportLogStore.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestRoutingTable >> ./logs/pkg/TestRoutingTable.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestAppsConfig >> ./logs/pkg/TestAppsConfig.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestAppsDir >> ./logs/pkg/TestAppsDir.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestLocalDir >> ./logs/pkg/TestLocalDir.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestNew >> ./logs/pkg/TestNewVisor.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestVisorStartClose >> ./logs/pkg/TestVisorStartClose.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestVisorSpawnApp >> ./logs/pkg/TestVisorSpawnApp.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestVisorSpawnAppValidations >> ./logs/pkg/TestVisorSpawnAppValidations.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestListApps >> ./logs/pkg/TestListApps.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestStartStopApp >> ./logs/pkg/TestStartStopApp.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestRPC >> ./logs/pkg/TestRPC.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerInit >> ./logs/pkg/TestAppManagerInit.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerSetupLoop >> ./logs/pkg/TestAppManagerSetupLoop.log diff --git a/cmd/apps/helloworld/helloworld.go b/cmd/apps/helloworld/helloworld.go index dfc79581d7..b6b5801e5a 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 @@ -35,7 +35,7 @@ func main() { log.Printf("Message from %s: %s", conn.RemoteAddr().String(), string(buf)) if _, err := conn.Write([]byte("pong")); err != nil { - log.Println("Failed to write to a remote node: ", err) + log.Println("Failed to write to a remote visor: ", err) } }() } @@ -52,7 +52,7 @@ func main() { } if _, err := conn.Write([]byte("ping")); err != nil { - log.Fatal("Failed to write to a remote node: ", err) + log.Fatal("Failed to write to a remote visor: ", err) } buf := make([]byte, 4) diff --git a/cmd/apps/skychat/README.md b/cmd/apps/skychat/README.md index 66aed3b624..742356675f 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 visors. Messaging UI is exposed via web interface. @@ -8,11 +8,12 @@ Chat only supports one WEB client user at a time. ## Local setup -Create 2 node config files: +Create 2 visor config files: -`skywire1.json` +`visor1.json` ```json +{ "apps": [ { "app": "skychat", @@ -21,11 +22,13 @@ Create 2 node config files: "port": 1 } ] +} ``` -`skywire2.json` +`visor2.json` ```json +{ "apps": [ { "app": "skychat", @@ -35,14 +38,15 @@ Create 2 node config files: "args": ["-addr", ":8001"] } ] +} ``` -Compile binaries and start 2 nodes: +Compile binaries and start 2 visors: ```bash $ go build -o apps/skychat.v1.0 ./cmd/apps/skychat -$ ./skywire-node skywire1.json -$ ./skywire-node skywire2.json +$ ./visor visor1.json +$ ./visor visor2.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 7f475d8bb7..80224c12c9 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/README.md b/cmd/apps/therealproxy-client/README.md index 7d8d7d9951..e6db78e4e5 100644 --- a/cmd/apps/therealproxy-client/README.md +++ b/cmd/apps/therealproxy-client/README.md @@ -2,7 +2,7 @@ `socksproxy-client` app implements client for the SOCKS5 app. -It opens persistent `skywire` connection to the configured remote node +It opens persistent `skywire` connection to the configured remote visor and local TCP port, all incoming TCP traffics is forwarded to the ~skywire~ connection. diff --git a/cmd/apps/therealproxy-client/therealproxy-client.go b/cmd/apps/therealproxy-client/therealproxy-client.go index 5e8a4ff9a4..eb1ab3c0f2 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..63aa827fe7 100644 --- a/cmd/apps/therealproxy/README.md +++ b/cmd/apps/therealproxy/README.md @@ -10,11 +10,12 @@ If none are provided, the server does not require authentication. ## Local setup -Create 2 node config files: +Create 2 visor config files: -- `skywire1.json` +- `visor1.json` ```json +{ "apps": [ { "app": "socksproxy", @@ -24,11 +25,13 @@ Create 2 node config files: "args": ["-passcode", "123456"] } ] +} ``` -- `skywire2.json` +- `visor2.json` ```json +{ "apps": [ { "app": "socksproxy-client", @@ -38,18 +41,19 @@ Create 2 node config files: "args": ["-srv", "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7"] } ] +} ``` -Compile binaries and start 2 nodes: +Compile binaries and start 2 visors: ```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 +$ ./visor visor1.json +$ ./visor visor2.json ``` -You should be able to connect to a secondary node via `curl`: +You should be able to connect to a secondary visor via `curl`: ```sh $ curl -v -x socks5://123456:@localhost:1080 https://api.ipify.org 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/README.md b/cmd/apps/therealssh-client/README.md index 3aaec45251..84e33d5363 100644 --- a/cmd/apps/therealssh-client/README.md +++ b/cmd/apps/therealssh-client/README.md @@ -3,6 +3,6 @@ `SSH-client` app implements client for the SSH app. It starts RCP interface for `SSH-cli` and handles incoming requests to -the remote node via `skywire` connection. +the remote visor via `skywire` connection. Please check docs for `SSH` app for further instructions. 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..62f5dfa261 100644 --- a/cmd/apps/therealssh/README.md +++ b/cmd/apps/therealssh/README.md @@ -15,11 +15,12 @@ authentication file (`$HOME/.therealssh/authorized_keys` by default). ** Local setup -Create 2 node config files: +Create 2 visor config files: -`skywire1.json` +`visor1.json` ```json +{ "apps": [ { "app": "SSH", @@ -28,11 +29,13 @@ Create 2 node config files: "port": 2 } ] +} ``` -`skywire2.json` +`visor2.json` ```json +{ "apps": [ { "app": "SSH-client", @@ -41,26 +44,27 @@ Create 2 node config files: "port": 22 } ] +} ``` -Compile binaries and start 2 nodes: +Compile binaries and start 2 visors: ```bash $ 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 +$ ./visor visor1.json +$ ./visor visor2.json ``` -Add public key of the second node to the auth file: +Add public key of the second visor 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: +Connect to the first visor using CLI: ```bash $ ./SSH-cli 024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7 diff --git a/cmd/apps/therealssh/therealssh.go b/cmd/apps/therealssh/therealssh.go index 69e813baa0..57f20f3c9b 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 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..e8cd464a3e 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 visor 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 67% rename from cmd/manager-node/commands/root.go rename to cmd/hypervisor/commands/root.go index b52e6fbb0e..777b222e54 100644 --- a/cmd/manager-node/commands/root.go +++ b/cmd/hypervisor/commands/root.go @@ -9,37 +9,37 @@ 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 - mockNodes int + mockVisors int mockMaxTps int mockMaxRoutes int ) 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") - rootCmd.Flags().IntVar(&mockMaxRoutes, "mock-max-routes", 30, "max number of routes per node") + rootCmd.Flags().IntVar(&mockVisors, "mock-visors", 5, "number of app visors to have in mock mode") + rootCmd.Flags().IntVar(&mockMaxTps, "mock-max-tps", 10, "max number of transports per mock app visor") + rootCmd.Flags().IntVar(&mockMaxRoutes, "mock-max-routes", 30, "max number of routes per visor") } var rootCmd = &cobra.Command{ - Use: "manager-node [config-path]", - Short: "Manages Skywire App Nodes", + Use: "hypervisor [config-path]", + Short: "Manages Skywire App Visors", 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.New(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,11 +68,11 @@ var rootCmd = &cobra.Command{ }() if mock { - err := m.AddMockData(manager.MockConfig{ - Nodes: mockNodes, - MaxTpsPerNode: mockMaxTps, - MaxRoutesPerNode: mockMaxRoutes, - EnableAuth: mockEnableAuth, + err := m.AddMockData(hypervisor.MockConfig{ + Visors: mockVisors, + MaxTpsPerVisor: mockMaxTps, + MaxRoutesPerVisor: mockMaxRoutes, + EnableAuth: mockEnableAuth, }) if err != nil { log.Fatalln("Failed to add mock data:", err) @@ -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..7cee2c9723 --- /dev/null +++ b/cmd/hypervisor/hypervisor.go @@ -0,0 +1,10 @@ +/* +skywire management visor +*/ +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 98% rename from cmd/manager-node/manager-node.postman_collection.json rename to cmd/hypervisor/hypervisor.postman_collection.json index 776f84d8b7..68fc3d5604 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": [ @@ -26,7 +26,7 @@ "nodes" ] }, - "description": "Provides a summary of all connected app nodes." + "description": "Provides a summary of all connected app visors." }, "response": [ { @@ -102,7 +102,7 @@ } ] }, - "description": "Provides a summary of a given connected app node of public key." + "description": "Provides a summary of a given connected visor of public key." }, "response": [ { @@ -180,7 +180,7 @@ "apps" ] }, - "description": "Provides a summary of an AppNode's apps." + "description": "Provides a summary of an Visor's apps." }, "response": [ { @@ -253,7 +253,7 @@ "foo.v1.0" ] }, - "description": "Starts an app on an AppNode." + "description": "Starts an app on an Visor." }, "response": [ { @@ -335,7 +335,7 @@ "foo.v1.0" ] }, - "description": "Starts an app on an AppNode." + "description": "Starts an app on an Visor." }, "response": [ { @@ -415,7 +415,7 @@ "transport-types" ] }, - "description": "Lists supported transport types of the given AppNode." + "description": "Lists supported transport types of the given Visor." }, "response": [ { @@ -494,7 +494,7 @@ } ] }, - "description": "List transports of given AppNode." + "description": "List transports of given Visor." }, "response": [ { @@ -580,7 +580,7 @@ "transports" ] }, - "description": "Adds a transport to a given AppNode." + "description": "Adds a transport to a given Visor." }, "response": [ { @@ -660,7 +660,7 @@ "70836b44-f6e5-4c17-a5e8-e1cbef89a10f" ] }, - "description": "Obtains summary of transport of given TransportID and AppNode." + "description": "Obtains summary of transport of given TransportID and Visor." }, "response": [ { @@ -734,7 +734,7 @@ "d5ace20e-06c8-4867-bda2-9449459a9e5a" ] }, - "description": "Removes transport of given TransportID and AppNode." + "description": "Removes transport of given TransportID and Visor." }, "response": [ { @@ -785,4 +785,4 @@ ] } ] -} \ No newline at end of file +} 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/setup-node/commands/root.go b/cmd/setup-node/commands/root.go index 4c94e34d44..f365c86432 100644 --- a/cmd/setup-node/commands/root.go +++ b/cmd/setup-node/commands/root.go @@ -82,7 +82,7 @@ var rootCmd = &cobra.Command{ func init() { rootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", ":2121", "address to bind metrics API to") rootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514") - rootCmd.Flags().StringVar(&tag, "tag", "setup-node", "logging tag") + rootCmd.Flags().StringVar(&tag, "tag", "setup-visor", "logging tag") rootCmd.Flags().BoolVarP(&cfgFromStdin, "stdin", "i", false, "read config from STDIN") } diff --git a/cmd/skywire-cli/commands/mdisc/root.go b/cmd/skywire-cli/commands/mdisc/root.go index 876e8098e9..f6fbc1416b 100644 --- a/cmd/skywire-cli/commands/mdisc/root.go +++ b/cmd/skywire-cli/commands/mdisc/root.go @@ -33,13 +33,13 @@ func init() { } var entryCmd = &cobra.Command{ - Use: "entry ", + Use: "entry ", Short: "fetches an entry from messaging-discovery", Args: cobra.MinimumNArgs(1), Run: func(_ *cobra.Command, args []string) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() - pk := internal.ParsePK("node-public-key", args[0]) + pk := internal.ParsePK("visor-public-key", args[0]) entry, err := client.NewHTTP(mdAddr).Entry(ctx, pk) internal.Catch(err) fmt.Println(entry) diff --git a/cmd/skywire-cli/commands/root.go b/cmd/skywire-cli/commands/root.go index c08a222bc2..0e51e65501 100644 --- a/cmd/skywire-cli/commands/root.go +++ b/cmd/skywire-cli/commands/root.go @@ -4,9 +4,9 @@ import ( "github.com/spf13/cobra" "github.com/skycoin/skywire/cmd/skywire-cli/commands/mdisc" - "github.com/skycoin/skywire/cmd/skywire-cli/commands/node" "github.com/skycoin/skywire/cmd/skywire-cli/commands/rtfind" "github.com/skycoin/skywire/cmd/skywire-cli/commands/tpdisc" + "github.com/skycoin/skywire/cmd/skywire-cli/commands/visor" ) var rootCmd = &cobra.Command{ @@ -16,7 +16,7 @@ var rootCmd = &cobra.Command{ func init() { rootCmd.AddCommand( - node.RootCmd, + visor.RootCmd, mdisc.RootCmd, rtfind.RootCmd, tpdisc.RootCmd, diff --git a/cmd/skywire-cli/commands/rtfind/root.go b/cmd/skywire-cli/commands/rtfind/root.go index cc2c9e8596..3b820e869a 100644 --- a/cmd/skywire-cli/commands/rtfind/root.go +++ b/cmd/skywire-cli/commands/rtfind/root.go @@ -24,8 +24,8 @@ func init() { // RootCmd is the command that queries the route-finder. var RootCmd = &cobra.Command{ - Use: "rtfind ", - Short: "Queries the Route Finder for available routes between two nodes", + Use: "rtfind ", + Short: "Queries the Route Finder for available routes between two visors", Args: cobra.MinimumNArgs(2), Run: func(_ *cobra.Command, args []string) { rfc := client.NewHTTP(frAddr, timeout) diff --git a/cmd/skywire-cli/commands/node/app.go b/cmd/skywire-cli/commands/visor/app.go similarity index 92% rename from cmd/skywire-cli/commands/node/app.go rename to cmd/skywire-cli/commands/visor/app.go index 23d3092341..78afa22727 100644 --- a/cmd/skywire-cli/commands/node/app.go +++ b/cmd/skywire-cli/commands/visor/app.go @@ -1,4 +1,4 @@ -package node +package visor import ( "fmt" @@ -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() { @@ -23,7 +23,7 @@ func init() { var lsAppsCmd = &cobra.Command{ Use: "ls-apps", - Short: "Lists apps running on the local node", + Short: "Lists apps running on the local visor", Run: func(_ *cobra.Command, _ []string) { states, err := rpcClient().Apps() internal.Catch(err) @@ -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/visor/gen-config.go similarity index 84% rename from cmd/skywire-cli/commands/node/gen-config.go rename to cmd/skywire-cli/commands/visor/gen-config.go index c7e88ab89a..27376a16a2 100644 --- a/cmd/skywire-cli/commands/node/gen-config.go +++ b/cmd/skywire-cli/commands/visor/gen-config.go @@ -1,4 +1,4 @@ -package node +package visor import ( "encoding/base64" @@ -9,8 +9,8 @@ import ( "github.com/spf13/cobra" "github.com/skycoin/skywire/pkg/cipher" - "github.com/skycoin/skywire/pkg/node" "github.com/skycoin/skywire/pkg/util/pathutil" + "github.com/skycoin/skywire/pkg/visor" ) func init() { @@ -34,7 +34,7 @@ var genConfigCmd = &cobra.Command{ Short: "Generates a config file", PreRun: func(_ *cobra.Command, _ []string) { if output == "" { - output = pathutil.NodeDefaults().Get(configLocType) + output = pathutil.VisorDefaults().Get(configLocType) log.Infof("No 'output' set; using default path: %s", output) } var err error @@ -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,24 +74,24 @@ 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() - conf.Node.StaticPubKey = pk - conf.Node.StaticSecKey = sk + conf.Visor.StaticPubKey = pk + conf.Visor.StaticSecKey = sk conf.Messaging.Discovery = "https://messaging.discovery.skywire.skycoin.net" 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}}, } - conf.TrustedNodes = []cipher.PubKey{} + conf.TrustedVisors = []cipher.PubKey{} conf.Transport.Discovery = "https://transport.discovery.skywire.skycoin.net" conf.Transport.LogStore.Type = "file" @@ -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/pk.go b/cmd/skywire-cli/commands/visor/pk.go similarity index 84% rename from cmd/skywire-cli/commands/node/pk.go rename to cmd/skywire-cli/commands/visor/pk.go index f87379b9e1..f8ad77114b 100644 --- a/cmd/skywire-cli/commands/node/pk.go +++ b/cmd/skywire-cli/commands/visor/pk.go @@ -1,4 +1,4 @@ -package node +package visor import ( "fmt" @@ -12,7 +12,7 @@ func init() { var pkCmd = &cobra.Command{ Use: "pk", - Short: "Obtains the public key of the node", + Short: "Obtains the public key of the visor", Run: func(_ *cobra.Command, _ []string) { client := rpcClient() diff --git a/cmd/skywire-cli/commands/node/root.go b/cmd/skywire-cli/commands/visor/root.go similarity index 67% rename from cmd/skywire-cli/commands/node/root.go rename to cmd/skywire-cli/commands/visor/root.go index f6fbf18bf8..5dd08bd58a 100644 --- a/cmd/skywire-cli/commands/node/root.go +++ b/cmd/skywire-cli/commands/visor/root.go @@ -1,4 +1,4 @@ -package node +package visor import ( "net/rpc" @@ -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 visor var RootCmd = &cobra.Command{ - Use: "node", - Short: "Contains sub-commands that interact with the local Skywire (App) Node", + Use: "visor", + 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/visor/routes.go similarity index 94% rename from cmd/skywire-cli/commands/node/routes.go rename to cmd/skywire-cli/commands/visor/routes.go index b80c3ab49c..2416f3b516 100644 --- a/cmd/skywire-cli/commands/node/routes.go +++ b/cmd/skywire-cli/commands/visor/routes.go @@ -1,4 +1,4 @@ -package node +package visor import ( "errors" @@ -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() { @@ -28,7 +28,7 @@ func init() { var lsRulesCmd = &cobra.Command{ Use: "ls-rules", - Short: "Lists the local node's routing rules", + Short: "Lists the local visor's routing rules", Run: func(_ *cobra.Command, _ []string) { rules, err := rpcClient().RoutingRules() internal.Catch(err) @@ -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/visor/transports.go similarity index 93% rename from cmd/skywire-cli/commands/node/transports.go rename to cmd/skywire-cli/commands/visor/transports.go index b216e5163c..502322efb4 100644 --- a/cmd/skywire-cli/commands/node/transports.go +++ b/cmd/skywire-cli/commands/visor/transports.go @@ -1,4 +1,4 @@ -package node +package visor import ( "fmt" @@ -13,7 +13,7 @@ import ( "github.com/skycoin/skywire/cmd/skywire-cli/internal" "github.com/skycoin/skywire/pkg/cipher" - "github.com/skycoin/skywire/pkg/node" + "github.com/skycoin/skywire/pkg/visor" ) func init() { @@ -28,7 +28,7 @@ func init() { var lsTypesCmd = &cobra.Command{ Use: "ls-types", - Short: "Lists transport types used by the local node", + Short: "Lists transport types used by the local visor", Run: func(_ *cobra.Command, _ []string) { types, err := rpcClient().TransportTypes() internal.Catch(err) @@ -107,7 +107,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") @@ -124,7 +124,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..489cdf2703 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 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/visor/commands/root.go similarity index 83% rename from cmd/skywire-node/commands/root.go rename to cmd/visor/commands/root.go index 0a2fd686dc..acdd6e0b14 100644 --- a/cmd/skywire-node/commands/root.go +++ b/cmd/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,26 +39,26 @@ type runCfg struct { profileStop func() logger *logging.Logger masterLogger *logging.MasterLogger - conf node.Config - node *node.Node + conf visor.Config + visor *visor.Visor } var cfg *runCfg var rootCmd = &cobra.Command{ - Use: "skywire-node [config-path]", - Short: "App Node for skywire", + Use: "visor [config-path]", + Short: "Visor for skywire", Run: func(_ *cobra.Command, args []string) { cfg.args = args cfg.startProfiler(). startLogger(). readConfig(). - runNode(). + runVisor(). waitOsSignals(). - stopNode() + stopVisor() }, - Version: node.Version, + Version: visor.Version, } func init() { @@ -126,7 +124,7 @@ func (cfg *runCfg) readConfig() *runCfg { var rdr io.Reader var err error if !cfg.cfgFromStdin { - configPath := pathutil.FindConfigPath(cfg.args, 0, configEnv, pathutil.NodeDefaults()) + configPath := pathutil.FindConfigPath(cfg.args, 0, configEnv, pathutil.VisorDefaults()) rdr, err = os.Open(configPath) if err != nil { cfg.logger.Fatalf("Failed to open config: %s", err) @@ -136,37 +134,37 @@ 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) } return cfg } -func (cfg *runCfg) runNode() *runCfg { - node, err := node.NewNode(&cfg.conf, cfg.masterLogger) +func (cfg *runCfg) runVisor() *runCfg { + visor, err := visor.New(&cfg.conf, cfg.masterLogger) if err != nil { - cfg.logger.Fatal("Failed to initialize node: ", err) + cfg.logger.Fatal("Failed to initialize visor: ", err) } go func() { - if err := node.Start(); err != nil { - cfg.logger.Fatal("Failed to start node: ", err) + if err := visor.Start(); err != nil { + cfg.logger.Fatal("Failed to start visor: ", err) } }() if cfg.conf.ShutdownTimeout == 0 { cfg.conf.ShutdownTimeout = defaultShutdownTimeout } - cfg.node = node + cfg.visor = visor return cfg } -func (cfg *runCfg) stopNode() *runCfg { +func (cfg *runCfg) stopVisor() *runCfg { defer cfg.profileStop() - if err := cfg.node.Close(); err != nil { + if err := cfg.visor.Close(); err != nil { if !strings.Contains(err.Error(), "closed") { - cfg.logger.Fatal("Failed to close node: ", err) + cfg.logger.Fatal("Failed to close visor: ", err) } } return cfg diff --git a/cmd/skywire-node/config.json b/cmd/visor/config.json similarity index 98% rename from cmd/skywire-node/config.json rename to cmd/visor/config.json index 72aeb19563..2447e35849 100644 --- a/cmd/skywire-node/config.json +++ b/cmd/visor/config.json @@ -1,6 +1,6 @@ { "version": "1.0", - "node": { + "visor": { "static_public_key": "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7", "static_secret_key": "42bca4df2f3189b28872d40e6c61aacd5e85b8e91f8fea65780af27c142419e5" }, diff --git a/cmd/visor/visor.go b/cmd/visor/visor.go new file mode 100644 index 0000000000..4a6d0c7de8 --- /dev/null +++ b/cmd/visor/visor.go @@ -0,0 +1,12 @@ +/* +skywire visor +*/ +package main + +import ( + "github.com/skycoin/skywire/cmd/visor/commands" +) + +func main() { + commands.Execute() +} diff --git a/integration/InteractiveEnvironments.md b/integration/InteractiveEnvironments.md index 10f3b78bcc..d50c0f1c26 100644 --- a/integration/InteractiveEnvironments.md +++ b/integration/InteractiveEnvironments.md @@ -24,31 +24,31 @@ integration ├── generic # Generic environmnent │   ├── env-vars.sh # -│   ├── nodeA.json # -│   └── nodeC.json # +│   ├── visorA.json # +│   └── visorC.json # ├── messaging # Messaging testing environment │   ├── env-vars.sh # -│   ├── nodeA.json # -│   └── nodeC.json # +│   ├── visorA.json # +│   └── visorC.json # ├── proxy # Proxy testing environment │   ├── env-vars.sh # -│   ├── nodeA.json # -│   └── nodeC.json # +│   ├── visorA.json # +│   └── visorC.json # ├── ssh # ssh testing environment │   ├── env-vars.sh # -│   ├── nodeA.json # -│   └── nodeC.json #S +│   ├── visorA.json # +│   └── visorC.json #S ├── InteractiveEnvironments.md # You're reading it -├── intermediary-nodeB.json # NodeB configurationS +├── intermediary-visorB.json # VisorB 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 -├── start-restart-nodeB.sh # script for restart in cycle NodeB -├── startup.sh # add transports between nodes +├── start-restart-visorB.sh # script for restart in cycle VisorB +├── startup.sh # add transports between visors ├── tear-down.sh # tear down everything ├── test-messaging-loop.sh # Test script for messaging in infinite loop -├── test-messaging.sh # Test one message between NodeA-NodeC, NodeC-NodeA +├── test-messaging.sh # Test one message between VisorA-VisorC, VisorC-VisorA ├── test-proxy.sh # Test script for proxy ├── test-ssh.sh # Test script for ssh ``` @@ -80,9 +80,9 @@ Usage: The generic test environment will define the following: - skywire-services running on localhost -- 3 skywire-nodes: - - NodeA, NodeC running all apps - - NodeB - intermediary node without apps +- 3 visors: + - VisorA, VisorC running all apps + - VisorB - intermediary visor without apps **Run** @@ -90,7 +90,7 @@ The generic test environment will define the following: # Tear down everything $ make integration-teardown -# Start all services and nodes +# Start all services and visors $ make integration-run-generic # Adds pre-defined transports @@ -115,8 +115,8 @@ $ make integration-teardown Instead of `../skywire/skywire-cli --rpc localhost:port [command]`, one can use: -- `CLI_A node ls-tp` - list transports from nodeA -- `CLI_B node add-tp $PK_A` - add transport on nodeB to nodeA +- `CLI_A visor ls-tp` - list transports from visorA +- `CLI_B visor add-tp $PK_A` - add transport on visorB to visorA Consult with `./integration/env-vars.sh` for details. @@ -129,11 +129,11 @@ These tests assume that the generic environment is running (via the aforemention # To be run in the 'shell' tab of tmux. ./integration/test-messaging.sh ``` -- **TEST 2: Test send/receive with unstable NodeB.** - 1. Stop NodeB by switching to the 7th tmux window (`Ctrl+B` & `6`) and sending SIGTERM (`Ctrl-C`). +- **TEST 2: Test send/receive with unstable VisorB.** + 1. Stop VisorB by switching to the 7th tmux window (`Ctrl+B` & `6`) and sending SIGTERM (`Ctrl-C`). 2. Run the following in the same window: ```bash - $ ./integration/start-restart-nodeB.sh + $ ./integration/start-restart-visorB.sh ``` 3. Switch to the `shell` window and run: ```bash @@ -144,22 +144,22 @@ These tests assume that the generic environment is running (via the aforemention The following steps will be performed: -1. copy sw*.json and start-restart-nodeB.sh into skywire directory +1. copy sw*.json and start-restart-visorB.sh into skywire directory 2. Create 9 tmux windows: 1. MSGD: messaging-discovery 2. MSG: messaging-server 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. VisorA: first visor running with generic/visorA.json + 7. VisorB: first visor running with intermediary-visorB.json + 8. VisorC: first visor running with generic/visorC.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 - 2. $PK_A, $PK_B, $PK_C - public keys of node_A, node_B, node_C + 2. $PK_A, $PK_B, $PK_C - public keys of visor_A, visor_B, visor_C 3. $RPC_A, $RPC_B, $RPC_C - `--rpc` param for ../skywire/skywire-cli - 4. $CHAT_A, $CHAT_B - addresses and ports for `skychat`-apps on node_A and node_C + 4. $CHAT_A, $CHAT_B - addresses and ports for `skychat`-apps on visor_A and visor_C 4. Aliases in shell-window: `CLI_A`, `CLI_B`, `CLI_C` ### SSH Test Environment @@ -167,10 +167,10 @@ The following steps will be performed: The SSH Test Environment will define the following: - skywire-services running on localhost -- 3 skywire-nodes: - - NodeA - running `SSH` app - - NodeB - intermediary node without apps - - NodeC - running `SSH-client` app +- 3 visors: + - VisorA - running `SSH` app + - VisorB - intermediary visor without apps + - VisorC - running `SSH-client` app **Run** @@ -181,7 +181,7 @@ $ make integration-teardown # Prerequisite $ echo $PK_C > ~/.therealssh/authorized_keys -# Start all services and nodes +# Start all services and visors $ make integration-run-ssh # Adds pre-defined transports @@ -193,12 +193,12 @@ $ make integration-startup - **TEST 1** 1. Run `./integration/run-ssh-env.sh` - it will run: 1. skywire-services on localhost - 2. NodeA with configured `SSH` app - 3. NodeB - intermediary - 4. NodeC with configured `SSH-client` app + 2. VisorA with configured `SSH` app + 3. VisorB - intermediary + 4. VisorC 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 visors 3. Collect logs 4. Increase n by power of 2 5. Repeat @@ -208,27 +208,27 @@ $ make integration-startup The proxy test environment will define the following: - skywire-services running on localhost -- 3 skywire-nodes: - - NodeA - running `SSH` app - - NodeB - intermediary node without apps - - NodeC - running `SSH-client` app +- 3 visors: + - VisorA - running `SSH` app + - VisorB - intermediary visor without apps + - VisorC - running `SSH-client` app #### Preparation It's really tricky to make socks5 proxy work now from clean start. Because `socksproxy-client` needs: -- transport to NodeA -- NodeA must be running **before** start of `socksproxy-client` +- transport to VisorA +- VisorA must be running **before** start of `socksproxy-client` Recipe for clean start: 1. Run `make integration-teardown` 2. Start `./integration/run-proxy-env.sh` 3. Run `make integration-startup` -4. Stop NodeA, NodeB, NodeC -5. Restart all nodes -6. Wait for message in NodeC logs about successful start of +4. Stop VisorA, VisorB, VisorC +5. Restart all visors +6. Wait for message in VisorC logs about successful start of socksproxy-client 7. Check `lsof -i :9999` that it's really started 8. Check `curl -v --retry 5 --retry-connrefused 1 --connect-timeout 5 -x socks5://123456:@localhost:9999 https://www.google.com` @@ -249,7 +249,7 @@ It's possible that a service could start earlier or later than needed. Examine windows, in case of failed service - restart it (E.g. `KeyUp`-`Enter`) Problem still exists in proxy test environment: - - NodeC cannot start `SSH-client` when NodeA is still starting `SSH` + - VisorC cannot start `SSH-client` when VisorA is still starting `SSH` ### Tmux for new users diff --git a/integration/generic/env-vars.sh b/integration/generic/env-vars.sh index 7a355a47c6..31366e9f2e 100644 --- a/integration/generic/env-vars.sh +++ b/integration/generic/env-vars.sh @@ -1,14 +1,14 @@ # This script needs to be `source`d from bash-compatible shell # E.g. `source ./integration/generic/env-vars.sh` or `. ./integration/generic/env-vars.sh` -export PK_A=$(jq -r ".node.static_public_key" ./integration/generic/nodeA.json) -export RPC_A=$(jq -r ".interfaces.rpc" ./integration/generic/nodeA.json) -export PK_B=$(jq -r ".node.static_public_key" ./integration/intermediary-nodeB.json) -export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-nodeB.json) -export PK_C=$(jq -r ".node.static_public_key" ./integration/generic/nodeC.json) -export RPC_C=$(jq -r ".interfaces.rpc" ./integration/generic/nodeC.json) +export PK_A=$(jq -r ".visor.static_public_key" ./integration/generic/visorA.json) +export RPC_A=$(jq -r ".interfaces.rpc" ./integration/generic/visorA.json) +export PK_B=$(jq -r ".visor.static_public_key" ./integration/intermediary-visorB.json) +export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-visorB.json) +export PK_C=$(jq -r ".visor.static_public_key" ./integration/generic/visorC.json) +export RPC_C=$(jq -r ".interfaces.rpc" ./integration/generic/visorC.json) export CHAT_A=http://localhost:8000/message -export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/generic/nodeC.json)/message +export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/generic/visorC.json)/message alias CLI_A='./skywire-cli --rpc $RPC_A' alias CLI_B='./skywire-cli --rpc $RPC_B' diff --git a/integration/generic/nodeA.json b/integration/generic/visorA.json similarity index 87% rename from integration/generic/nodeA.json rename to integration/generic/visorA.json index e984c6f482..26d95ee16c 100644 --- a/integration/generic/nodeA.json +++ b/integration/generic/visorA.json @@ -1,6 +1,6 @@ { "version": "1.0", - "node": { + "visor": { "static_public_key": "02072dd1e2ccd761e717096e1a264de1d8917e78e3176ca99dbf7ccf7292969845", "static_secret_key": "7073e557aa2308b448525397ea2f45d56c9962c4dcdf82c5fdb5cc02fca0481c" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/nodeA/transport_logs" + "location": "./local/visorA/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/nodeA/routing.db" + "location": "./local/visorA/routing.db" } }, "apps": [ @@ -48,10 +48,10 @@ "args": [] } ], - "trusted_nodes": [], - "manager_nodes": [], + "trusted_visors": [], + "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/nodeA", + "local_path": "./local/visorA", "log_level": "info", "interfaces": { "rpc": "localhost:3436" diff --git a/integration/generic/nodeC.json b/integration/generic/visorC.json similarity index 86% rename from integration/generic/nodeC.json rename to integration/generic/visorC.json index 0b9aa6136a..e8fd8f452e 100644 --- a/integration/generic/nodeC.json +++ b/integration/generic/visorC.json @@ -1,6 +1,6 @@ { "version": "1.0", - "node": { + "visor": { "static_public_key": "02c9ddf5c2ae6a5a2166028dafbc814eff3ec2352f429fb0aa37d96e1aa668f332", "static_secret_key": "5ab3744ab56e4d0b82f9a915e07b8f05d51ec0f16ff8496bd92f4e378ca6c1fc" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/nodeC/transport_logs" + "location": "./local/visorC/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/nodeC/routing.db" + "location": "./local/visorC/routing.db" } }, "apps": [ @@ -48,10 +48,10 @@ "args": ["-srv", "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7"] } ], - "trusted_nodes": [], - "manager_nodes": [], + "trusted_visors": [], + "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/nodeC", + "local_path": "./local/visorC", "log_level": "info", "interfaces": { "rpc": "localhost:3438" diff --git a/integration/intermediary-nodeB.json b/integration/intermediary-visorB.json similarity index 84% rename from integration/intermediary-nodeB.json rename to integration/intermediary-visorB.json index 2d246dc2eb..3d6ad265a0 100644 --- a/integration/intermediary-nodeB.json +++ b/integration/intermediary-visorB.json @@ -1,6 +1,6 @@ { "version": "1.0", - "node": { + "visor": { "static_public_key": "0372ee0a2b99b55906ac33b49704073ab90ab4f395d814d48d597b5b42c39e5c79", "static_secret_key": "5092f14fe18bd7dcd34479c5d26bb3bf68b708ec74a12c4557091e82dd6e6c36" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/nodeB/transport_logs" + "location": "./local/visorB/transport_logs" } }, "routing": { @@ -23,12 +23,12 @@ "route_finder_timeout": "60s", "table": { "type": "boltdb", - "location": "./local/nodeB/routing.db" + "location": "./local/visorB/routing.db" } }, "apps": [], - "trusted_nodes": [], - "manager_nodes": [], + "trusted_visors": [], + "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..2a40809d02 100644 --- a/integration/messaging/env-vars.sh +++ b/integration/messaging/env-vars.sh @@ -1,14 +1,14 @@ # This script needs to be `source`d from bash-compatible shell # E.g. `source ./integration/generic/env-vars.sh` or `. ./integration/messaging/env-vars.sh` -export PK_A=$(jq -r ".node.static_public_key" ./integration/messaging/nodeA.json) -export RPC_A=$(jq -r ".interfaces.rpc" ./integration/messaging/nodeA.json) -export PK_B=$(jq -r ".node.static_public_key" ./integration/intermediary-nodeB.json) -export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-nodeB.json) -export PK_C=$(jq -r ".node.static_public_key" ./integration/messaging/nodeC.json) -export RPC_C=$(jq -r ".interfaces.rpc" ./integration/messaging/nodeC.json) +export PK_A=$(jq -r ".visor.static_public_key" ./integration/messaging/visorA.json) +export RPC_A=$(jq -r ".interfaces.rpc" ./integration/messaging/visorA.json) +export PK_B=$(jq -r ".visor.static_public_key" ./integration/intermediary-visorB.json) +export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-visorB.json) +export PK_C=$(jq -r ".visor.static_public_key" ./integration/messaging/visorC.json) +export RPC_C=$(jq -r ".interfaces.rpc" ./integration/messaging/visorC.json) export CHAT_A=http://localhost:8000/message -export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/messaging/nodeC.json)/message +export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/messaging/visorC.json)/message export MSGD=https://messaging.discovery.skywire.skycoin.net export TRD=https://transport.discovery.skywire.skycoin.net @@ -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='./visor ./integration/messaging/visorA.json --tag VisorA' +alias RUN_B='./visor ./integration/messaging/intermediary-visorB.json --tag VisorB' +alias RUN_C='./visor ./integration/messaging/visorC.json --tag VisorC' echo PK_A: $PK_A echo PK_B: $PK_B diff --git a/integration/messaging/nodeA.json b/integration/messaging/visorA.json similarity index 85% rename from integration/messaging/nodeA.json rename to integration/messaging/visorA.json index 446ec9d2d2..fb5febaef4 100644 --- a/integration/messaging/nodeA.json +++ b/integration/messaging/visorA.json @@ -1,6 +1,6 @@ { "version": "1.0", - "node": { + "visor": { "static_public_key": "02072dd1e2ccd761e717096e1a264de1d8917e78e3176ca99dbf7ccf7292969845", "static_secret_key": "7073e557aa2308b448525397ea2f45d56c9962c4dcdf82c5fdb5cc02fca0481c" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/nodeA/transport_logs" + "location": "./local/visorA/transport_logs" } }, "routing": { @@ -23,7 +23,7 @@ "route_finder_timeout": "60s", "table": { "type": "boltdb", - "location": "./local/nodeA/routing.db" + "location": "./local/visorA/routing.db" } }, "apps": [ @@ -35,11 +35,11 @@ "args": [] } ], - "trusted_nodes": [], - "manager_nodes": [], + "trusted_visors": [], + "hypervisors": [], "apps_path": "./apps", "shutdown_timeout": "30s", - "local_path": "./local/nodeA", + "local_path": "./local/visorA", "log_level": "info", "interfaces": { "rpc": "localhost:3436" diff --git a/integration/messaging/nodeC.json b/integration/messaging/visorC.json similarity index 83% rename from integration/messaging/nodeC.json rename to integration/messaging/visorC.json index 2d41cf3024..4837f44251 100644 --- a/integration/messaging/nodeC.json +++ b/integration/messaging/visorC.json @@ -1,6 +1,6 @@ { "version": "1.0", - "node": { + "visor": { "static_public_key": "02c9ddf5c2ae6a5a2166028dafbc814eff3ec2352f429fb0aa37d96e1aa668f332", "static_secret_key": "5ab3744ab56e4d0b82f9a915e07b8f05d51ec0f16ff8496bd92f4e378ca6c1fc" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/nodeC/transport_logs" + "location": "./local/visorC/transport_logs" } }, "routing": { @@ -23,7 +23,7 @@ "route_finder_timeout": "60s", "table": { "type": "boltdb", - "location": "./local/nodeC/routing.db" + "location": "./local/visorC/routing.db" } }, "apps": [ @@ -35,11 +35,11 @@ "args": ["-addr", ":8001"] } ], - "trusted_nodes": [], - "manager_nodes": [], + "trusted_visors": [], + "hypervisors": [], "apps_path": "./apps", "shutdown_timeout": "30s", - "local_path": "./local/nodeC", + "local_path": "./local/visorC", "log_level": "info", "interfaces": { "rpc": "localhost:3438" diff --git a/integration/proxy/env-vars.sh b/integration/proxy/env-vars.sh index 07a9aca479..ce2f3a838f 100644 --- a/integration/proxy/env-vars.sh +++ b/integration/proxy/env-vars.sh @@ -1,11 +1,11 @@ # This script needs to be `source`d from bash-compatible shell # E.g. `source ./integration/proxy/env-vars.sh` or `. ./integration/proxy/env-vars.sh` -export PK_A=$(jq -r ".node.static_public_key" ./integration/proxy/nodeA.json) -export RPC_A=$(jq -r ".interfaces.rpc" ./integration/proxy/nodeA.json) -export PK_B=$(jq -r ".node.static_public_key" ./integration/intermediary-nodeB.json) -export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-nodeB.json) -export PK_C=$(jq -r ".node.static_public_key" ./integration/proxy/nodeC.json) -export RPC_C=$(jq -r ".interfaces.rpc" ./integration/proxy/nodeC.json) +export PK_A=$(jq -r ".visor.static_public_key" ./integration/proxy/visorA.json) +export RPC_A=$(jq -r ".interfaces.rpc" ./integration/proxy/visorA.json) +export PK_B=$(jq -r ".visor.static_public_key" ./integration/intermediary-visorB.json) +export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-visorB.json) +export PK_C=$(jq -r ".visor.static_public_key" ./integration/proxy/visorC.json) +export RPC_C=$(jq -r ".interfaces.rpc" ./integration/proxy/visorC.json) alias CLI_A='./skywire-cli --rpc $RPC_A' alias CLI_B='./skywire-cli --rpc $RPC_B' @@ -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/visor ./integration/messaging/visorA.json --tag VisorA' +alias RUN_B='go run ./cmd/visor ./integration/intermediary-visorB.json --tag VisorB' +alias RUN_C='go run ./cmd/visor ./integration/messaging/visorC.json --tag VisorC' echo PK_A: $PK_A echo PK_B: $PK_B diff --git a/integration/proxy/nodeA.json b/integration/proxy/visorA.json similarity index 84% rename from integration/proxy/nodeA.json rename to integration/proxy/visorA.json index 28aea37235..b1544c57fa 100644 --- a/integration/proxy/nodeA.json +++ b/integration/proxy/visorA.json @@ -1,6 +1,6 @@ { "version": "1.0", - "node": { + "visor": { "static_public_key": "02072dd1e2ccd761e717096e1a264de1d8917e78e3176ca99dbf7ccf7292969845", "static_secret_key": "7073e557aa2308b448525397ea2f45d56c9962c4dcdf82c5fdb5cc02fca0481c" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/nodeA/transport_logs" + "location": "./local/visorA/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/nodeA/routing.db" + "location": "./local/visorA/routing.db" } }, "apps": [ @@ -34,10 +34,10 @@ "args": [] } ], - "trusted_nodes": [], - "manager_nodes": [], + "trusted_visors": [], + "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/nodeA", + "local_path": "./local/visorA", "log_level": "info", "interfaces": { "rpc": "localhost:3436" diff --git a/integration/proxy/nodeC.json b/integration/proxy/visorC.json similarity index 83% rename from integration/proxy/nodeC.json rename to integration/proxy/visorC.json index b86df4a7b3..9425810c45 100644 --- a/integration/proxy/nodeC.json +++ b/integration/proxy/visorC.json @@ -1,6 +1,6 @@ { "version": "1.0", - "node": { + "visor": { "static_public_key": "02c9ddf5c2ae6a5a2166028dafbc814eff3ec2352f429fb0aa37d96e1aa668f332", "static_secret_key": "5ab3744ab56e4d0b82f9a915e07b8f05d51ec0f16ff8496bd92f4e378ca6c1fc" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/nodeC/transport_logs" + "location": "./local/visorC/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/nodeC/routing.db" + "location": "./local/visorC/routing.db" } }, "apps": [ @@ -34,10 +34,10 @@ "args": ["-srv", "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7"] } ], - "trusted_nodes": [], - "manager_nodes": [], + "trusted_visors": [], + "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/nodeC", + "local_path": "./local/visorC", "log_level": "info", "interfaces": { "rpc": "localhost:3438" diff --git a/integration/run-generic-env.sh b/integration/run-generic-env.sh index 894d0b7e1c..64a0fd8db0 100755 --- a/integration/run-generic-env.sh +++ b/integration/run-generic-env.sh @@ -9,14 +9,14 @@ source ./integration/generic/env-vars.sh 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 rename-window -t skywire VisorA +tmux send-keys -t VisorA -l "./visor ./integration/generic/visorA.json --tag VisorA $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 new-window -t skywire -n VisorB +tmux send-keys -t VisorB -l "./visor ./integration/intermediary-visorB.json --tag VisorB $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 new-window -t skywire -n VisorC +tmux send-keys -t VisorC -l "./visor ./integration/generic/visorC.json --tag VisorC $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..18f296796f 100755 --- a/integration/run-messaging-env.sh +++ b/integration/run-messaging-env.sh @@ -9,14 +9,14 @@ source ./integration/messaging/env-vars.sh 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 rename-window -t skywire VisorA +tmux send-keys -t VisorA -l "./visor ./integration/messaging/visorA.json --tag VisorA $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 new-window -t skywire -n VisorB +tmux send-keys -t VisorB -l "./visor ./integration/intermediary-visorB.json --tag VisorB $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 new-window -t skywire -n VisorC +tmux send-keys -t VisorC -l "./visor ./integration/messaging/visorC.json --tag VisorC $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..1ec59ef2b7 100755 --- a/integration/run-proxy-env.sh +++ b/integration/run-proxy-env.sh @@ -9,14 +9,14 @@ source ./integration/proxy/env-vars.sh 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 rename-window -t skywire VisorA +tmux send-keys -t VisorA -l "./visor ./integration/proxy/visorA.json --tag VisorA $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 new-window -t skywire -n VisorB +tmux send-keys -t VisorB -l "./visor ./integration/intermediary-visorB.json --tag VisorB $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 new-window -t skywire -n VisorC +tmux send-keys -t VisorC -l "./visor ./integration/proxy/visorC.json --tag VisorC $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..2bd3a16bd1 100755 --- a/integration/run-ssh-env.sh +++ b/integration/run-ssh-env.sh @@ -9,14 +9,14 @@ source ./integration/ssh/env-vars.sh 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 rename-window -t skywire VisorA +tmux send-keys -t VisorA -l "./visor ./integration/ssh/visorA.json --tag VisorA $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 new-window -t skywire -n VisorB +tmux send-keys -t VisorB -l "./visor ./integration/intermediary-visorB.json --tag VisorB $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 new-window -t skywire -n VisorC +tmux send-keys -t VisorC -l "./visor ./integration/ssh/visorC.json --tag VisorC $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..e739403175 100644 --- a/integration/ssh/env-vars.sh +++ b/integration/ssh/env-vars.sh @@ -1,11 +1,11 @@ # This script needs to be `source`d from bash-compatible shell # E.g. `source ./integration/ssh/env-vars.sh` or `. ./integration/ssh/env-vars.sh` -export PK_A=$(jq -r ".node.static_public_key" ./integration/ssh/nodeA.json) -export RPC_A=$(jq -r ".interfaces.rpc" ./integration/ssh/nodeA.json) -export PK_B=$(jq -r ".node.static_public_key" ./integration/intermediary-nodeB.json) -export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-nodeB.json) -export PK_C=$(jq -r ".node.static_public_key" ./integration/ssh/nodeC.json) -export RPC_C=$(jq -r ".interfaces.rpc" ./integration/ssh/nodeC.json) +export PK_A=$(jq -r ".visor.static_public_key" ./integration/ssh/visorA.json) +export RPC_A=$(jq -r ".interfaces.rpc" ./integration/ssh/visorA.json) +export PK_B=$(jq -r ".visor.static_public_key" ./integration/intermediary-visorB.json) +export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-visorB.json) +export PK_C=$(jq -r ".visor.static_public_key" ./integration/ssh/visorC.json) +export RPC_C=$(jq -r ".interfaces.rpc" ./integration/ssh/visorC.json) alias CLI_A='./skywire-cli --rpc $RPC_A' alias CLI_B='./skywire-cli --rpc $RPC_B' @@ -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/visor ./integration/messaging/visorA.json --tag VisorA' +alias RUN_B='go run ./cmd/visor ./integration/intermediary-visorB.json --tag VisorB' +alias RUN_C='go run ./cmd/visor ./integration/messaging/visorC.json --tag VisorC' echo PK_A: $PK_A echo PK_B: $PK_B diff --git a/integration/ssh/nodeA.json b/integration/ssh/visorA.json similarity index 87% rename from integration/ssh/nodeA.json rename to integration/ssh/visorA.json index e984c6f482..26d95ee16c 100644 --- a/integration/ssh/nodeA.json +++ b/integration/ssh/visorA.json @@ -1,6 +1,6 @@ { "version": "1.0", - "node": { + "visor": { "static_public_key": "02072dd1e2ccd761e717096e1a264de1d8917e78e3176ca99dbf7ccf7292969845", "static_secret_key": "7073e557aa2308b448525397ea2f45d56c9962c4dcdf82c5fdb5cc02fca0481c" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/nodeA/transport_logs" + "location": "./local/visorA/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/nodeA/routing.db" + "location": "./local/visorA/routing.db" } }, "apps": [ @@ -48,10 +48,10 @@ "args": [] } ], - "trusted_nodes": [], - "manager_nodes": [], + "trusted_visors": [], + "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/nodeA", + "local_path": "./local/visorA", "log_level": "info", "interfaces": { "rpc": "localhost:3436" diff --git a/integration/ssh/nodeC.json b/integration/ssh/visorC.json similarity index 86% rename from integration/ssh/nodeC.json rename to integration/ssh/visorC.json index 0b9aa6136a..e8fd8f452e 100644 --- a/integration/ssh/nodeC.json +++ b/integration/ssh/visorC.json @@ -1,6 +1,6 @@ { "version": "1.0", - "node": { + "visor": { "static_public_key": "02c9ddf5c2ae6a5a2166028dafbc814eff3ec2352f429fb0aa37d96e1aa668f332", "static_secret_key": "5ab3744ab56e4d0b82f9a915e07b8f05d51ec0f16ff8496bd92f4e378ca6c1fc" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/nodeC/transport_logs" + "location": "./local/visorC/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/nodeC/routing.db" + "location": "./local/visorC/routing.db" } }, "apps": [ @@ -48,10 +48,10 @@ "args": ["-srv", "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7"] } ], - "trusted_nodes": [], - "manager_nodes": [], + "trusted_visors": [], + "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/nodeC", + "local_path": "./local/visorC", "log_level": "info", "interfaces": { "rpc": "localhost:3438" diff --git a/integration/start-restart-nodeB.sh b/integration/start-restart-nodeB.sh deleted file mode 100755 index dbf9c0e5de..0000000000 --- a/integration/start-restart-nodeB.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -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 & - echo node starting NodeB - sleep 25 - echo Killing NodeB on $(ps aux |grep "[N]odeB" |awk '{print $2}') - kill $(ps aux |grep "[N]odeB" |awk '{print $2}') - sleep 3 - echo Restarting NodeB -done diff --git a/integration/start-restart-visorB.sh b/integration/start-restart-visorB.sh new file mode 100755 index 0000000000..a6b93c45b8 --- /dev/null +++ b/integration/start-restart-visorB.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +mkdir -p ./logs +echo Press Ctrl-C to exit +for ((;;)) +do + ./bin/visor ./integration/intermediary-visorB.json --tag VisorB 2>> ./logs/visorB.log >> ./logs/visorB.log & + echo visor starting VisorB + sleep 25 + echo Killing VisorB on $(ps aux |grep "[N]odeB" |awk '{print $2}') + kill $(ps aux |grep "[N]odeB" |awk '{print $2}') + sleep 3 + echo Restarting VisorB +done diff --git a/integration/startup.sh b/integration/startup.sh index 1ca41aa4c5..86e9ad2aeb 100755 --- a/integration/startup.sh +++ b/integration/startup.sh @@ -4,12 +4,12 @@ # - inside tmux session created by run-*-env.sh scripts # - or standalone `source ./integration/[name of environment]/env-vars.sh && ./integration/startup.sh` -./skywire-cli --rpc $RPC_A node add-tp $PK_B -./skywire-cli --rpc $RPC_C node add-tp $PK_B +./skywire-cli --rpc $RPC_A visor add-tp $PK_B +./skywire-cli --rpc $RPC_C visor add-tp $PK_B sleep 1 -echo "NodeA Transports:" -./skywire-cli --rpc $RPC_A node ls-tp +echo "VisorA Transports:" +./skywire-cli --rpc $RPC_A visor ls-tp -echo "NodeB Transports:" -./skywire-cli --rpc $RPC_B node ls-tp +echo "VisorB Transports:" +./skywire-cli --rpc $RPC_B visor ls-tp diff --git a/integration/tear-down.sh b/integration/tear-down.sh index 37c685deed..8d80fbafd2 100755 --- a/integration/tear-down.sh +++ b/integration/tear-down.sh @@ -1,9 +1,9 @@ #!/bin/sh -# In case skywire-nodes 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}') +# In case visors are not stopped properly. +kill $(ps aux |grep "[V]isorA" |awk '{print $2}') +kill $(ps aux |grep "[V]isorB" |awk '{print $2}') +kill $(ps aux |grep "[V]isorC" |awk '{print $2}') echo Removing ./local rm -rf ./local diff --git a/integration/test-proxy.sh b/integration/test-proxy.sh index 1c72d0a6f3..c60f5e2945 100755 --- a/integration/test-proxy.sh +++ b/integration/test-proxy.sh @@ -11,21 +11,21 @@ do echo Test with $N requests mkdir -p ./logs/proxy/$N - 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}') + echo Killing visors + echo Killing $(ps aux |grep "[V]isorA\|[V]isorB\|[V]isorC" |awk '{print $2}') + kill $(ps aux |grep "[V]isorA\|[V]isorB\|[V]isorC" |awk '{print $2}') - # This sleep needed to allow clean exit of node + # This sleep needed to allow clean exit of visor 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 & + echo Restarting visorA and VisorB + ./bin/visor ./integration/proxy/visorA.json --tag VisorA &> ./logs/proxy/$N/visorA.log & + ./bin/visor ./integration/intermediary-visorB.json --tag VisorB &> ./logs/proxy/$N/visorB.log & # TODO: improve this sleep sleep 5 - echo Restarting nodeC - ./bin/skywire-node ./integration/proxy/nodeC.json --tag NodeC &> ./logs/proxy/$N/nodeC.log & + echo Restarting visorC + ./bin/visor ./integration/proxy/visorC.json --tag VisorC &> ./logs/proxy/$N/visorC.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..02974472af 100755 --- a/integration/test-ssh.sh +++ b/integration/test-ssh.sh @@ -11,14 +11,14 @@ do echo Test with $N lines mkdir -p ./logs/ssh/$N - echo Killing nodes and SSH-cli - echo Killing $(ps aux |grep "[N]odeA\|[N]odeB\|[N]odeC\|[s]kywire/SSH-cli" |awk '{print $2}') - 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 & + echo Killing visors and SSH-cli + echo Killing $(ps aux |grep "[V]isorA\|[V]isorB\|[V]isorC\|[s]kywire/SSH-cli" |awk '{print $2}') + kill $(ps aux |grep "[V]isorA\|[V]isorB\|[V]isorC\|[s]kywire/SSH-cli" |awk '{print $2}') + + echo Restarting visors + ./bin/visor ./integration/ssh/visorA.json --tag VisorA &> ./logs/ssh/$N/visorA.log & + ./bin/visor ./integration/intermediary-visorB.json --tag VisorB &> ./logs/ssh/$N/visorB.log & + ./bin/visor ./integration/ssh/visorC.json --tag VisorC &> ./logs/ssh/$N/visorC.log & sleep 20 echo Trying SSH-cli diff --git a/internal/noise/net.go b/internal/noise/net.go index 26dc525e27..1f835c7050 100644 --- a/internal/noise/net.go +++ b/internal/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 diff --git a/internal/therealssh/client.go b/internal/therealssh/client.go index bec4631c09..f74b1dc733 100644 --- a/internal/therealssh/client.go +++ b/internal/therealssh/client.go @@ -22,7 +22,7 @@ import ( var r = netutil.NewRetrier(50*time.Millisecond, 5, 2) -// Dialer dials to a remote node. +// Dialer dials to a remote visor. type Dialer interface { Dial(raddr *app.Addr) (net.Conn, error) } diff --git a/pkg/app/app.go b/pkg/app/app.go index 6081052ff2..fcf98130a1 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -1,5 +1,5 @@ /* -Package app implements app to node communication interface. +Package app implements app to visor communication interface. */ package app @@ -16,10 +16,10 @@ import ( ) const ( - // DefaultIn holds value of inFd for Apps setup via Node + // DefaultIn holds value of inFd for Apps setup via Visor DefaultIn = uintptr(3) - // DefaultOut holds value of outFd for Apps setup via Node + // DefaultOut holds value of outFd for Apps setup via Visor DefaultOut = uintptr(4) ) @@ -107,7 +107,7 @@ func (app *App) Close() error { return app.proto.Close() } -// Accept awaits for incoming loop confirmation request from a Node and +// Accept awaits for incoming loop confirmation request from a Visor and // returns net.Conn for received loop. func (app *App) Accept() (net.Conn, error) { addrs := <-app.acceptChan @@ -123,7 +123,7 @@ func (app *App) Accept() (net.Conn, error) { return newAppConn(out, laddr, raddr), nil } -// Dial sends create loop request to a Node and returns net.Conn for created loop. +// Dial sends create loop request to a Visor and returns net.Conn for created loop. func (app *App) Dial(raddr *Addr) (net.Conn, error) { laddr := &Addr{} err := app.proto.Send(FrameCreateLoop, raddr, laddr) diff --git a/pkg/app/packet.go b/pkg/app/packet.go index aff7522375..573b1f535f 100644 --- a/pkg/app/packet.go +++ b/pkg/app/packet.go @@ -31,7 +31,7 @@ func (l *LoopAddr) String() string { return fmt.Sprintf(":%d <-> %s:%d", l.Port, l.Remote.PubKey, l.Remote.Port) } -// Packet represents message exchanged between App and Node. +// Packet represents message exchanged between App and Visor. type Packet struct { Addr *LoopAddr `json:"addr"` Payload []byte `json:"payload"` diff --git a/pkg/app/protocol.go b/pkg/app/protocol.go index 2df8734935..4bba6fa12a 100644 --- a/pkg/app/protocol.go +++ b/pkg/app/protocol.go @@ -48,7 +48,7 @@ const ( FrameSuccess = 0xff ) -// Protocol implements full-duplex protocol for App to Node communication. +// Protocol implements full-duplex protocol for App to Visor communication. type Protocol struct { rw io.ReadWriteCloser chans *chanList 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 228bbd37eb..985e9ea253 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 75% rename from pkg/manager/node.go rename to pkg/hypervisor/hypervisor.go index 836005e8d4..b77ee6e7cd 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 visor +package hypervisor import ( "encoding/hex" @@ -13,54 +13,53 @@ import ( "sync" "time" - "github.com/skycoin/skycoin/src/util/logging" - "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" "github.com/google/uuid" + "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire/internal/noise" "github.com/skycoin/skywire/pkg/cipher" "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 { +type visorConn struct { Addr *noise.Addr - Client node.RPCClient + Client visor.RPCClient } -// Node manages AppNodes. -type Node struct { - c Config - nodes map[cipher.PubKey]appNodeConn // connected remote nodes. - users *UserManager - mu *sync.RWMutex +// Hypervisor manages Visors. +type Hypervisor struct { + c Config + visors map[cipher.PubKey]visorConn // connected remote visors. + users *UserManager + mu *sync.RWMutex } -// NewNode creates a new Node. -func NewNode(config Config) (*Node, error) { +// New creates a new Hypervisor. +func New(config Config) (*Hypervisor, error) { boltUserDB, err := NewBoltUserStore(config.DBPath) if err != nil { return nil, err } singleUserDB := NewSingleUserStore("admin", boltUserDB) - return &Node{ - c: config, - nodes: make(map[cipher.PubKey]appNodeConn), - users: NewUserManager(singleUserDB, config.Cookies), - mu: new(sync.RWMutex), + return &Hypervisor{ + c: config, + visors: make(map[cipher.PubKey]visorConn), + users: NewUserManager(singleUserDB, config.Cookies), + mu: new(sync.RWMutex), }, nil } -// ServeRPC serves RPC of a Node. -func (m *Node) ServeRPC(lis net.Listener) error { +// ServeRPC serves RPC of a Visor. +func (m *Hypervisor) ServeRPC(lis net.Listener) error { for { conn, err := noise.WrapListener(lis, m.c.PK, m.c.SK, false, noise.HandshakeXK).Accept() if err != nil { @@ -68,9 +67,9 @@ func (m *Node) ServeRPC(lis net.Listener) error { } addr := conn.RemoteAddr().(*noise.Addr) m.mu.RLock() - m.nodes[addr.PK] = appNodeConn{ + m.visors[addr.PK] = visorConn{ Addr: addr, - Client: node.NewRPCClient(rpc.NewClient(conn), node.RPCPrefix), + Client: visor.NewRPCClient(rpc.NewClient(conn), visor.RPCPrefix), } m.mu.RUnlock() } @@ -83,19 +82,19 @@ func (a mockAddr) String() string { return string(a) } // MockConfig configures how mock data is to be added. type MockConfig struct { - Nodes int - MaxTpsPerNode int - MaxRoutesPerNode int - EnableAuth bool + Visors int + MaxTpsPerVisor int + MaxRoutesPerVisor int + EnableAuth bool } -// AddMockData adds mock data to Manager Node. -func (m *Node) AddMockData(config MockConfig) error { +// AddMockData adds mock data to Hypervisor. +func (m *Hypervisor) 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) + for i := 0; i < config.Visors; i++ { + pk, client := visor.NewMockRPCClient(r, config.MaxTpsPerVisor, config.MaxRoutesPerVisor) m.mu.Lock() - m.nodes[pk] = appNodeConn{ + m.visors[pk] = visorConn{ Addr: &noise.Addr{ PK: pk, Addr: mockAddr(fmt.Sprintf("0.0.0.0:%d", i)), @@ -109,7 +108,7 @@ func (m *Node) AddMockData(config MockConfig) error { } // ServeHTTP implements http.Handler -func (m *Node) ServeHTTP(w http.ResponseWriter, req *http.Request) { +func (m *Hypervisor) ServeHTTP(w http.ResponseWriter, req *http.Request) { r := chi.NewRouter() r.Use(middleware.Timeout(time.Second * 30)) r.Use(middleware.Logger) @@ -127,8 +126,8 @@ func (m *Node) ServeHTTP(w http.ResponseWriter, req *http.Request) { } r.Get("/user", m.users.UserInfo()) r.Post("/change-password", m.users.ChangePassword()) - r.Get("/nodes", m.getNodes()) - r.Get("/nodes/{pk}", m.getNode()) + r.Get("/nodes", m.getVisors()) + r.Get("/nodes/{pk}", m.getVisor()) r.Get("/nodes/{pk}/apps", m.getApps()) r.Get("/nodes/{pk}/apps/{app}", m.getApp()) r.Put("/nodes/{pk}/apps/{app}", m.putApp()) @@ -150,19 +149,19 @@ 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. -func (m *Node) getNodes() http.HandlerFunc { +// provides summary of all visors. +func (m *Hypervisor) getVisors() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var summaries []summaryResp m.mu.RLock() - for pk, c := range m.nodes { + for pk, c := range m.visors { 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} + log.Printf("failed to obtain summary from Visor with pk %s. Error: %v", pk, err) + summary = &visor.Summary{PubKey: pk} } summaries = append(summaries, summaryResp{ TCPAddr: c.Addr.Addr.String(), @@ -174,9 +173,9 @@ func (m *Node) getNodes() http.HandlerFunc { } } -// provides summary of single node. -func (m *Node) getNode() http.HandlerFunc { - return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +// provides summary of single visor. +func (m *Hypervisor) getVisor() http.HandlerFunc { + return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { summary, err := ctx.RPC.Summary() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) @@ -189,9 +188,9 @@ func (m *Node) getNode() http.HandlerFunc { }) } -// returns app summaries of a given node of pk -func (m *Node) getApps() http.HandlerFunc { - return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +// returns app summaries of a given visor of pk +func (m *Hypervisor) getApps() http.HandlerFunc { + return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { apps, err := ctx.RPC.Apps() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) @@ -201,14 +200,14 @@ func (m *Node) getApps() http.HandlerFunc { }) } -// returns an app summary of a given node's pk and app name -func (m *Node) getApp() http.HandlerFunc { +// returns an app summary of a given visor's pk and app name +func (m *Hypervisor) getApp() http.HandlerFunc { return m.withCtx(m.appCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { httputil.WriteJSON(w, r, http.StatusOK, ctx.App) }) } -func (m *Node) putApp() http.HandlerFunc { +func (m *Hypervisor) putApp() http.HandlerFunc { return m.withCtx(m.appCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { var reqBody struct { Autostart *bool `json:"autostart,omitempty"` @@ -247,8 +246,8 @@ func (m *Node) putApp() http.HandlerFunc { }) } -func (m *Node) getTransportTypes() http.HandlerFunc { - return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Hypervisor) getTransportTypes() http.HandlerFunc { + return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { types, err := ctx.RPC.TransportTypes() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) @@ -258,8 +257,8 @@ func (m *Node) getTransportTypes() http.HandlerFunc { }) } -func (m *Node) getTransports() http.HandlerFunc { - return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Hypervisor) getTransports() http.HandlerFunc { + return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { var ( qTypes []string qPKs []cipher.PubKey @@ -284,8 +283,8 @@ func (m *Node) getTransports() http.HandlerFunc { }) } -func (m *Node) postTransport() http.HandlerFunc { - return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Hypervisor) postTransport() http.HandlerFunc { + return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { var reqBody struct { Remote cipher.PubKey `json:"remote_pk"` TpType string `json:"transport_type"` @@ -304,13 +303,13 @@ func (m *Node) postTransport() http.HandlerFunc { }) } -func (m *Node) getTransport() http.HandlerFunc { +func (m *Hypervisor) getTransport() http.HandlerFunc { return m.withCtx(m.tpCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { httputil.WriteJSON(w, r, http.StatusOK, ctx.Tp) }) } -func (m *Node) deleteTransport() http.HandlerFunc { +func (m *Hypervisor) deleteTransport() http.HandlerFunc { return m.withCtx(m.tpCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { if err := ctx.RPC.RemoveTransport(ctx.Tp.ID); err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) @@ -337,8 +336,8 @@ func makeRoutingRuleResp(key routing.RouteID, rule routing.Rule, summary bool) r return resp } -func (m *Node) getRoutes() http.HandlerFunc { - return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Hypervisor) getRoutes() http.HandlerFunc { + return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { qSummary, err := httputil.BoolFromQuery(r, "summary", false) if err != nil { httputil.WriteJSON(w, r, http.StatusBadRequest, err) @@ -357,8 +356,8 @@ func (m *Node) getRoutes() http.HandlerFunc { }) } -func (m *Node) postRoute() http.HandlerFunc { - return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Hypervisor) postRoute() http.HandlerFunc { + return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { var summary routing.RuleSummary if err := httputil.ReadJSON(r, &summary); err != nil { httputil.WriteJSON(w, r, http.StatusBadRequest, err) @@ -378,7 +377,7 @@ func (m *Node) postRoute() http.HandlerFunc { }) } -func (m *Node) getRoute() http.HandlerFunc { +func (m *Hypervisor) getRoute() http.HandlerFunc { return m.withCtx(m.routeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { qSummary, err := httputil.BoolFromQuery(r, "summary", true) if err != nil { @@ -394,7 +393,7 @@ func (m *Node) getRoute() http.HandlerFunc { }) } -func (m *Node) putRoute() http.HandlerFunc { +func (m *Hypervisor) putRoute() http.HandlerFunc { return m.withCtx(m.routeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { var summary routing.RuleSummary if err := httputil.ReadJSON(r, &summary); err != nil { @@ -414,7 +413,7 @@ func (m *Node) putRoute() http.HandlerFunc { }) } -func (m *Node) deleteRoute() http.HandlerFunc { +func (m *Hypervisor) deleteRoute() http.HandlerFunc { return m.withCtx(m.routeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { if err := ctx.RPC.RemoveRoutingRule(ctx.RtKey); err != nil { httputil.WriteJSON(w, r, http.StatusNotFound, err) @@ -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{} } @@ -439,8 +438,8 @@ func makeLoopResp(info node.LoopInfo) loopResp { } } -func (m *Node) getLoops() http.HandlerFunc { - return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Hypervisor) getLoops() http.HandlerFunc { + return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { loops, err := ctx.RPC.Loops() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) @@ -458,24 +457,24 @@ func (m *Node) getLoops() http.HandlerFunc { <<< Helper functions >>> */ -func (m *Node) client(pk cipher.PubKey) (*noise.Addr, node.RPCClient, bool) { +func (m *Hypervisor) client(pk cipher.PubKey) (*noise.Addr, visor.RPCClient, bool) { m.mu.RLock() - conn, ok := m.nodes[pk] + conn, ok := m.visors[pk] m.mu.RUnlock() return conn.Addr, conn.Client, ok } type httpCtx struct { - // Node + // Visor 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 @@ -486,7 +485,7 @@ type ( handlerFunc func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) ) -func (m *Node) withCtx(vFunc valuesFunc, hFunc handlerFunc) http.HandlerFunc { +func (m *Hypervisor) withCtx(vFunc valuesFunc, hFunc handlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if rv, ok := vFunc(w, r); ok { hFunc(w, r, rv) @@ -494,7 +493,7 @@ func (m *Node) withCtx(vFunc valuesFunc, hFunc handlerFunc) http.HandlerFunc { } } -func (m *Node) nodeCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { +func (m *Hypervisor) visorCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { pk, err := pkFromParam(r, "pk") if err != nil { httputil.WriteJSON(w, r, http.StatusBadRequest, err) @@ -502,7 +501,7 @@ func (m *Node) nodeCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) } addr, client, ok := m.client(pk) if !ok { - httputil.WriteJSON(w, r, http.StatusNotFound, fmt.Errorf("node of pk '%s' not found", pk)) + httputil.WriteJSON(w, r, http.StatusNotFound, fmt.Errorf("visor of pk '%s' not found", pk)) return nil, false } return &httpCtx{ @@ -512,8 +511,8 @@ func (m *Node) nodeCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) }, true } -func (m *Node) appCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { - ctx, ok := m.nodeCtx(w, r) +func (m *Hypervisor) appCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { + ctx, ok := m.visorCtx(w, r) if !ok { return nil, false } @@ -530,11 +529,11 @@ func (m *Node) appCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { } } httputil.WriteJSON(w, r, http.StatusNotFound, - fmt.Errorf("can not find app of name %s from node %s", appName, ctx.PK)) + fmt.Errorf("can not find app of name %s from visor %s", appName, ctx.PK)) return nil, false } -func (m *Node) tpCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { +func (m *Hypervisor) tpCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { ctx, ok := m.appCtx(w, r) if !ok { return nil, false @@ -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 @@ -558,7 +557,7 @@ func (m *Node) tpCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { return ctx, true } -func (m *Node) routeCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { +func (m *Hypervisor) routeCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { ctx, ok := m.tpCtx(w, r) if !ok { return nil, false diff --git a/pkg/manager/node_test.go b/pkg/hypervisor/hypervisor_test.go similarity index 92% rename from pkg/manager/node_test.go rename to pkg/hypervisor/hypervisor_test.go index 44d2d72dc1..c574402490 100644 --- a/pkg/manager/node_test.go +++ b/pkg/hypervisor/hypervisor_test.go @@ -1,4 +1,4 @@ -package manager +package hypervisor import ( "encoding/json" @@ -33,29 +33,29 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -func TestNewNode(t *testing.T) { +func TestNew(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") defaultMockConfig := func() MockConfig { return MockConfig{ - Nodes: 5, - MaxTpsPerNode: 10, - MaxRoutesPerNode: 10, - EnableAuth: true, + Visors: 5, + MaxTpsPerVisor: 10, + MaxRoutesPerVisor: 10, + EnableAuth: true, } } - startNode := func(mock MockConfig) (string, *http.Client, func()) { - node, err := NewNode(config) + startHypervisor := func(mock MockConfig) (string, *http.Client, func()) { + hypervisor, err := New(config) require.NoError(t, err) - require.NoError(t, node.AddMockData(mock)) + require.NoError(t, hypervisor.AddMockData(mock)) - srv := httptest.NewTLSServer(node) - node.c.Cookies.Domain = srv.Listener.Addr().String() + srv := httptest.NewTLSServer(hypervisor) + hypervisor.c.Cookies.Domain = srv.Listener.Addr().String() client := srv.Client() jar, err := cookiejar.New(&cookiejar.Options{}) @@ -94,7 +94,7 @@ func TestNewNode(t *testing.T) { } t.Run("no_access_without_login", func(t *testing.T) { - addr, client, stop := startNode(defaultMockConfig()) + addr, client, stop := startHypervisor(defaultMockConfig()) defer stop() makeCase := func(method string, uri string, body io.Reader) TestCase { @@ -119,7 +119,7 @@ func TestNewNode(t *testing.T) { }) t.Run("only_admin_account_allowed", func(t *testing.T) { - addr, client, stop := startNode(defaultMockConfig()) + addr, client, stop := startHypervisor(defaultMockConfig()) defer stop() testCases(t, addr, client, []TestCase{ @@ -149,7 +149,7 @@ func TestNewNode(t *testing.T) { }) t.Run("cannot_login_twice", func(t *testing.T) { - addr, client, stop := startNode(defaultMockConfig()) + addr, client, stop := startHypervisor(defaultMockConfig()) defer stop() testCases(t, addr, client, []TestCase{ @@ -190,7 +190,7 @@ func TestNewNode(t *testing.T) { }) t.Run("access_after_login", func(t *testing.T) { - addr, client, stop := startNode(defaultMockConfig()) + addr, client, stop := startHypervisor(defaultMockConfig()) defer stop() testCases(t, addr, client, []TestCase{ @@ -230,7 +230,7 @@ func TestNewNode(t *testing.T) { }) t.Run("no_access_after_logout", func(t *testing.T) { - addr, client, stop := startNode(defaultMockConfig()) + addr, client, stop := startHypervisor(defaultMockConfig()) defer stop() testCases(t, addr, client, []TestCase{ @@ -297,7 +297,7 @@ func TestNewNode(t *testing.T) { // - Login with old password (should fail). // - Login with new password (should succeed). - addr, client, stop := startNode(defaultMockConfig()) + addr, client, stop := startHypervisor(defaultMockConfig()) defer stop() testCases(t, addr, client, []TestCase{ 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 d0654f27c0..394349d657 100644 --- a/pkg/manager/user.go +++ b/pkg/hypervisor/user.go @@ -1,4 +1,4 @@ -package manager +package hypervisor import ( "bytes" @@ -23,7 +23,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/messaging-discovery/client/entry.go b/pkg/messaging-discovery/client/entry.go index 660e2c3cdd..08f5d5b85e 100644 --- a/pkg/messaging-discovery/client/entry.go +++ b/pkg/messaging-discovery/client/entry.go @@ -4,9 +4,8 @@ import ( "encoding/json" "errors" "fmt" - "time" - "strings" + "time" "github.com/skycoin/skywire/pkg/cipher" ) diff --git a/pkg/messaging/factory.go b/pkg/messaging/factory.go index b3c5204e47..84558613f5 100644 --- a/pkg/messaging/factory.go +++ b/pkg/messaging/factory.go @@ -1,6 +1,6 @@ // Package messaging implements messaging communication. Messaging // communication is performed between 2 nodes using intermediate relay -// server, node discovery is performed using messaging discovery. +// server, visor discovery is performed using messaging discovery. package messaging import ( @@ -141,7 +141,7 @@ func (msgFactory *MsgFactory) Accept(ctx context.Context) (transport.Transport, } } -// Dial initiates a Transport with a remote node. +// Dial initiates a Transport with a remote visor. func (msgFactory *MsgFactory) Dial(ctx context.Context, remote cipher.PubKey) (transport.Transport, error) { entry, err := msgFactory.dc.Entry(ctx, remote) if err != nil { diff --git a/pkg/route-finder/client/client.go b/pkg/route-finder/client/client.go index d80abd8167..1a6cfd2c66 100644 --- a/pkg/route-finder/client/client.go +++ b/pkg/route-finder/client/client.go @@ -68,7 +68,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 2f1851fdb7..9d0a2bf5c4 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 ( @@ -42,7 +42,7 @@ type Config struct { SetupNodes []cipher.PubKey } -// Router implements node.PacketRouter. It manages routing table by +// Router implements visor.PacketRouter. It manages routing table by // communicating with setup nodes, forward packets according to local // rules and manages loops for apps. type Router struct { diff --git a/pkg/routing/route.go b/pkg/routing/route.go index 7ba4802102..68f2663eed 100644 --- a/pkg/routing/route.go +++ b/pkg/routing/route.go @@ -21,7 +21,7 @@ func (h Hop) String() string { return fmt.Sprintf("%s -> %s @ %s", h.From, h.To, h.Transport) } -// Route is a succession of transport entries that denotes a path from source node to destination node +// Route is a succession of transport entries that denotes a path from source visor to destination visor type Route []*Hop func (r Route) String() string { diff --git a/pkg/setup/protocol.go b/pkg/setup/protocol.go index 59fbaed18e..87d8270300 100644 --- a/pkg/setup/protocol.go +++ b/pkg/setup/protocol.go @@ -1,4 +1,4 @@ -// Package setup defines setup node protocol. +// Package setup defines setup visor protocol. package setup import ( diff --git a/pkg/transport/manager.go b/pkg/transport/manager.go index fc2b8517c1..f828f87206 100644 --- a/pkg/transport/manager.go +++ b/pkg/transport/manager.go @@ -22,7 +22,7 @@ type ManagerConfig struct { SecKey cipher.SecKey DiscoveryClient DiscoveryClient LogStore LogStore - DefaultNodes []cipher.PubKey // Nodes to automatically connect to + DefaultVisors []cipher.PubKey // Visors to automatically connect to } // Manager manages Transports. @@ -143,9 +143,9 @@ func (tm *Manager) Remote(edges [2]cipher.PubKey) (cipher.PubKey, bool) { return cipher.PubKey{}, false } -// createDefaultTransports created transports to DefaultNodes if they don't exist. +// createDefaultTransports created transports to DefaultVisors if they don't exist. func (tm *Manager) createDefaultTransports(ctx context.Context) { - for _, pk := range tm.config.DefaultNodes { + for _, pk := range tm.config.DefaultVisors { exist := false tm.WalkTransports(func(tr *ManagedTransport) bool { remote, ok := tm.Remote(tr.Edges()) @@ -160,7 +160,7 @@ func (tm *Manager) createDefaultTransports(ctx context.Context) { } _, err := tm.CreateTransport(ctx, pk, "messaging", true) if err != nil { - tm.Logger.Warnf("Failed to establish transport to a node %s: %s", pk, err) + tm.Logger.Warnf("Failed to establish transport to a visor %s: %s", pk, err) } } } @@ -202,7 +202,7 @@ func (tm *Manager) Serve(ctx context.Context) error { return nil } -// CreateTransport begins to attempt to establish transports to the given 'remote' node. +// CreateTransport begins to attempt to establish transports to the given 'remote' visor. func (tm *Manager) CreateTransport(ctx context.Context, remote cipher.PubKey, tpType string, public bool) (*ManagedTransport, error) { return tm.createTransport(ctx, remote, tpType, public) } diff --git a/pkg/transport/tcp_transport.go b/pkg/transport/tcp_transport.go index b2b117e301..63e4858f84 100644 --- a/pkg/transport/tcp_transport.go +++ b/pkg/transport/tcp_transport.go @@ -44,7 +44,7 @@ func (f *TCPFactory) Accept(ctx context.Context) (Transport, error) { return &TCPTransport{conn, [2]cipher.PubKey{f.lpk, rpk}}, nil } -// Dial initiates a Transport with a remote node. +// Dial initiates a Transport with a remote visor. func (f *TCPFactory) Dial(ctx context.Context, remote cipher.PubKey) (Transport, error) { raddr := f.pkt.RemoteAddr(remote) if raddr == nil { diff --git a/pkg/transport/transport.go b/pkg/transport/transport.go index 9b2a1b2e46..693e6e7cd5 100644 --- a/pkg/transport/transport.go +++ b/pkg/transport/transport.go @@ -11,7 +11,7 @@ import ( "github.com/skycoin/skywire/pkg/cipher" ) -// Transport represents communication between two nodes via a single hop. +// Transport represents communication between two visors via a single hop. type Transport interface { // Read implements io.Reader @@ -40,7 +40,7 @@ type Factory interface { // Accept accepts a remotely-initiated Transport. Accept(ctx context.Context) (Transport, error) - // Dial initiates a Transport with a remote node. + // Dial initiates a Transport with a remote visor. Dial(ctx context.Context, remote cipher.PubKey) (Transport, error) // Close implements io.Closer diff --git a/pkg/util/pathutil/configpath.go b/pkg/util/pathutil/configpath.go index a29c0c6207..7bf92effeb 100644 --- a/pkg/util/pathutil/configpath.go +++ b/pkg/util/pathutil/configpath.go @@ -71,25 +71,25 @@ func (dp ConfigPaths) Get(cpType ConfigLocationType) string { return "" } -// NodeDefaults returns the default config paths for skywire-node. -func NodeDefaults() ConfigPaths { +// VisorDefaults returns the default config paths for visor. +func VisorDefaults() ConfigPaths { paths := make(ConfigPaths) if wd, err := os.Getwd(); err == nil { - paths[WorkingDirLoc] = filepath.Join(wd, "skywire-config.json") + paths[WorkingDirLoc] = filepath.Join(wd, "visor-config.json") } - paths[HomeLoc] = filepath.Join(HomeDir(), ".skycoin/skywire/skywire-config.json") - paths[LocalLoc] = "/usr/local/skycoin/skywire/skywire-config.json" + paths[HomeLoc] = filepath.Join(HomeDir(), ".skycoin/visor/visor-config.json") + paths[LocalLoc] = "/usr/local/skycoin/visor/visor-config.json" 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/util/pathutil/homedir.go b/pkg/util/pathutil/homedir.go index 12f205d3b8..9e7500551f 100644 --- a/pkg/util/pathutil/homedir.go +++ b/pkg/util/pathutil/homedir.go @@ -23,8 +23,8 @@ func HomeDir() string { return os.Getenv("HOME") } -// NodeDir returns a path to a directory used to store specific node configuration. Such dir is ~/.skywire/{PK} -func NodeDir(pk cipher.PubKey) string { +// VisorDir returns a path to a directory used to store specific visor configuration. Such dir is ~/.skywire/{PK} +func VisorDir(pk cipher.PubKey) string { return filepath.Join(HomeDir(), ".skycoin", "skywire", pk.String()) } diff --git a/pkg/node/config.go b/pkg/visor/config.go similarity index 90% rename from pkg/node/config.go rename to pkg/visor/config.go index b6b358cc1c..9d90765e98 100644 --- a/pkg/node/config.go +++ b/pkg/visor/config.go @@ -1,4 +1,4 @@ -package node +package visor import ( "encoding/json" @@ -17,14 +17,14 @@ import ( trClient "github.com/skycoin/skywire/pkg/transport-discovery/client" ) -// Config defines configuration parameters for Node. +// Config defines configuration parameters for Visor. type Config struct { Version string `json:"version"` - Node struct { + Visor struct { StaticPubKey cipher.PubKey `json:"static_public_key"` StaticSecKey cipher.SecKey `json:"static_secret_key"` - } `json:"node"` + } `json:"visor"` Messaging struct { Discovery string `json:"discovery"` @@ -51,8 +51,8 @@ type Config struct { Apps []AppConfig `json:"apps"` - TrustedNodes []cipher.PubKey `json:"trusted_nodes"` - ManagerNodes []ManagerConfig `json:"manager_nodes"` + TrustedVisors []cipher.PubKey `json:"trusted_visors"` + Hypervisors []HypervisorConfig `json:"hypervisors"` AppsPath string `json:"apps_path"` LocalPath string `json:"local_path"` @@ -73,8 +73,8 @@ func (c *Config) MessagingConfig() (*messaging.Config, error) { } return &messaging.Config{ - PubKey: c.Node.StaticPubKey, - SecKey: c.Node.StaticSecKey, + PubKey: c.Visor.StaticPubKey, + SecKey: c.Visor.StaticSecKey, Discovery: mClient.NewHTTP(msgConfig.Discovery), Retries: 5, RetryDelay: time.Second, @@ -87,7 +87,7 @@ func (c *Config) TransportDiscovery() (transport.DiscoveryClient, error) { return nil, errors.New("empty transport_discovery") } - return trClient.NewHTTP(c.Transport.Discovery, c.Node.StaticPubKey, c.Node.StaticSecKey) + return trClient.NewHTTP(c.Transport.Discovery, c.Visor.StaticPubKey, c.Visor.StaticSecKey) } // TransportLogStore returns configure transport.LogStore. @@ -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 97% rename from pkg/node/config_test.go rename to pkg/visor/config_test.go index 5ffae77d19..0c85d20b17 100644 --- a/pkg/node/config_test.go +++ b/pkg/visor/config_test.go @@ -1,4 +1,4 @@ -package node +package visor import ( "encoding/json" @@ -20,8 +20,8 @@ import ( func TestMessagingDiscovery(t *testing.T) { pk, sk := cipher.GenerateKeyPair() conf := Config{} - conf.Node.StaticPubKey = pk - conf.Node.StaticSecKey = sk + conf.Visor.StaticPubKey = pk + conf.Visor.StaticSecKey = sk conf.Messaging.Discovery = "skywire.skycoin.net:8001" conf.Messaging.ServerCount = 10 diff --git a/pkg/node/rpc.go b/pkg/visor/rpc.go similarity index 73% rename from pkg/node/rpc.go rename to pkg/visor/rpc.go index affe6c0f49..75cbd63533 100644 --- a/pkg/node/rpc.go +++ b/pkg/visor/rpc.go @@ -1,4 +1,4 @@ -package node +package visor import ( "context" @@ -15,7 +15,7 @@ import ( const ( // RPCPrefix is the prefix used with all RPC calls. - RPCPrefix = "app-node" + RPCPrefix = "app-visor" ) var ( @@ -29,9 +29,9 @@ var ( ErrNotFound = errors.New("not found") ) -// RPC defines RPC methods for Node. +// RPC defines RPC methods for Visor. type RPC struct { - node *Node + visor *Visor } /* @@ -68,31 +68,31 @@ func newTransportSummary(tm *transport.Manager, tp *transport.ManagedTransport, return summary } -// Summary provides a summary of an AppNode. +// Summary provides a summary of an Visor. type Summary struct { PubKey cipher.PubKey `json:"local_pk"` - NodeVersion string `json:"node_version"` + VisorVersion string `json:"visor_version"` AppProtoVersion string `json:"app_protocol_version"` Apps []*AppState `json:"apps"` Transports []*TransportSummary `json:"transports"` RoutesCount int `json:"routes_count"` } -// Summary provides a summary of the AppNode. +// Summary provides a summary of the Visor. func (r *RPC) Summary(_ *struct{}, out *Summary) error { var summaries []*TransportSummary - r.node.tm.WalkTransports(func(tp *transport.ManagedTransport) bool { + r.visor.tm.WalkTransports(func(tp *transport.ManagedTransport) bool { summaries = append(summaries, - newTransportSummary(r.node.tm, tp, false, r.node.router.IsSetupTransport(tp))) + newTransportSummary(r.visor.tm, tp, false, r.visor.router.IsSetupTransport(tp))) return true }) *out = Summary{ - PubKey: r.node.config.Node.StaticPubKey, - NodeVersion: Version, + PubKey: r.visor.config.Visor.StaticPubKey, + VisorVersion: Version, AppProtoVersion: supportedProtocolVersion, - Apps: r.node.Apps(), + Apps: r.visor.Apps(), Transports: summaries, - RoutesCount: r.node.rt.Count(), + RoutesCount: r.visor.rt.Count(), } return nil } @@ -101,20 +101,20 @@ func (r *RPC) Summary(_ *struct{}, out *Summary) error { <<< APP MANAGEMENT >>> */ -// Apps returns list of Apps registered on the Node. +// Apps returns list of Apps registered on the Visor. func (r *RPC) Apps(_ *struct{}, reply *[]*AppState) error { - *reply = r.node.Apps() + *reply = r.visor.Apps() return nil } // StartApp start App with provided name. func (r *RPC) StartApp(name *string, _ *struct{}) error { - return r.node.StartApp(*name) + return r.visor.StartApp(*name) } // StopApp stops App with provided name. func (r *RPC) StopApp(name *string, _ *struct{}) error { - return r.node.StopApp(*name) + return r.visor.StopApp(*name) } // SetAutoStartIn is input for SetAutoStart. @@ -125,16 +125,16 @@ type SetAutoStartIn struct { // SetAutoStart sets auto-start settings for an app. func (r *RPC) SetAutoStart(in *SetAutoStartIn, _ *struct{}) error { - return r.node.SetAutoStart(in.AppName, in.AutoStart) + return r.visor.SetAutoStart(in.AppName, in.AutoStart) } /* <<< TRANSPORT MANAGEMENT >>> */ -// TransportTypes lists all transport types supported by the Node. +// TransportTypes lists all transport types supported by the Visor. func (r *RPC) TransportTypes(_ *struct{}, out *[]string) error { - *out = r.node.tm.Factories() + *out = r.visor.tm.Factories() return nil } @@ -145,7 +145,7 @@ type TransportsIn struct { ShowLogs bool } -// Transports lists Transports of the Node and provides a summary of each. +// Transports lists Transports of the Visor and provides a summary of each. func (r *RPC) Transports(in *TransportsIn, out *[]*TransportSummary) error { typeIncluded := func(tType string) bool { if in.FilterTypes != nil { @@ -169,10 +169,10 @@ func (r *RPC) Transports(in *TransportsIn, out *[]*TransportSummary) error { } return true } - r.node.tm.WalkTransports(func(tp *transport.ManagedTransport) bool { - if remote, ok := r.node.tm.Remote(tp.Edges()); ok { - if typeIncluded(tp.Type()) && pkIncluded(r.node.tm.Local(), remote) { - *out = append(*out, newTransportSummary(r.node.tm, tp, in.ShowLogs, r.node.router.IsSetupTransport(tp))) + r.visor.tm.WalkTransports(func(tp *transport.ManagedTransport) bool { + if remote, ok := r.visor.tm.Remote(tp.Edges()); ok { + if typeIncluded(tp.Type()) && pkIncluded(r.visor.tm.Local(), remote) { + *out = append(*out, newTransportSummary(r.visor.tm, tp, in.ShowLogs, r.visor.router.IsSetupTransport(tp))) } return true } @@ -183,11 +183,11 @@ func (r *RPC) Transports(in *TransportsIn, out *[]*TransportSummary) error { // Transport obtains a Transport Summary of Transport of given Transport ID. func (r *RPC) Transport(in *uuid.UUID, out *TransportSummary) error { - tp := r.node.tm.Transport(*in) + tp := r.visor.tm.Transport(*in) if tp == nil { return ErrNotFound } - *out = *newTransportSummary(r.node.tm, tp, true, r.node.router.IsSetupTransport(tp)) + *out = *newTransportSummary(r.visor.tm, tp, true, r.visor.router.IsSetupTransport(tp)) return nil } @@ -199,7 +199,7 @@ type AddTransportIn struct { Timeout time.Duration } -// AddTransport creates a transport for the node. +// AddTransport creates a transport for the visor. func (r *RPC) AddTransport(in *AddTransportIn, out *TransportSummary) error { ctx := context.Background() if in.Timeout > 0 { @@ -208,17 +208,17 @@ func (r *RPC) AddTransport(in *AddTransportIn, out *TransportSummary) error { defer cancel() } - tp, err := r.node.tm.CreateTransport(ctx, in.RemotePK, in.TpType, in.Public) + tp, err := r.visor.tm.CreateTransport(ctx, in.RemotePK, in.TpType, in.Public) if err != nil { return err } - *out = *newTransportSummary(r.node.tm, tp, false, r.node.router.IsSetupTransport(tp)) + *out = *newTransportSummary(r.visor.tm, tp, false, r.visor.router.IsSetupTransport(tp)) return nil } -// RemoveTransport removes a Transport from the node. +// RemoveTransport removes a Transport from the visor. func (r *RPC) RemoveTransport(tid *uuid.UUID, _ *struct{}) error { - return r.node.tm.DeleteTransport(*tid) + return r.visor.tm.DeleteTransport(*tid) } /* @@ -233,7 +233,7 @@ type RoutingEntry struct { // RoutingRules obtains all routing rules of the RoutingTable. func (r *RPC) RoutingRules(_ *struct{}, out *[]*RoutingEntry) error { - return r.node.rt.RangeRules(func(routeID routing.RouteID, rule routing.Rule) (next bool) { + return r.visor.rt.RangeRules(func(routeID routing.RouteID, rule routing.Rule) (next bool) { *out = append(*out, &RoutingEntry{Key: routeID, Value: rule}) return true }) @@ -242,25 +242,25 @@ func (r *RPC) RoutingRules(_ *struct{}, out *[]*RoutingEntry) error { // RoutingRule obtains a routing rule of given RouteID. func (r *RPC) RoutingRule(key *routing.RouteID, rule *routing.Rule) error { var err error - *rule, err = r.node.rt.Rule(*key) + *rule, err = r.visor.rt.Rule(*key) return err } // AddRoutingRule adds a RoutingRule and returns a Key in which the rule is stored under. func (r *RPC) AddRoutingRule(rule *routing.Rule, routeID *routing.RouteID) error { var err error - *routeID, err = r.node.rt.AddRule(*rule) + *routeID, err = r.visor.rt.AddRule(*rule) return err } // SetRoutingRule sets a routing rule. func (r *RPC) SetRoutingRule(in *RoutingEntry, out *struct{}) error { - return r.node.rt.SetRule(in.Key, in.Value) + return r.visor.rt.SetRule(in.Key, in.Value) } // RemoveRoutingRule removes a RoutingRule based on given RouteID key. func (r *RPC) RemoveRoutingRule(key *routing.RouteID, _ *struct{}) error { - return r.node.rt.DeleteRules(*key) + return r.visor.rt.DeleteRules(*key) } /* @@ -277,7 +277,7 @@ type LoopInfo struct { // Loops retrieves loops via rules of the routing table. func (r *RPC) Loops(_ *struct{}, out *[]LoopInfo) error { var loops []LoopInfo - err := r.node.rt.RangeRules(func(_ routing.RouteID, rule routing.Rule) (next bool) { + err := r.visor.rt.RangeRules(func(_ routing.RouteID, rule routing.Rule) (next bool) { if rule.Type() == routing.RuleApp { loops = append(loops, LoopInfo{AppRule: rule}) } @@ -288,7 +288,7 @@ func (r *RPC) Loops(_ *struct{}, out *[]LoopInfo) error { } for i, l := range loops { fwdRID := l.AppRule.RouteID() - rule, err := r.node.rt.Rule(fwdRID) + rule, err := r.visor.rt.Rule(fwdRID) if err != nil { return err } 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 e2e1f6374e..10a58faabf 100644 --- a/pkg/node/rpc_client.go +++ b/pkg/visor/rpc_client.go @@ -1,4 +1,4 @@ -package node +package visor import ( "encoding/binary" @@ -225,7 +225,7 @@ func NewMockRPCClient(r *rand.Rand, maxTps int, maxRules int) (cipher.PubKey, RP return localPK, &mockRPCClient{ s: &Summary{ PubKey: localPK, - NodeVersion: Version, + VisorVersion: Version, AppProtoVersion: supportedProtocolVersion, Apps: []*AppState{ {Name: "foo.v1.0", AutoStart: false, Port: 10}, diff --git a/pkg/node/rpc_test.go b/pkg/visor/rpc_test.go similarity index 93% rename from pkg/node/rpc_test.go rename to pkg/visor/rpc_test.go index 85534b7ea6..2a1e956ecc 100644 --- a/pkg/node/rpc_test.go +++ b/pkg/visor/rpc_test.go @@ -1,4 +1,4 @@ -package node +package visor import ( "context" @@ -30,7 +30,7 @@ func TestListApps(t *testing.T) { sApps := map[string]*appBind{ "bar": {}, } - rpc := &RPC{&Node{appsConf: apps, startedApps: sApps}} + rpc := &RPC{&Visor{appsConf: apps, startedApps: sApps}} var reply []*AppState require.NoError(t, rpc.Apps(nil, &reply)) @@ -56,12 +56,12 @@ func TestStartStopApp(t *testing.T) { defer os.RemoveAll("skychat") apps := []AppConfig{{App: "foo", Version: "1.0", AutoStart: false, Port: 10}} - node := &Node{router: router, executer: executer, appsConf: apps, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test"), config: &Config{}} - node.config.Node.StaticPubKey = pk + node := &Visor{router: router, executer: executer, appsConf: apps, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test"), config: &Config{}} + node.config.Visor.StaticPubKey = pk pathutil.EnsureDir(node.dir()) defer os.RemoveAll(node.dir()) - rpc := &RPC{node: node} + rpc := &RPC{visor: node} unknownApp := "bar" app := "foo" @@ -115,8 +115,8 @@ func TestRPC(t *testing.T) { {App: "bar", Version: "2.0", AutoStart: false, Port: 20}, } conf := &Config{} - conf.Node.StaticPubKey = pk1 - node := &Node{ + conf.Visor.StaticPubKey = pk1 + node := &Visor{ config: conf, router: r, tm: tm1, @@ -133,7 +133,7 @@ func TestRPC(t *testing.T) { require.NoError(t, node.StartApp("bar")) time.Sleep(time.Second) - gateway := &RPC{node: node} + gateway := &RPC{visor: node} sConn, cConn := net.Pipe() defer func() { @@ -225,10 +225,10 @@ func TestRPC(t *testing.T) { //assert.Equal(t, ErrUnknownApp.Error(), err.Error()) // //require.NoError(t, client.SetAutoStart(in2.AppName, in2.AutoStart)) - //assert.True(t, node.appsConf[0].AutoStart) + //assert.True(t, visor.appsConf[0].AutoStart) // //require.NoError(t, client.SetAutoStart(in3.AppName, in3.AutoStart)) - //assert.False(t, node.appsConf[0].AutoStart) + //assert.False(t, visor.appsConf[0].AutoStart) }) t.Run("TransportTypes", func(t *testing.T) { diff --git a/pkg/node/node.go b/pkg/visor/visor.go similarity index 56% rename from pkg/node/node.go rename to pkg/visor/visor.go index 0d91b6bc57..3912b8fee6 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" @@ -46,7 +46,7 @@ const ( // ErrUnknownApp represents lookup error for App related calls. var ErrUnknownApp = errors.New("unknown app") -// Version is the node version. +// Version is the visor version. const Version = "0.0.1" const supportedProtocolVersion = "0.0.1" @@ -80,9 +80,9 @@ type PacketRouter interface { IsSetupTransport(tr *transport.ManagedTransport) bool } -// Node provides messaging runtime for Apps by setting up all +// Visor provides messaging runtime for Apps by setting up all // necessary connections and performing messaging gateway functions. -type Node struct { +type Visor struct { config *Config router PacketRouter messenger *dmsg.Client @@ -106,25 +106,25 @@ type Node struct { rpcDialers []*noise.RPCClientDialer } -// NewNode constructs new Node. -func NewNode(config *Config, masterLogger *logging.MasterLogger) (*Node, error) { - node := &Node{ +// New constructs new Visor. +func New(config *Config, masterLogger *logging.MasterLogger) (*Visor, error) { + visor := &Visor{ config: config, executer: newOSExecuter(), startedApps: make(map[string]*appBind), } - node.Logger = masterLogger - node.logger = node.Logger.PackageLogger("skywire") + visor.Logger = masterLogger + visor.logger = visor.Logger.PackageLogger("skywire") - pk := config.Node.StaticPubKey - sk := config.Node.StaticSecKey + pk := config.Visor.StaticPubKey + sk := config.Visor.StaticSecKey mConfig, err := config.MessagingConfig() if err != nil { return nil, fmt.Errorf("invalid Messaging config: %s", err) } - node.messenger = dmsg.NewClient(mConfig.PubKey, mConfig.SecKey, mConfig.Discovery, dmsg.SetLogger(node.Logger.PackageLogger(dmsg.Type))) + visor.messenger = dmsg.NewClient(mConfig.PubKey, mConfig.SecKey, mConfig.Discovery, dmsg.SetLogger(visor.Logger.PackageLogger(dmsg.Type))) trDiscovery, err := config.TransportDiscovery() if err != nil { @@ -138,47 +138,47 @@ func NewNode(config *Config, masterLogger *logging.MasterLogger) (*Node, error) PubKey: pk, SecKey: sk, DiscoveryClient: trDiscovery, LogStore: logStore, - DefaultNodes: config.TrustedNodes, + DefaultVisors: config.TrustedVisors, } - node.tm, err = transport.NewManager(tmConfig, node.messenger) + visor.tm, err = transport.NewManager(tmConfig, visor.messenger) if err != nil { return nil, fmt.Errorf("transport manager: %s", err) } - node.tm.Logger = node.Logger.PackageLogger("trmanager") + visor.tm.Logger = visor.Logger.PackageLogger("trmanager") - node.rt, err = config.RoutingTable() + visor.rt, err = config.RoutingTable() if err != nil { return nil, fmt.Errorf("routing table: %s", err) } rConfig := &router.Config{ - Logger: node.Logger.PackageLogger("router"), + Logger: visor.Logger.PackageLogger("router"), PubKey: pk, SecKey: sk, - TransportManager: node.tm, - RoutingTable: node.rt, + TransportManager: visor.tm, + RoutingTable: visor.rt, RouteFinder: routeFinder.NewHTTP(config.Routing.RouteFinder, time.Duration(config.Routing.RouteFinderTimeout)), SetupNodes: config.Routing.SetupNodes, } r := router.New(rConfig) - node.router = r + visor.router = r - node.appsConf, err = config.AppsConfig() + visor.appsConf, err = config.AppsConfig() if err != nil { return nil, fmt.Errorf("invalid AppsConfig: %s", err) } - node.appsPath, err = config.AppsDir() + visor.appsPath, err = config.AppsDir() if err != nil { return nil, fmt.Errorf("invalid AppsPath: %s", err) } - node.localPath, err = config.LocalDir() + visor.localPath, err = config.LocalDir() if err != nil { return nil, fmt.Errorf("invalid LocalPath: %s", err) } if lvl, err := logging.LevelFromString(config.LogLevel); err == nil { - node.Logger.SetLevel(lvl) + visor.Logger.SetLevel(lvl) } if config.Interfaces.RPCAddress != "" { @@ -186,11 +186,11 @@ func NewNode(config *Config, masterLogger *logging.MasterLogger) (*Node, error) if err != nil { return nil, fmt.Errorf("failed to setup RPC listener: %s", err) } - node.rpcListener = l + visor.rpcListener = l } - node.rpcDialers = make([]*noise.RPCClientDialer, len(config.ManagerNodes)) - for i, entry := range config.ManagerNodes { - node.rpcDialers[i] = noise.NewRPCClientDialer(entry.Addr, noise.HandshakeXK, noise.Config{ + visor.rpcDialers = make([]*noise.RPCClientDialer, len(config.Hypervisors)) + for i, entry := range config.Hypervisors { + visor.rpcDialers[i] = noise.NewRPCClientDialer(entry.Addr, noise.HandshakeXK, noise.Config{ LocalPK: pk, LocalSK: sk, RemotePK: entry.PubKey, @@ -198,62 +198,62 @@ func NewNode(config *Config, masterLogger *logging.MasterLogger) (*Node, error) }) } - return node, err + return visor, err } // Start spawns auto-started Apps, starts router and RPC interfaces . -func (node *Node) Start() error { +func (visor *Visor) Start() error { ctx := context.Background() - err := node.messenger.InitiateServerConnections(ctx, node.config.Messaging.ServerCount) + err := visor.messenger.InitiateServerConnections(ctx, visor.config.Messaging.ServerCount) if err != nil { return fmt.Errorf("%s: %s", dmsg.Type, err) } - node.logger.Info("Connected to messaging servers") + visor.logger.Info("Connected to messaging servers") - pathutil.EnsureDir(node.dir()) - node.closePreviousApps() - for _, ac := range node.appsConf { + pathutil.EnsureDir(visor.dir()) + visor.closePreviousApps() + for _, ac := range visor.appsConf { if !ac.AutoStart { continue } go func(a AppConfig) { - if err := node.SpawnApp(&a, nil); err != nil { - node.logger.Warnf("Failed to start %s: %s\n", a.App, err) + if err := visor.SpawnApp(&a, nil); err != nil { + visor.logger.Warnf("Failed to start %s: %s\n", a.App, err) } }(ac) } rpcSvr := rpc.NewServer() - if err := rpcSvr.RegisterName(RPCPrefix, &RPC{node: node}); err != nil { + if err := rpcSvr.RegisterName(RPCPrefix, &RPC{visor: visor}); err != nil { return fmt.Errorf("rpc server created failed: %s", err) } - if node.rpcListener != nil { - node.logger.Info("Starting RPC interface on ", node.rpcListener.Addr()) - go rpcSvr.Accept(node.rpcListener) + if visor.rpcListener != nil { + visor.logger.Info("Starting RPC interface on ", visor.rpcListener.Addr()) + go rpcSvr.Accept(visor.rpcListener) } - for _, dialer := range node.rpcDialers { + for _, dialer := range visor.rpcDialers { go func(dialer *noise.RPCClientDialer) { if err := dialer.Run(rpcSvr, time.Second); err != nil { - node.logger.Errorf("Dialer exited with error: %v", err) + visor.logger.Errorf("Dialer exited with error: %v", err) } }(dialer) } - node.logger.Info("Starting packet router") - if err := node.router.Serve(ctx); err != nil { - return fmt.Errorf("failed to start Node: %s", err) + visor.logger.Info("Starting packet router") + if err := visor.router.Serve(ctx); err != nil { + return fmt.Errorf("failed to start Visor: %s", err) } return nil } -func (node *Node) dir() string { - return pathutil.NodeDir(node.config.Node.StaticPubKey) +func (visor *Visor) dir() string { + return pathutil.VisorDir(visor.config.Visor.StaticPubKey) } -func (node *Node) pidFile() *os.File { - f, err := os.OpenFile(filepath.Join(node.dir(), "apps-pid.txt"), os.O_RDWR|os.O_CREATE, 0600) +func (visor *Visor) pidFile() *os.File { + f, err := os.OpenFile(filepath.Join(visor.dir(), "apps-pid.txt"), os.O_RDWR|os.O_CREATE, 0600) if err != nil { panic(err) } @@ -261,36 +261,36 @@ func (node *Node) pidFile() *os.File { return f } -func (node *Node) closePreviousApps() { - node.logger.Info("killing previously ran apps if any...") +func (visor *Visor) closePreviousApps() { + visor.logger.Info("killing previously ran apps if any...") - pids := node.pidFile() + pids := visor.pidFile() defer pids.Close() // nocheck: err scanner := bufio.NewScanner(pids) for scanner.Scan() { appInfo := strings.Split(scanner.Text(), " ") if len(appInfo) != 2 { - node.logger.Fatal("error parsing %s. Err: %s", pids.Name(), errors.New("line should be: [app name] [pid]")) + visor.logger.Fatal("error parsing %s. Err: %s", pids.Name(), errors.New("line should be: [app name] [pid]")) } pid, err := strconv.Atoi(appInfo[1]) if err != nil { - node.logger.Fatal("error parsing %s. Err: %s", pids.Name(), err) + visor.logger.Fatal("error parsing %s. Err: %s", pids.Name(), err) } - node.stopUnhandledApp(appInfo[0], pid) + visor.stopUnhandledApp(appInfo[0], pid) } // empty file pathutil.AtomicWriteFile(pids.Name(), []byte{}) } -func (node *Node) stopUnhandledApp(name string, pid int) { +func (visor *Visor) stopUnhandledApp(name string, pid int) { p, err := os.FindProcess(pid) if err != nil { if runtime.GOOS != "windows" { - node.logger.Infof("Previous app %s ran by this node with pid: %d not found", name, pid) + visor.logger.Infof("Previous app %s ran by this visor with pid: %d not found", name, pid) } return } @@ -300,52 +300,52 @@ func (node *Node) stopUnhandledApp(name string, pid int) { return } - node.logger.Infof("Found and killed hanged app %s with pid %d previously ran by this node", name, pid) + visor.logger.Infof("Found and killed hanged app %s with pid %d previously ran by this visor", name, pid) } -// Close safely stops spawned Apps and messaging Node. -func (node *Node) Close() (err error) { - if node.rpcListener != nil { - if err = node.rpcListener.Close(); err != nil { - node.logger.WithError(err).Error("failed to stop RPC interface") +// Close safely stops spawned Apps and messaging Visor. +func (visor *Visor) Close() (err error) { + if visor.rpcListener != nil { + if err = visor.rpcListener.Close(); err != nil { + visor.logger.WithError(err).Error("failed to stop RPC interface") } else { - node.logger.Info("RPC interface stopped successfully") + visor.logger.Info("RPC interface stopped successfully") } } - for i, dialer := range node.rpcDialers { + for i, dialer := range visor.rpcDialers { if err = dialer.Close(); err != nil { - node.logger.WithError(err).Errorf("(%d) failed to stop RPC dialer", i) + visor.logger.WithError(err).Errorf("(%d) failed to stop RPC dialer", i) } else { - node.logger.Infof("(%d) RPC dialer closed successfully", i) + visor.logger.Infof("(%d) RPC dialer closed successfully", i) } } - node.startedMu.Lock() - for a, bind := range node.startedApps { - if err = node.stopApp(a, bind); err != nil { - node.logger.WithError(err).Errorf("(%s) failed to stop app", a) + visor.startedMu.Lock() + for a, bind := range visor.startedApps { + if err = visor.stopApp(a, bind); err != nil { + visor.logger.WithError(err).Errorf("(%s) failed to stop app", a) } else { - node.logger.Infof("(%s) app stopped successfully", a) + visor.logger.Infof("(%s) app stopped successfully", a) } } - node.startedMu.Unlock() - if err = node.router.Close(); err != nil { - node.logger.WithError(err).Error("failed to stop router") + visor.startedMu.Unlock() + if err = visor.router.Close(); err != nil { + visor.logger.WithError(err).Error("failed to stop router") } else { - node.logger.Info("router stopped successfully") + visor.logger.Info("router stopped successfully") } return err } // Apps returns list of AppStates for all registered apps. -func (node *Node) Apps() []*AppState { +func (visor *Visor) Apps() []*AppState { res := []*AppState{} - for _, app := range node.appsConf { + for _, app := range visor.appsConf { state := &AppState{app.App, app.AutoStart, app.Port, AppStatusStopped} - node.startedMu.RLock() - if node.startedApps[app.App] != nil { + visor.startedMu.RLock() + if visor.startedApps[app.App] != nil { state.Status = AppStatusRunning } - node.startedMu.RUnlock() + visor.startedMu.RUnlock() res = append(res, state) } @@ -354,13 +354,13 @@ func (node *Node) Apps() []*AppState { } // StartApp starts registered App. -func (node *Node) StartApp(appName string) error { - for _, app := range node.appsConf { +func (visor *Visor) StartApp(appName string) error { + for _, app := range visor.appsConf { if app.App == appName { startCh := make(chan struct{}) go func() { - if err := node.SpawnApp(&app, startCh); err != nil { - node.logger.Warnf("Failed to start app %s: %s", appName, err) + if err := visor.SpawnApp(&app, startCh); err != nil { + visor.logger.Warnf("Failed to start app %s: %s", appName, err) } }() @@ -373,11 +373,11 @@ func (node *Node) StartApp(appName string) error { } // SpawnApp configures and starts new App. -func (node *Node) SpawnApp(config *AppConfig, startCh chan<- struct{}) error { - node.logger.Infof("Starting %s.v%s", config.App, config.Version) +func (visor *Visor) SpawnApp(config *AppConfig, startCh chan<- struct{}) error { + visor.logger.Infof("Starting %s.v%s", config.App, config.Version) conn, cmd, err := app.Command( &app.Config{ProtocolVersion: supportedProtocolVersion, AppName: config.App, AppVersion: config.Version}, - node.appsPath, + visor.appsPath, config.Args, ) if err != nil { @@ -389,48 +389,48 @@ func (node *Node) SpawnApp(config *AppConfig, startCh chan<- struct{}) error { return fmt.Errorf("can't bind to reserved port %d", config.Port) } - node.startedMu.Lock() - if node.startedApps[config.App] != nil { - node.startedMu.Unlock() + visor.startedMu.Lock() + if visor.startedApps[config.App] != nil { + visor.startedMu.Unlock() return fmt.Errorf("app %s is already started", config.App) } - node.startedApps[config.App] = bind - node.startedMu.Unlock() + visor.startedApps[config.App] = bind + visor.startedMu.Unlock() // TODO: make PackageLogger return *Entry. FieldLogger doesn't expose Writer. - logger := node.logger.WithField("_module", fmt.Sprintf("%s.v%s", config.App, config.Version)).Writer() + logger := visor.logger.WithField("_module", fmt.Sprintf("%s.v%s", config.App, config.Version)).Writer() defer logger.Close() cmd.Stdout = logger cmd.Stderr = logger - cmd.Dir = filepath.Join(node.localPath, config.App, fmt.Sprintf("v%s", config.Version)) + cmd.Dir = filepath.Join(visor.localPath, config.App, fmt.Sprintf("v%s", config.Version)) if _, err := ensureDir(cmd.Dir); err != nil { return err } appCh := make(chan error) go func() { - pid, err := node.executer.Start(cmd) + pid, err := visor.executer.Start(cmd) if err != nil { appCh <- err return } - node.startedMu.Lock() + visor.startedMu.Lock() bind.pid = pid - node.startedMu.Unlock() + visor.startedMu.Unlock() - node.pidMu.Lock() - node.logger.Infof("storing app %s pid %d", config.App, pid) - node.persistPID(config.App, pid) - node.pidMu.Unlock() - appCh <- node.executer.Wait(cmd) + visor.pidMu.Lock() + visor.logger.Infof("storing app %s pid %d", config.App, pid) + visor.persistPID(config.App, pid) + visor.pidMu.Unlock() + appCh <- visor.executer.Wait(cmd) }() srvCh := make(chan error) go func() { - srvCh <- node.router.ServeApp(conn, config.Port, &app.Config{AppName: config.App, AppVersion: config.Version}) + srvCh <- visor.router.ServeApp(conn, config.Port, &app.Config{AppName: config.App, AppVersion: config.Version}) }() if startCh != nil { @@ -451,15 +451,15 @@ func (node *Node) SpawnApp(config *AppConfig, startCh chan<- struct{}) error { } } - node.startedMu.Lock() - delete(node.startedApps, config.App) - node.startedMu.Unlock() + visor.startedMu.Lock() + delete(visor.startedApps, config.App) + visor.startedMu.Unlock() return appErr } -func (node *Node) persistPID(name string, pid int) { - pidF := node.pidFile() +func (visor *Visor) persistPID(name string, pid int) { + pidF := visor.pidFile() pidFName := pidF.Name() pidF.Close() @@ -467,39 +467,39 @@ func (node *Node) persistPID(name string, pid int) { } // StopApp stops running App. -func (node *Node) StopApp(appName string) error { - node.startedMu.Lock() - bind := node.startedApps[appName] - node.startedMu.Unlock() +func (visor *Visor) StopApp(appName string) error { + visor.startedMu.Lock() + bind := visor.startedApps[appName] + visor.startedMu.Unlock() if bind == nil { return ErrUnknownApp } - return node.stopApp(appName, bind) + return visor.stopApp(appName, bind) } // SetAutoStart sets an app to auto start or not. -func (node *Node) SetAutoStart(appName string, autoStart bool) error { - for i, ac := range node.appsConf { +func (visor *Visor) SetAutoStart(appName string, autoStart bool) error { + for i, ac := range visor.appsConf { if ac.App == appName { - node.appsConf[i].AutoStart = autoStart + visor.appsConf[i].AutoStart = autoStart return nil } } return ErrUnknownApp } -func (node *Node) stopApp(app string, bind *appBind) (err error) { - node.logger.Infof("Stopping app %s and closing ports", app) +func (visor *Visor) stopApp(app string, bind *appBind) (err error) { + visor.logger.Infof("Stopping app %s and closing ports", app) - if excErr := node.executer.Stop(bind.pid); excErr != nil && err == nil { - node.logger.Warn("Failed to stop app: ", excErr) + if excErr := visor.executer.Stop(bind.pid); excErr != nil && err == nil { + visor.logger.Warn("Failed to stop app: ", excErr) err = excErr } if srvErr := bind.conn.Close(); srvErr != nil && err == nil { - node.logger.Warnf("Failed to close App conn: %s", srvErr) + visor.logger.Warnf("Failed to close App conn: %s", srvErr) err = srvErr } diff --git a/pkg/node/node_test.go b/pkg/visor/visor_test.go similarity index 91% rename from pkg/node/node_test.go rename to pkg/visor/visor_test.go index de6a0867ea..3bfb7b86f3 100644 --- a/pkg/node/node_test.go +++ b/pkg/visor/visor_test.go @@ -1,4 +1,4 @@ -package node +package visor import ( "context" @@ -50,7 +50,7 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -func TestNewNode(t *testing.T) { +func TestNew(t *testing.T) { pk, sk := cipher.GenerateKeyPair() srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(&httpauth.NextNonceResponse{Edge: pk, NextNonce: 1}) // nolint: errcheck @@ -58,8 +58,8 @@ func TestNewNode(t *testing.T) { defer srv.Close() conf := Config{Version: "1.0", LocalPath: "local", AppsPath: "apps"} - conf.Node.StaticPubKey = pk - conf.Node.StaticSecKey = sk + conf.Visor.StaticPubKey = pk + conf.Visor.StaticSecKey = sk conf.Messaging.Discovery = "http://skywire.skycoin.net:8001" conf.Messaging.ServerCount = 10 conf.Transport.Discovery = srv.URL @@ -70,7 +70,7 @@ func TestNewNode(t *testing.T) { defer os.RemoveAll("local") - node, err := NewNode(&conf, masterLogger) + node, err := New(&conf, masterLogger) require.NoError(t, err) assert.NotNil(t, node.router) @@ -80,7 +80,7 @@ func TestNewNode(t *testing.T) { assert.NotNil(t, node.startedApps) } -func TestNodeStartClose(t *testing.T) { +func TestVisorStartClose(t *testing.T) { r := new(mockRouter) executer := &MockExecuter{} conf := []AppConfig{ @@ -88,7 +88,7 @@ func TestNodeStartClose(t *testing.T) { {App: "foo", Version: "1.0", AutoStart: false}, } defer os.RemoveAll("skychat") - node := &Node{config: &Config{}, router: r, executer: executer, appsConf: conf, + node := &Visor{config: &Config{}, router: r, executer: executer, appsConf: conf, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test")} mConf := &messaging.Config{PubKey: cipher.PubKey{}, SecKey: cipher.SecKey{}, Discovery: client.NewMock()} node.messenger = dmsg.NewClient(mConf.PubKey, mConf.SecKey, mConf.Discovery) @@ -114,15 +114,15 @@ func TestNodeStartClose(t *testing.T) { assert.Equal(t, "skychat/v1.0", executer.cmds[0].Dir) } -func TestNodeSpawnApp(t *testing.T) { +func TestVisorSpawnApp(t *testing.T) { pk, _ := cipher.GenerateKeyPair() r := new(mockRouter) executer := &MockExecuter{} defer os.RemoveAll("skychat") apps := []AppConfig{{App: "skychat", Version: "1.0", AutoStart: false, Port: 10, Args: []string{"foo"}}} - node := &Node{router: r, executer: executer, appsConf: apps, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test"), + node := &Visor{router: r, executer: executer, appsConf: apps, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test"), config: &Config{}} - node.config.Node.StaticPubKey = pk + node.config.Visor.StaticPubKey = pk pathutil.EnsureDir(node.dir()) defer os.RemoveAll(node.dir()) @@ -145,12 +145,12 @@ func TestNodeSpawnApp(t *testing.T) { require.NoError(t, node.StopApp("skychat")) } -func TestNodeSpawnAppValidations(t *testing.T) { +func TestVisorSpawnAppValidations(t *testing.T) { conn, _ := net.Pipe() r := new(mockRouter) executer := &MockExecuter{err: errors.New("foo")} defer os.RemoveAll("skychat") - node := &Node{router: r, executer: executer, + node := &Visor{router: r, executer: executer, startedApps: map[string]*appBind{"skychat": {conn, 10}}, logger: logging.MustGetLogger("test")} From 7a25517f0b76cb14adf1d65951ce161336736c45 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Mon, 1 Jul 2019 12:16:55 +0300 Subject: [PATCH 02/10] Further improvements --- Makefile | 16 ++++++++-------- README.md | 16 ++++++++-------- ci_scripts/run-pkg-tests.sh | 18 +++++++++--------- cmd/hypervisor/hypervisor.go | 2 +- cmd/visor/commands/root.go | 2 +- integration/InteractiveEnvironments.md | 20 ++++++++++---------- integration/start-restart-visorB.sh | 4 ++-- pkg/hypervisor/hypervisor.go | 2 +- pkg/visor/rpc.go | 2 +- pkg/visor/visor.go | 5 ++--- 10 files changed, 43 insertions(+), 44 deletions(-) diff --git a/Makefile b/Makefile index bae5087d5b..19018126a4 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ OPTS?=GO111MODULE=on DOCKER_IMAGE?=skywire-runner # docker image to use for running visor.`golang`, `buildpack-deps:stretch-scm` is OK too DOCKER_NETWORK?=SKYNET -DOCKER_NODE?=SKY01 +DOCKER_VISOR?=SKY01 DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker container TEST_OPTS?=-race -tags no_ci -cover -timeout=5m BUILD_OPTS?=-race @@ -130,9 +130,9 @@ release: ## Build `hypervisor`, `skywire-cli`, `SSH-cli`, `visor` and apps witho 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-clean: ## Clean docker system: remove container ${DOCKER_VISOR} and network ${DOCKER_NETWORK} -docker network rm ${DOCKER_NETWORK} - -docker container rm --force ${DOCKER_NODE} + -docker container rm --force ${DOCKER_VISOR} docker-network: ## Create docker network ${DOCKER_NETWORK} -docker network create ${DOCKER_NETWORK} @@ -153,9 +153,9 @@ docker-volume: dep docker-apps docker-bin bin ## Prepare docker volume for dock -./skywire-cli visor gen-config -o ./visor/visor.json -r perl -pi -e 's/localhost//g' ./visor/visor.json # To make visor accessible from outside with skywire-cli -docker-run: docker-clean docker-image docker-network docker-volume ## Run dockerized visor ${DOCKER_NODE} in image ${DOCKER_IMAGE} with network ${DOCKER_NETWORK} +docker-run: docker-clean docker-image docker-network docker-volume ## Run dockerized visor ${DOCKER_VISOR} in image ${DOCKER_IMAGE} with network ${DOCKER_NETWORK} docker run -it -v $(shell pwd)/visor:/sky --network=${DOCKER_NETWORK} \ - --name=${DOCKER_NODE} ${DOCKER_IMAGE} bash -c "cd /sky && ./visor visor.json" + --name=${DOCKER_VISOR} ${DOCKER_IMAGE} bash -c "cd /sky && ./visor visor.json" docker-setup-node: ## Runs setup-visor in detached state in ${DOCKER_NETWORK} -docker container rm setup-node -f @@ -164,14 +164,14 @@ docker-setup-node: ## Runs setup-visor in detached state in ${DOCKER_NETWORK} --hostname=setup-node skywire-services \ bash -c "./setup-node setup-node.json" -docker-stop: ## Stop running dockerized visor ${DOCKER_NODE} - -docker container stop ${DOCKER_NODE} +docker-stop: ## Stop running dockerized visor ${DOCKER_VISOR} + -docker container stop ${DOCKER_VISOR} docker-rerun: docker-stop -./skywire-cli gen-config -o ./visor/visor.json -r perl -pi -e 's/localhost//g' ./visor/visor.json # To make visor accessible from outside with skywire-cli ${DOCKER_OPTS} go build -race -o ./visor/visor ./cmd/visor - docker container start -i ${DOCKER_NODE} + docker container start -i ${DOCKER_VISOR} run-syslog: ## Run syslog-ng in docker. Logs are mounted under /tmp/syslog -rm -rf /tmp/syslog diff --git a/README.md b/README.md index 23db5f1a5a..9890ea6c97 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ - [Structure of `./visor`](#Structure-of-visor) - [Refresh and restart `SKY01`](#Refresh-and-restart-SKY01) - [Customization of dockers](#Customization-of-dockers) - - [1. DOCKER_IMAGE](#1-DOCKERIMAGE) - - [2.DOCKER_NETWORK](#2DOCKERNETWORK) - - [3. DOCKER_NODE](#3-DOCKERNODE) - - [4. DOCKER_OPTS](#4-DOCKEROPTS) + - [1. DOCKER_IMAGE](#1-DOCKER_IMAGE) + - [2. DOCKER_NETWORK](#2-DOCKER_NETWORK) + - [3. DOCKER_VISOR](#3-DOCKER_NODE) + - [4. DOCKER_OPTS](#4-DOCKER_OPTS) - [Dockerized `visor` recipes](#Dockerized-visor-recipes) - [1. Get Public Key of docker-visor](#1-Get-Public-Key-of-docker-visor) - [2. Get an IP of visor](#2-Get-an-IP-of-visor) @@ -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 -visor +# visor Contains sub-commands that interact with the local Visor # rtfind Queries the Route Finder for available routes between two visors # tpdisc Queries the Transport Discovery to find transport(s) of given transport ID or edge public key # @@ -286,7 +286,7 @@ This will: │   ├── routing.db # │   └── transport_logs # ├── visor-config.json # config of visor -└── visor # `visor binary` compiled with DOCKER_OPTS +└── visor # `visor` binary compiled with DOCKER_OPTS ``` Directory `./visor` is mounted as docker volume for `visor` container. @@ -327,13 +327,13 @@ E.g. DOCKER_IMAGE=golang make docker-run #buildpack-deps:stretch-scm is OK too ``` -#### 2.DOCKER_NETWORK +#### 2. DOCKER_NETWORK Name of virtual network for `visor` Default value: SKYNET -#### 3. DOCKER_NODE +#### 3. DOCKER_VISOR Name of container for `visor` diff --git a/ci_scripts/run-pkg-tests.sh b/ci_scripts/run-pkg-tests.sh index 87de4cb384..977f900530 100644 --- a/ci_scripts/run-pkg-tests.sh +++ b/ci_scripts/run-pkg-tests.sh @@ -11,16 +11,16 @@ 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/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/hypervisor -run TestNew >> ./logs/pkg/TestNewHyperVisor.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/hypervisor -run TestNew >> ./logs/pkg/TestNewHypervisor.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestChannelRead >> ./logs/pkg/TestChannelRead.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestChannelWrite >> ./logs/pkg/TestChannelWrite.log diff --git a/cmd/hypervisor/hypervisor.go b/cmd/hypervisor/hypervisor.go index 7cee2c9723..b3f5d88d21 100644 --- a/cmd/hypervisor/hypervisor.go +++ b/cmd/hypervisor/hypervisor.go @@ -1,5 +1,5 @@ /* -skywire management visor +skywire hypervisor */ package main diff --git a/cmd/visor/commands/root.go b/cmd/visor/commands/root.go index acdd6e0b14..e927de1bac 100644 --- a/cmd/visor/commands/root.go +++ b/cmd/visor/commands/root.go @@ -25,7 +25,7 @@ import ( "github.com/skycoin/skywire/pkg/visor" ) -const configEnv = "SW_CONFIG" +const configEnv = "SW_VISOR_CONFIG" const defaultShutdownTimeout = visor.Duration(10 * time.Second) type runCfg struct { diff --git a/integration/InteractiveEnvironments.md b/integration/InteractiveEnvironments.md index d50c0f1c26..14b6724d19 100644 --- a/integration/InteractiveEnvironments.md +++ b/integration/InteractiveEnvironments.md @@ -24,27 +24,27 @@ integration ├── generic # Generic environmnent │   ├── env-vars.sh # -│   ├── visorA.json # -│   └── visorC.json # +│   ├── visorA.json # +│   └── visorC.json # ├── messaging # Messaging testing environment │   ├── env-vars.sh # -│   ├── visorA.json # -│   └── visorC.json # +│   ├── visorA.json # +│   └── visorC.json # ├── proxy # Proxy testing environment │   ├── env-vars.sh # -│   ├── visorA.json # -│   └── visorC.json # +│   ├── visorA.json # +│   └── visorC.json # ├── ssh # ssh testing environment │   ├── env-vars.sh # -│   ├── visorA.json # -│   └── visorC.json #S +│   ├── visorA.json # +│   └── visorC.json # ├── InteractiveEnvironments.md # You're reading it -├── intermediary-visorB.json # VisorB configurationS +├── intermediary-visorB.json # VisorB 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 -├── start-restart-visorB.sh # script for restart in cycle VisorB +├── start-restart-visorB.sh # script for restart in cycle VisorB ├── startup.sh # add transports between visors ├── tear-down.sh # tear down everything ├── test-messaging-loop.sh # Test script for messaging in infinite loop diff --git a/integration/start-restart-visorB.sh b/integration/start-restart-visorB.sh index a6b93c45b8..f854c0236c 100755 --- a/integration/start-restart-visorB.sh +++ b/integration/start-restart-visorB.sh @@ -7,8 +7,8 @@ do ./bin/visor ./integration/intermediary-visorB.json --tag VisorB 2>> ./logs/visorB.log >> ./logs/visorB.log & echo visor starting VisorB sleep 25 - echo Killing VisorB on $(ps aux |grep "[N]odeB" |awk '{print $2}') - kill $(ps aux |grep "[N]odeB" |awk '{print $2}') + echo Killing VisorB on $(ps aux |grep "[V]isorB" |awk '{print $2}') + kill $(ps aux |grep "[V]isorB" |awk '{print $2}') sleep 3 echo Restarting VisorB done diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index b77ee6e7cd..2c21e2142f 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -1,4 +1,4 @@ -// Package hypervisor implements management visor +// Package hypervisor implements visor manager package hypervisor import ( diff --git a/pkg/visor/rpc.go b/pkg/visor/rpc.go index 75cbd63533..0c55bc8ac2 100644 --- a/pkg/visor/rpc.go +++ b/pkg/visor/rpc.go @@ -15,7 +15,7 @@ import ( const ( // RPCPrefix is the prefix used with all RPC calls. - RPCPrefix = "app-visor" + RPCPrefix = "visor" ) var ( diff --git a/pkg/visor/visor.go b/pkg/visor/visor.go index 3912b8fee6..b7bc83a85b 100644 --- a/pkg/visor/visor.go +++ b/pkg/visor/visor.go @@ -19,17 +19,16 @@ import ( "syscall" "time" - "github.com/skycoin/skywire/pkg/dmsg" - "github.com/skycoin/skywire/pkg/util/pathutil" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire/internal/noise" "github.com/skycoin/skywire/pkg/app" + "github.com/skycoin/skywire/pkg/dmsg" routeFinder "github.com/skycoin/skywire/pkg/route-finder/client" "github.com/skycoin/skywire/pkg/router" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/transport" + "github.com/skycoin/skywire/pkg/util/pathutil" ) // AppStatus defines running status of an App. From 19d4d3cf860d44452a94f668a76cdd355b0ead9d Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 10 Jul 2019 00:41:38 +0300 Subject: [PATCH 03/10] Rename visor (skywire-node) to skywire-networking-node --- .gitignore | 8 +- Makefile | 98 +++---- README.md | 202 +++++++------- ROADMAP.md | 2 +- ci_scripts/run-pkg-tests.sh | 39 ++- cmd/apps/helloworld/helloworld.go | 6 +- cmd/apps/skychat/README.md | 14 +- cmd/apps/skychat/chat.go | 2 +- cmd/apps/therealproxy-client/README.md | 2 +- .../therealproxy-client.go | 2 +- cmd/apps/therealproxy/README.md | 14 +- cmd/apps/therealproxy/therealproxy.go | 2 +- cmd/apps/therealssh-client/README.md | 2 +- .../therealssh-client/therealssh-client.go | 2 +- cmd/apps/therealssh/README.md | 16 +- cmd/apps/therealssh/therealssh.go | 2 +- cmd/hypervisor/README.md | 2 +- cmd/hypervisor/commands/root.go | 22 +- .../hypervisor.postman_collection.json | 20 +- cmd/setup-node/commands/root.go | 2 +- cmd/skywire-cli/commands/mdisc/root.go | 4 +- .../commands/{visor => node}/app.go | 8 +- .../commands/{visor => node}/gen-config.go | 30 +-- .../commands/{visor => node}/pk.go | 4 +- .../commands/{visor => node}/root.go | 14 +- .../commands/{visor => node}/routes.go | 10 +- .../commands/{visor => node}/transports.go | 10 +- cmd/skywire-cli/commands/root.go | 4 +- cmd/skywire-cli/commands/rtfind/root.go | 4 +- cmd/skywire-cli/skywire-cli.go | 2 +- .../commands/root.go | 42 +-- .../config.json | 2 +- cmd/skywire-networking-node/visor.go | 12 + cmd/visor/visor.go | 12 - integration/InteractiveEnvironments.md | 96 +++---- integration/generic/env-vars.sh | 14 +- .../{ssh/visorA.json => generic/nodeA.json} | 10 +- .../generic/{visorC.json => nodeC.json} | 10 +- ...ry-visorB.json => intermediary-nodeB.json} | 8 +- integration/messaging/env-vars.sh | 20 +- .../messaging/{visorA.json => nodeA.json} | 10 +- .../messaging/{visorC.json => nodeC.json} | 10 +- integration/proxy/env-vars.sh | 18 +- integration/proxy/{visorA.json => nodeA.json} | 10 +- integration/proxy/{visorC.json => nodeC.json} | 10 +- integration/run-generic-env.sh | 12 +- integration/run-messaging-env.sh | 12 +- integration/run-proxy-env.sh | 12 +- integration/run-ssh-env.sh | 12 +- integration/ssh/env-vars.sh | 18 +- .../{generic/visorA.json => ssh/nodeA.json} | 10 +- integration/ssh/{visorC.json => nodeC.json} | 10 +- integration/start-restart-nodeB.sh | 14 + integration/start-restart-visorB.sh | 14 - integration/startup.sh | 12 +- integration/tear-down.sh | 8 +- integration/test-proxy.sh | 18 +- integration/test-ssh.sh | 16 +- internal/therealssh/client.go | 2 +- pkg/app/app.go | 10 +- pkg/app/packet.go | 2 +- pkg/app/protocol.go | 2 +- pkg/hypervisor/hypervisor.go | 162 ++++++------ pkg/hypervisor/hypervisor_test.go | 32 +-- pkg/{visor => node}/config.go | 20 +- pkg/{visor => node}/config_test.go | 6 +- pkg/{visor/visor.go => node/node.go} | 248 +++++++++--------- .../visor_test.go => node/node_test.go} | 24 +- pkg/{visor => node}/rpc.go | 78 +++--- pkg/{visor => node}/rpc_client.go | 4 +- pkg/{visor => node}/rpc_test.go | 20 +- pkg/route-finder/client/client.go | 2 +- pkg/router/router.go | 4 +- pkg/routing/packet.go | 2 +- pkg/routing/route.go | 2 +- pkg/setup/protocol.go | 2 +- pkg/transport/manager.go | 10 +- pkg/transport/tcp_transport.go | 2 +- pkg/transport/transport.go | 4 +- pkg/util/pathutil/configpath.go | 10 +- pkg/util/pathutil/homedir.go | 4 +- 81 files changed, 822 insertions(+), 831 deletions(-) rename cmd/skywire-cli/commands/{visor => node}/app.go (92%) rename cmd/skywire-cli/commands/{visor => node}/gen-config.go (84%) rename cmd/skywire-cli/commands/{visor => node}/pk.go (84%) rename cmd/skywire-cli/commands/{visor => node}/root.go (66%) rename cmd/skywire-cli/commands/{visor => node}/routes.go (94%) rename cmd/skywire-cli/commands/{visor => node}/transports.go (93%) rename cmd/{visor => skywire-networking-node}/commands/root.go (83%) rename cmd/{visor => skywire-networking-node}/config.json (98%) create mode 100644 cmd/skywire-networking-node/visor.go delete mode 100644 cmd/visor/visor.go rename integration/{ssh/visorA.json => generic/nodeA.json} (89%) rename integration/generic/{visorC.json => nodeC.json} (87%) rename integration/{intermediary-visorB.json => intermediary-nodeB.json} (86%) rename integration/messaging/{visorA.json => nodeA.json} (86%) rename integration/messaging/{visorC.json => nodeC.json} (85%) rename integration/proxy/{visorA.json => nodeA.json} (86%) rename integration/proxy/{visorC.json => nodeC.json} (85%) rename integration/{generic/visorA.json => ssh/nodeA.json} (89%) rename integration/ssh/{visorC.json => nodeC.json} (87%) create mode 100755 integration/start-restart-nodeB.sh delete mode 100755 integration/start-restart-visorB.sh rename pkg/{visor => node}/config.go (91%) rename pkg/{visor => node}/config_test.go (97%) rename pkg/{visor/visor.go => node/node.go} (56%) rename pkg/{visor/visor_test.go => node/node_test.go} (91%) rename pkg/{visor => node}/rpc.go (73%) rename pkg/{visor => node}/rpc_client.go (99%) rename pkg/{visor => node}/rpc_test.go (93%) diff --git a/.gitignore b/.gitignore index 5c83e5a3b1..423a3ec4eb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,15 +9,15 @@ .idea/ -/visor.json +/skywire.json /*-config.json /apps/ /skywire/ /local* -pkg/visor/apps/ -pkg/visor/bar/ -pkg/visor/foo/ +pkg/node/apps/ +pkg/node/bar/ +pkg/node/foo/ /node /users.db diff --git a/Makefile b/Makefile index 2f0cb0496b..707c3a63b7 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,9 @@ .PHONY : docker-run docker-stop OPTS?=GO111MODULE=on -DOCKER_IMAGE?=skywire-runner # docker image to use for running visor.`golang`, `buildpack-deps:stretch-scm` is OK too +DOCKER_IMAGE?=skywire-runner # docker image to use for running skywire-networking-node.`golang`, `buildpack-deps:stretch-scm` is OK too DOCKER_NETWORK?=SKYNET -DOCKER_VISOR?=SKY01 +DOCKER_NODE?=SKY01 DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker container TEST_OPTS?=-race -tags no_ci -cover -timeout=5m BUILD_OPTS?=-race @@ -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 visor on host - ./visor visor.json +run: stop build config ## Run skywire-networking-node on host + ./skywire-networking-node skywire.json -stop: ## Stop running visor on host - -bash -c "kill $$(ps aux |grep '[v]isor' |awk '{print $$2}')" +stop: ## Stop running skywire-networking-node on host + -bash -c "kill $$(ps aux |grep '[s]kywire-networking-node' |awk '{print $$2}')" -config: ## Generate visor.json - -./skywire-cli visor gen-config -o ./visor.json -r +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 ./visor ./skywire-cli ./setup-node ./hypervisor ./SSH-cli + -rm -f ./skywire-networking-node ./skywire-cli ./setup-node ./hypervisor ./SSH-cli -install: ## Install `visor`, `skywire-cli`, `hypervisor`, `SSH-cli` - ${OPTS} go install ./cmd/visor ./cmd/skywire-cli ./cmd/setup-node ./cmd/hypervisor ./cmd/therealssh-cli +install: ## Install `skywire-networking-node`, `skywire-cli`, `hypervisor`, `SSH-cli` + ${OPTS} go install ./cmd/skywire-networking-node ./cmd/skywire-cli ./cmd/setup-node ./cmd/hypervisor ./cmd/therealssh-cli rerun: stop - ${OPTS} go build -race -o ./visor ./cmd/visor - -./skywire-cli visor gen-config -o ./visor.json -r - perl -pi -e 's/localhost//g' ./visor.json - ./visor visor.json + ${OPTS} go build -race -o ./skywire-networking-node ./cmd/skywire-networking-node + -./skywire-cli node gen-config -o ./skywire.json -r + perl -pi -e 's/localhost//g' ./skywire.json + ./skywire-networking-node skywire.json lint: ## Run linters. Use make install-linters first @@ -54,7 +54,7 @@ vendorcheck: ## Run vendorcheck GO111MODULE=off vendorcheck ./cmd/hypervisor/... GO111MODULE=off vendorcheck ./cmd/setup-node/... GO111MODULE=off vendorcheck ./cmd/skywire-cli/... - GO111MODULE=off vendorcheck ./cmd/visor/... + GO111MODULE=off vendorcheck ./cmd/skywire-networking-node/... # vendorcheck fails on ./cmd/therealssh-cli # the problem is indirect dependency to github.com/sirupsen/logrus #GO111MODULE=off vendorcheck ./cmd/therealssh-cli/... @@ -90,21 +90,21 @@ host-apps: ## Build app ${OPTS} go build ${BUILD_OPTS} -o ./apps/SSH-client.v1.0 ./cmd/apps/therealssh-client # Bin -bin: ## Build `hypervisor`, `skywire-cli`, `SSH-cli`, `visor` - ${OPTS} go build ${BUILD_OPTS} -o ./hypervisor ./cmd/hypervisor +bin: ## Build `skywire-networking-node`, `skywire-cli`, `hypervisor`, `SSH-cli` + ${OPTS} go build ${BUILD_OPTS} -o ./skywire-networking-node ./cmd/skywire-networking-node ${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 ./hypervisor ./cmd/hypervisor ${OPTS} go build ${BUILD_OPTS} -o ./SSH-cli ./cmd/therealssh-cli - ${OPTS} go build ${BUILD_OPTS} -o ./visor ./cmd/visor -release: ## Build `hypervisor`, `skywire-cli`, `SSH-cli`, `visor` and apps without -race flag - ${OPTS} go build -o ./hypervisor ./cmd/hypervisor - ${OPTS} go build -o ./skywire-cli ./cmd/skywire-cli +release: ## Build `skywire-networking-node`, `skywire-cli`, `hypervisor`, `SSH-cli` and apps without -race flag + ${OPTS} go build -o ./skywire-networking-node ./cmd/skywire-networking-node + ${OPTS} go build -o ./skywire-cli ./cmd/skywire-cli ${OPTS} go build -o ./setup-node ./cmd/setup-node + ${OPTS} go build -o ./hypervisor ./cmd/hypervisor ${OPTS} go build -o ./SSH-cli ./cmd/therealssh-cli - ${OPTS} go build -o ./visor ./cmd/visor ${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 @@ -112,52 +112,52 @@ release: ## Build `hypervisor`, `skywire-cli`, `SSH-cli`, `visor` and apps witho ${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 visor +# Dockerized skywire-networking-node 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_VISOR} and network ${DOCKER_NETWORK} +docker-clean: ## Clean docker system: remove container ${DOCKER_NODE} and network ${DOCKER_NETWORK} -docker network rm ${DOCKER_NETWORK} - -docker container rm --force ${DOCKER_VISOR} + -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 visor. `go build` with ${DOCKER_OPTS} - -${DOCKER_OPTS} go build -race -o ./visor/apps/skychat.v1.0 ./cmd/apps/skychat - -${DOCKER_OPTS} go build -race -o ./visor/apps/helloworld.v1.0 ./cmd/apps/helloworld - -${DOCKER_OPTS} go build -race -o ./visor/apps/socksproxy.v1.0 ./cmd/apps/therealproxy - -${DOCKER_OPTS} go build -race -o ./visor/apps/socksproxy-client.v1.0 ./cmd/apps/therealproxy-client - -${DOCKER_OPTS} go build -race -o ./visor/apps/SSH.v1.0 ./cmd/apps/therealssh - -${DOCKER_OPTS} go build -race -o ./visor/apps/SSH-client.v1.0 ./cmd/apps/therealssh-client +docker-apps: ## Build apps binaries for dockerized skywire-networking-node. `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 + -${DOCKER_OPTS} go build -race -o ./node/apps/socksproxy-client.v1.0 ./cmd/apps/therealproxy-client + -${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 `visor`, `skywire-cli`, `visor`, `therealssh-cli`. `go build` with ${DOCKER_OPTS} - ${DOCKER_OPTS} go build -race -o ./visor/visor ./cmd/visor +docker-bin: ## Build `skywire-networking-node`, `skywire-cli`, `hypervisor`, `therealssh-cli`. `go build` with ${DOCKER_OPTS} + ${DOCKER_OPTS} go build -race -o ./node/skywire-networking-node ./cmd/skywire-networking-node -docker-volume: dep docker-apps docker-bin bin ## Prepare docker volume for dockerized visor +docker-volume: dep docker-apps docker-bin bin ## Prepare docker volume for dockerized skywire-networking-node -${DOCKER_OPTS} go build -o ./docker/skywire-services/setup-node ./cmd/setup-node - -./skywire-cli visor gen-config -o ./visor/visor.json -r - perl -pi -e 's/localhost//g' ./visor/visor.json # To make visor accessible from outside with skywire-cli + -./skywire-cli node gen-config -o ./skywire-networking-node/skywire.json -r + perl -pi -e 's/localhost//g' ./node/skywire.json # To make skywire-networking-node accessible from outside with skywire-cli -docker-run: docker-clean docker-image docker-network docker-volume ## Run dockerized visor ${DOCKER_VISOR} in image ${DOCKER_IMAGE} with network ${DOCKER_NETWORK} - docker run -it -v $(shell pwd)/visor:/sky --network=${DOCKER_NETWORK} \ - --name=${DOCKER_VISOR} ${DOCKER_IMAGE} bash -c "cd /sky && ./visor visor.json" +docker-run: docker-clean docker-image docker-network docker-volume ## Run dockerized skywire-networking-node ${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-networking-node skywire.json" -docker-setup-node: ## Runs setup-visor in detached state in ${DOCKER_NETWORK} +docker-setup-node: ## Runs setup-node in detached state in ${DOCKER_NETWORK} -docker container rm setup-node -f docker run -d --network=${DOCKER_NETWORK} \ --name=setup-node \ --hostname=setup-node skywire-services \ bash -c "./setup-node setup-node.json" -docker-stop: ## Stop running dockerized visor ${DOCKER_VISOR} - -docker container stop ${DOCKER_VISOR} +docker-stop: ## Stop running dockerized skywire-networking-node ${DOCKER_NODE} + -docker container stop ${DOCKER_NODE} docker-rerun: docker-stop - -./skywire-cli gen-config -o ./visor/visor.json -r - perl -pi -e 's/localhost//g' ./visor/visor.json # To make visor accessible from outside with skywire-cli - ${DOCKER_OPTS} go build -race -o ./visor/visor ./cmd/visor - docker container start -i ${DOCKER_VISOR} + -./skywire-cli gen-config -o ./node/skywire.json -r + perl -pi -e 's/localhost//g' ./node/skywire.json # To make skywire-networking-node accessible from outside with skywire-cli + ${DOCKER_OPTS} go build -race -o ./node/skywire-networking-node ./cmd/skywire-networking-node + docker container start -i ${DOCKER_NODE} run-syslog: ## Run syslog-ng in docker. Logs are mounted under /tmp/syslog -rm -rf /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 'visor's of interactive testing environment +integration-startup: ## Starts up the required transports between 'skywire-networking-node's of interactive testing environment ./integration/startup.sh integration-teardown: ## Tears down all saved configs and states of integration executables diff --git a/README.md b/README.md index 9890ea6c97..0de373f534 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ - [Build and run](#Build-and-run) - [Requirements](#Requirements) - [Build](#Build) - - [Run `visor`](#Run-visor) - - [Run `visor` in docker container](#Run-visor-in-docker-container) + - [Run `skywire-networking-node`](#Run-skywire-networking-node) + - [Run `skywire-networking-node` in docker container](#Run-skywire-networking-node-in-docker-container) - [Run `skywire-cli`](#Run-skywire-cli) - [Apps](#Apps) - [Transports](#Transports) @@ -22,19 +22,19 @@ - [$SYSLOG_OPTS](#SYSLOGOPTS) - [Updater](#Updater) - [Running skywire in docker containers](#Running-skywire-in-docker-containers) - - [Run dockerized `visor`](#Run-dockerized-visor) - - [Structure of `./visor`](#Structure-of-visor) + - [Run dockerized `skywire-networking-node`](#Run-dockerized-skywire-networking-node) + - [Structure of `./node`](#Structure-of-node) - [Refresh and restart `SKY01`](#Refresh-and-restart-SKY01) - [Customization of dockers](#Customization-of-dockers) - - [1. DOCKER_IMAGE](#1-DOCKER_IMAGE) - - [2. DOCKER_NETWORK](#2-DOCKER_NETWORK) - - [3. DOCKER_VISOR](#3-DOCKER_NODE) - - [4. DOCKER_OPTS](#4-DOCKER_OPTS) - - [Dockerized `visor` recipes](#Dockerized-visor-recipes) - - [1. Get Public Key of docker-visor](#1-Get-Public-Key-of-docker-visor) - - [2. Get an IP of visor](#2-Get-an-IP-of-visor) + - [1. DOCKER_IMAGE](#1-DOCKERIMAGE) + - [2. DOCKER_NETWORK](#2-DOCKERNETWORK) + - [3. DOCKER_NODE](#3-DOCKERNODE) + - [4. DOCKER_OPTS](#4-DOCKEROPTS) + - [Dockerized `skywire-networking-node` recipes](#Dockerized-skywire-networking-node-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 `visors`](#4-Create-new-dockerized-visors) + - [4. Create new dockerized `skywire-networking-node`s](#4-Create-new-dockerized-skywire-networking-nodes) - [5. Env-vars for develoment-/testing- purposes](#5-Env-vars-for-develoment-testing--purposes) - [6. "Hello-Mike-Hello-Joe" test](#6-%22Hello-Mike-Hello-Joe%22-test) @@ -46,19 +46,19 @@ The software is still under heavy development and the current version is intende ## Architecture -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 visors follow the rules that were created by the control plane and execute them. +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 visor which hosts applications and is the gateway to use the network. It establishes connections, called transports, to other visors, requests the setup of routes and forwards packets for other visors on a route. The Skywire visor exposes an API to applications for using the networking protocol of Skywire. +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. -In order to detach control plane tasks from the network visors, 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 visors. +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 visors to advertise transports that they established with other visors. 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 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. -On the basis of this information the route finder calculates the most efficient route in the network. Visors 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 visor. +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 visor to the Setup Node, which sets the routing rules in all visors along a route. Skywire visors determine, which visors they accept routing rules from, so only a whitelisted visor can send routing rules to a visor 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 visors 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 visors 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 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. -There are currently two types of transports that visors can use. The messaging transport is a transport between two visors that uses an intermediary messaging server to relay packets between them. The connection to a specific visor and the connection to a messaging server is facilitated by a discovery service, that allows visors to advertise the messaging servers over which they can be contacted. This transport is used by the setup visor to send routing rules and can be used for other applications as well. It allows visors 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. +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. ## Build and run @@ -90,7 +90,7 @@ $ make $ OPTS="GSO111MODULE=on GOOS=linux GOARCH=arm" make ``` -**Install visor, skywire-cli, hypervisor and SSH-cli** +**Install skywire-networking-node, skywire-cli, hypervisor and SSH-cli** ```bash $ make install # compiles and installs all binaries @@ -99,19 +99,19 @@ $ make install # compiles and installs all binaries **Generate default json config** ```bash -$ skywire-cli visor gen-config +$ skywire-cli node gen-config ``` -### Run `visor` +### Run `skywire-networking-node` -`visor` hosts apps, proxies app's requests to remote visors and exposes communication API that apps can use to implement communication protocols. App binaries are spawned by the visor, communication between visor and app is performed via unix pipes provided on app startup. +`skywire-networking-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. ```bash -visor -$ visor visor-config.json +# Run skywire-networking-node. It takes one argument; the path of a configuration file (`skywire-config.json` if unspecified). +$ skywire-networking-node skywire-config.json ``` -### Run `visor` in docker container +### Run `skywire-networking-node` 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 `visor`. Refer to the help menu for usage: +The `skywire-cli` tool is used to control the `skywire-networking-node`. Refer to the help menu for usage: ```bash $ skywire-cli -h @@ -132,8 +132,8 @@ $ skywire-cli -h # Available Commands: # help Help about any command # mdisc Contains sub-commands that interact with a remote Messaging Discovery -# visor Contains sub-commands that interact with the local Visor -# rtfind Queries the Route Finder for available routes between two visors +# node Contains sub-commands that interact with the local Skywire (Networking) Node +# 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 # # Flags: @@ -145,7 +145,7 @@ $ skywire-cli -h ### Apps -After `visor` is up and running with default environment, default apps are run with the configuration specified in `visor-config.json`. Refer to the following for usage of the default apps: +After `skywire-networking-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: - [Chat](/cmd/apps/skychat) - [Hello World](/cmd/apps/helloworld) @@ -154,23 +154,23 @@ After `visor` is up and running with default environment, default apps are run w ### Transports -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. +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. Transports can be established via the `skywire-cli`. ```bash # Establish transport to `0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881`. -$ skywire-cli visor add-tp 0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881 +$ skywire-cli node add-tp 0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881 # List established transports. -$ skywire-cli visor ls-tp +$ skywire-cli node ls-tp ``` ## App programming API -App is a generic binary that can be executed by the visor. On app -startup visor will open pair of unix pipes that will be used for -communication between app and visor. `app` packages exposes +App is a generic binary that can be executed by the node. On app +startup node will open pair of unix pipes that will be used for +communication between app and node. `app` packages exposes communication API over the pipe. ```golang @@ -179,13 +179,13 @@ communication API over the pipe. // Setup setups app using default pair of pipes func Setup(config *Config) (*App, error) {} -// Accept awaits for incoming loop confirmation request from a Visor and +// Accept awaits for incoming loop confirmation request from a Node and // returns net.Conn for a received loop. func (app *App) Accept() (net.Conn, error) {} // Addr implements net.Addr for App connections. &Addr{PubKey: pk, Port: 12} -// Dial sends create loop request to a Visor and returns net.Conn for created loop. +// Dial sends create loop request to a Node and returns net.Conn for created loop. func (app *App) Dial(raddr *Addr) (net.Conn, error) {} // Close implements io.Closer for App. @@ -242,7 +242,7 @@ E.g. $ make run_syslog ## run syslog-ng in docker container with logs mounted to /tmp/syslog $ export SYSLOG_OPTS='--syslog localhost:514' $ make integration-run-messaging ## or other integration-run-* goal -$ sudo cat /tmp/syslog/messages ## collected logs from VisorA, VisorB, VisorC instances +$ sudo cat /tmp/syslog/messages ## collected logs from NodeA, NodeB, NodeC instances ``` ## Updater @@ -251,9 +251,9 @@ This software comes with an updater, which is located in this repo: https://gith ## Running skywire in docker containers -There are two make goals for running in development environment dockerized `visor`. +There are two make goals for running in development environment dockerized `skywire-networking-node`. -### Run dockerized `visor` +### Run dockerized `skywire-networking-node` ```bash $ make docker-run @@ -261,62 +261,62 @@ $ make docker-run This will: -- create docker image `skywire-runner` for running `visor` +- create docker image `skywire-runner` for running `skywire-networking-node` - create docker network `SKYNET` (can be customized) -- create docker volume ./visor with linux binaries and apps +- create docker volume ./node with linux binaries and apps - create container `SKY01` and starts it (can be customized) -#### Structure of `./visor` +#### Structure of `./node` ``` -./visor -├── apps # visor `apps` compiled with DOCKER_OPTS -│   ├── skychat.v1.0 # +./node +├── apps # node `apps` compiled with DOCKER_OPTS +│   ├── skychat.v1.0 # │   ├── helloworld.v1.0 # -│   ├── socksproxy-client.v1.0 # -│   ├── socksproxy.v1.0 # -│   ├── SSH-client.v1.0 # -│   └── SSH.v1.0 # +│   ├── socksproxy-client.v1.0 # +│   ├── socksproxy.v1.0 # +│   ├── SSH-client.v1.0 # +│   └── SSH.v1.0 # ├── local # **Created inside docker** -│   ├── skychat # according to "local_path" in visor-config.json -│   ├── socksproxy # -│   └── SSH # -├── PK # contains public key of visor +│   ├── skychat # according to "local_path" in skywire-config.json +│   ├── socksproxy # +│   └── SSH # +├── PK # contains public key of node ├── skywire # db & logs. **Created inside docker** │   ├── routing.db # │   └── transport_logs # -├── visor-config.json # config of visor -└── visor # `visor` binary compiled with DOCKER_OPTS +├── skywire-config.json # config of node +└── skywire-networking-node # `skywire-networking-node` binary compiled with DOCKER_OPTS ``` -Directory `./visor` is mounted as docker volume for `visor` container. +Directory `./node` is mounted as docker volume for `skywire-networking-node` container. Inside docker container it is mounted on `/sky` -Structure of `./visor` partially replicates structure of project root directory. +Structure of `./skywire-networking-node` partially replicates structure of project root directory. Note that files created inside docker container has ownership `root:root`, -so in case you want to `rm -rf ./visor` (or other file operations) - you will need `sudo` it. +so in case you want to `rm -rf ./node` (or other file operations) - you will need `sudo` it. -Look at "Recipes: Creating new dockerized visor" for further details. +Look at "Recipes: Creating new dockerized node" for further details. ### Refresh and restart `SKY01` ```bash -$ make refresh-visor +$ make refresh-node ``` This will: - - stops running visor - - recompiles `visor` for container - - start visor again + - stops running node + - recompiles `skywire-networking-node` for container + - start node again ### Customization of dockers #### 1. DOCKER_IMAGE -Docker image for running `visor`. +Docker image for running `skywire-networking-node`. Default value: `skywire-runner` (built with `make docker-image`) @@ -329,13 +329,13 @@ DOCKER_IMAGE=golang make docker-run #buildpack-deps:stretch-scm is OK too #### 2. DOCKER_NETWORK -Name of virtual network for `visor` +Name of virtual network for `skywire-networking-node` Default value: SKYNET -#### 3. DOCKER_VISOR +#### 3. DOCKER_NODE -Name of container for `visor` +Name of container for `skywire-networking-node` Default value: SKY01 @@ -345,16 +345,16 @@ Default value: SKY01 Default value: "GO111MODULE=on GOOS=linux" -### Dockerized `visor` recipes +### Dockerized `skywire-networking-node` recipes -#### 1. Get Public Key of docker-visor +#### 1. Get Public Key of docker-node ```bash -$ cat ./visor/visor.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ' +$ cat ./node/skywire-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ' # 029be6fa68c13e9222553035cc1636d98fb36a888aa569d9ce8aa58caa2c651b45 ``` -#### 2. Get an IP of visor +#### 2. Get an IP of node ```bash $ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01 @@ -367,37 +367,37 @@ $ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' S $ firefox http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01):8000 ``` -#### 4. Create new dockerized `visors` +#### 4. Create new dockerized `skywire-networking-node`s -In case you need more dockerized visors or maybe it's needed to customize visor -let's look how to create new visor. +In case you need more dockerized nodes or maybe it's needed to customize node +let's look how to create new node. ```bash # 1. We need a folder for docker volume -$ mkdir /tmp/SKYVISOR -visor -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/visor ./cmd/visor +$ mkdir /tmp/SKYNODE +# 2. compile `skywire-node` +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/skywire-networking-node ./cmd/skywire-networking-node # 3. compile apps -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/apps/skychat.v1.0 ./cmd/apps/skychat -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/apps/helloworld.v1.0 ./cmd/apps/helloworld -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/apps/socksproxy.v1.0 ./cmd/apps/therealproxy -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/apps/SSH.v1.0 ./cmd/apps/SSH -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYVISOR/apps/SSH-client.v1.0 ./cmd/apps/SSH-client -visor -$ skywire-cli visor gen-config -o /tmp/SKYVISOR/visor-config.json +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/skychat.v1.0 ./cmd/apps/skychat +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/helloworld.v1.0 ./cmd/apps/helloworld +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/socksproxy.v1.0 ./cmd/apps/therealproxy +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/SSH.v1.0 ./cmd/apps/SSH +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/SSH-client.v1.0 ./cmd/apps/SSH-client +# 4. Create skywire-config.json for node +$ skywire-cli node gen-config -o /tmp/SKYNODE/skywire-config.json # 2019/03/15 16:43:49 Done! -$ tree /tmp/SKYVISOR -# /tmp/SKYVISOR +$ tree /tmp/SKYNODE +# /tmp/SKYNODE # ├── apps # │   ├── skychat.v1.0 # │   ├── helloworld.v1.0 # │   ├── socksproxy.v1.0 # │   ├── SSH-client.v1.0 # │   └── SSH.v1.0 -# ├── visor-config.json -visor +# ├── skywire-config.json +# └── skywire-networking-node # So far so good. We prepared docker volume. Now we can: -$ docker run -it -v /tmp/SKYVISOR:/sky --network=SKYNET --name=SKYVISOR skywire-runner bash -c "visor" +$ docker run -it -v /tmp/SKYNODE:/sky --network=SKYNET --name=SKYNODE skywire-runner bash -c "cd /sky && ./skywire-networking-node" # [2019-03-15T13:55:08Z] INFO [messenger]: Opened new link with the server # 02a49bc0aa1b5b78f638e9189be4ed095bac5d6839c828465a8350f80ac07629c0 # [2019-03-15T13:55:08Z] INFO [messenger]: Updating discovery entry # [2019-03-15T13:55:10Z] INFO [skywire]: Connected to messaging servers @@ -427,10 +427,10 @@ Instead of skywire-runner you can use: #### 5. Env-vars for develoment-/testing- purposes ```bash -export SW_VISOR_A=127.0.0.1 -export SW_VISOR_A_PK=$(cat ./visor-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ') -export SW_VISOR_B=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01) -export SW_VISOR_B_PK=$(cat ./visor/visor-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ') +export SW_NODE_A=127.0.0.1 +export SW_NODE_A_PK=$(cat ./skywire-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ') +export SW_NODE_B=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01) +export SW_NODE_B_PK=$(cat ./node/skywire-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ') ``` #### 6. "Hello-Mike-Hello-Joe" test @@ -438,17 +438,17 @@ export SW_VISOR_B_PK=$(cat ./visor/visor-config.json|grep static_public_key |cut Idea of test from Erlang classics: https://youtu.be/uKfKtXYLG78?t=120 ```bash -# Setup: run visors on host and in docker +# Setup: run skywire-networking-nodes on host and in docker $ make run $ make docker-run # Open in browser skychat application -$ firefox http://$SW_VISOR_B:8000 & +$ firefox http://$SW_NODE_B:8000 & # add transport -$ ./skywire-cli add-transport $SW_VISOR_B_PK +$ ./skywire-cli add-transport $SW_NODE_B_PK # "Hello Mike!" - "Hello Joe!" - "System is working!" -$ curl --data {'"recipient":"'$SW_VISOR_A_PK'", "message":"Hello Mike!"}' -X POST http://$SW_VISOR_B:8000/message -$ curl --data {'"recipient":"'$SW_VISOR_B_PK'", "message":"Hello Joe!"}' -X POST http://$SW_VISOR_A:8000/message -$ curl --data {'"recipient":"'$SW_VISOR_A_PK'", "message":"System is working!"}' -X POST http://$SW_VISOR_B:8000/message +$ curl --data {'"recipient":"'$SW_NODE_A_PK'", "message":"Hello Mike!"}' -X POST http://$SW_NODE_B:8000/message +$ curl --data {'"recipient":"'$SW_NODE_B_PK'", "message":"Hello Joe!"}' -X POST http://$SW_NODE_A:8000/message +$ curl --data {'"recipient":"'$SW_NODE_A_PK'", "message":"System is working!"}' -X POST http://$SW_NODE_B:8000/message # Teardown $ make stop && make docker-stop ``` diff --git a/ROADMAP.md b/ROADMAP.md index 3855908d6f..e7e48f9e6d 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -5,7 +5,7 @@ This document defines a high level roadmap for Skywire mainnet development. It d - [ ] Implement bandwidth settlement system for monetization of network services - [ ] Integrate Coin Hour Bank / CoinJoin with the settlement system - [ ] Integrate the new manager interface with the manager backend -- [ ] Add support for remote management of unlimited visors via messaging system +- [ ] Add support for remote management of unlimited nodes via messaging system - [ ] Integrate CXO with Skywire - [ ] Create service discovery for peer discovery - [ ] Document the software and provide tutorials and help for developing applications using Skywire and to contribute to the development diff --git a/ci_scripts/run-pkg-tests.sh b/ci_scripts/run-pkg-tests.sh index fd6eba8f2d..96d4c88006 100644 --- a/ci_scripts/run-pkg-tests.sh +++ b/ci_scripts/run-pkg-tests.sh @@ -11,31 +11,22 @@ 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/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/hypervisor -run TestNew >> ./logs/pkg/TestNewHypervisor.log - -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -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/visor -run TestTransportDiscovery >> ./logs/pkg/TestTransportDiscovery.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestTransportLogStore >> ./logs/pkg/TestTransportLogStore.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestRoutingTable >> ./logs/pkg/TestRoutingTable.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestAppsConfig >> ./logs/pkg/TestAppsConfig.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestAppsDir >> ./logs/pkg/TestAppsDir.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestLocalDir >> ./logs/pkg/TestLocalDir.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestNew >> ./logs/pkg/TestNewVisor.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestVisorStartClose >> ./logs/pkg/TestVisorStartClose.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestVisorSpawnApp >> ./logs/pkg/TestVisorSpawnApp.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestVisorSpawnAppValidations >> ./logs/pkg/TestVisorSpawnAppValidations.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestListApps >> ./logs/pkg/TestListApps.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestStartStopApp >> ./logs/pkg/TestStartStopApp.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/visor -run TestRPC >> ./logs/pkg/TestRPC.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 +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestTransportLogStore >> ./logs/pkg/TestTransportLogStore.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestRoutingTable >> ./logs/pkg/TestRoutingTable.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestAppsConfig >> ./logs/pkg/TestAppsConfig.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestAppsDir >> ./logs/pkg/TestAppsDir.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestLocalDir >> ./logs/pkg/TestLocalDir.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -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 TestNodeStartClose >> ./logs/pkg/TestNodeStartClose.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestNodeSpawnApp >> ./logs/pkg/TestNodeSpawnApp.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestNodeSpawnAppValidations >> ./logs/pkg/TestNodeSpawnAppValidations.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestListApps >> ./logs/pkg/TestListApps.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestStartStopApp >> ./logs/pkg/TestStartStopApp.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestRPC >> ./logs/pkg/TestRPC.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerInit >> ./logs/pkg/TestAppManagerInit.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerSetupLoop >> ./logs/pkg/TestAppManagerSetupLoop.log diff --git a/cmd/apps/helloworld/helloworld.go b/cmd/apps/helloworld/helloworld.go index 0d7a36c75c..b52d2307ac 100644 --- a/cmd/apps/helloworld/helloworld.go +++ b/cmd/apps/helloworld/helloworld.go @@ -1,5 +1,5 @@ /* -simple client server app for skywire visor testing +simple client server app for skywire networking node testing */ package main @@ -36,7 +36,7 @@ func main() { log.Printf("Message from %s: %s", conn.RemoteAddr().String(), string(buf)) if _, err := conn.Write([]byte("pong")); err != nil { - log.Println("Failed to write to a remote visor: ", err) + log.Println("Failed to write to a remote node: ", err) } }() } @@ -53,7 +53,7 @@ func main() { } if _, err := conn.Write([]byte("ping")); err != nil { - log.Fatal("Failed to write to a remote visor: ", err) + log.Fatal("Failed to write to a remote node: ", err) } buf := make([]byte, 4) diff --git a/cmd/apps/skychat/README.md b/cmd/apps/skychat/README.md index 742356675f..6b145895fa 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 visors. +Chat implements basic text messaging between skywire networking nodes. Messaging UI is exposed via web interface. @@ -8,9 +8,9 @@ Chat only supports one WEB client user at a time. ## Local setup -Create 2 visor config files: +Create 2 node config files: -`visor1.json` +`skywire1.json` ```json { @@ -25,7 +25,7 @@ Create 2 visor config files: } ``` -`visor2.json` +`skywire2.json` ```json { @@ -41,12 +41,12 @@ Create 2 visor config files: } ``` -Compile binaries and start 2 visors: +Compile binaries and start 2 nodes: ```bash $ go build -o apps/skychat.v1.0 ./cmd/apps/skychat -$ ./visor visor1.json -$ ./visor visor2.json +$ ./skywire-networking-node skywire1.json +$ ./skywire-networking-node 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 8b76bf3423..c9cc69c14b 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 visor +skychat app for skywire networking node */ package main diff --git a/cmd/apps/therealproxy-client/README.md b/cmd/apps/therealproxy-client/README.md index e6db78e4e5..7d8d7d9951 100644 --- a/cmd/apps/therealproxy-client/README.md +++ b/cmd/apps/therealproxy-client/README.md @@ -2,7 +2,7 @@ `socksproxy-client` app implements client for the SOCKS5 app. -It opens persistent `skywire` connection to the configured remote visor +It opens persistent `skywire` connection to the configured remote node and local TCP port, all incoming TCP traffics is forwarded to the ~skywire~ connection. diff --git a/cmd/apps/therealproxy-client/therealproxy-client.go b/cmd/apps/therealproxy-client/therealproxy-client.go index f1e7c01bd6..de3559ef84 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 visor +proxy client app for skywire networking node */ package main diff --git a/cmd/apps/therealproxy/README.md b/cmd/apps/therealproxy/README.md index 63aa827fe7..ce35629017 100644 --- a/cmd/apps/therealproxy/README.md +++ b/cmd/apps/therealproxy/README.md @@ -10,9 +10,9 @@ If none are provided, the server does not require authentication. ## Local setup -Create 2 visor config files: +Create 2 node config files: -- `visor1.json` +- `skywire1.json` ```json { @@ -28,7 +28,7 @@ Create 2 visor config files: } ``` -- `visor2.json` +- `skywire2.json` ```json { @@ -44,16 +44,16 @@ Create 2 visor config files: } ``` -Compile binaries and start 2 visors: +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 -$ ./visor visor1.json -$ ./visor visor2.json +$ ./skywire-networking-node skywire1.json +$ ./skywire-networking-node skywire2.json ``` -You should be able to connect to a secondary visor via `curl`: +You should be able to connect to a secondary node via `curl`: ```sh $ curl -v -x socks5://123456:@localhost:1080 https://api.ipify.org diff --git a/cmd/apps/therealproxy/therealproxy.go b/cmd/apps/therealproxy/therealproxy.go index e053c5badb..98ecd61974 100644 --- a/cmd/apps/therealproxy/therealproxy.go +++ b/cmd/apps/therealproxy/therealproxy.go @@ -1,5 +1,5 @@ /* -proxy server app for skywire visor +proxy server app for skywire networking node */ package main diff --git a/cmd/apps/therealssh-client/README.md b/cmd/apps/therealssh-client/README.md index 84e33d5363..3aaec45251 100644 --- a/cmd/apps/therealssh-client/README.md +++ b/cmd/apps/therealssh-client/README.md @@ -3,6 +3,6 @@ `SSH-client` app implements client for the SSH app. It starts RCP interface for `SSH-cli` and handles incoming requests to -the remote visor via `skywire` connection. +the remote node via `skywire` connection. Please check docs for `SSH` app for further instructions. diff --git a/cmd/apps/therealssh-client/therealssh-client.go b/cmd/apps/therealssh-client/therealssh-client.go index 9645cb7ff0..7dae9166a0 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 visor +ssh client app for skywire networking node */ package main diff --git a/cmd/apps/therealssh/README.md b/cmd/apps/therealssh/README.md index 62f5dfa261..62d4454467 100644 --- a/cmd/apps/therealssh/README.md +++ b/cmd/apps/therealssh/README.md @@ -15,9 +15,9 @@ authentication file (`$HOME/.therealssh/authorized_keys` by default). ** Local setup -Create 2 visor config files: +Create 2 node config files: -`visor1.json` +`skywire1.json` ```json { @@ -32,7 +32,7 @@ Create 2 visor config files: } ``` -`visor2.json` +`skywire2.json` ```json { @@ -47,24 +47,24 @@ Create 2 visor config files: } ``` -Compile binaries and start 2 visors: +Compile binaries and start 2 nodes: ```bash $ 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 -$ ./visor visor1.json -$ ./visor visor2.json +$ ./skywire-networking-node skywire1.json +$ ./skywire-networking-node skywire2.json ``` -Add public key of the second visor to the auth file: +Add public key of the second node to the auth file: ```bash $ mkdir /.therealssh $ echo "0348c941c5015a05c455ff238af2e57fb8f914c399aab604e9abb5b32b91a4c1fe" > /.SSH/authorized_keys ``` -Connect to the first visor using CLI: +Connect to the first node using CLI: ```bash $ ./SSH-cli 024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7 diff --git a/cmd/apps/therealssh/therealssh.go b/cmd/apps/therealssh/therealssh.go index 57f20f3c9b..7a4ce32e97 100644 --- a/cmd/apps/therealssh/therealssh.go +++ b/cmd/apps/therealssh/therealssh.go @@ -1,5 +1,5 @@ /* -ssh server app for visor +ssh server app for skywire networking node */ package main diff --git a/cmd/hypervisor/README.md b/cmd/hypervisor/README.md index e8cd464a3e..929f636f3f 100644 --- a/cmd/hypervisor/README.md +++ b/cmd/hypervisor/README.md @@ -1,6 +1,6 @@ # Hypervisor -Hypervisor exposes visor management operations via web API. +Hypervisor exposes node management operations via web API. **Generate config file:** diff --git a/cmd/hypervisor/commands/root.go b/cmd/hypervisor/commands/root.go index 777b222e54..62e0510f2f 100644 --- a/cmd/hypervisor/commands/root.go +++ b/cmd/hypervisor/commands/root.go @@ -20,7 +20,7 @@ var ( mock bool mockEnableAuth bool - mockVisors int + mockNodes int mockMaxTps int mockMaxRoutes int ) @@ -28,14 +28,14 @@ var ( func init() { 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(&mockVisors, "mock-visors", 5, "number of app visors to have in mock mode") - rootCmd.Flags().IntVar(&mockMaxTps, "mock-max-tps", 10, "max number of transports per mock app visor") - rootCmd.Flags().IntVar(&mockMaxRoutes, "mock-max-routes", 30, "max number of routes per visor") + 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") + rootCmd.Flags().IntVar(&mockMaxRoutes, "mock-max-routes", 30, "max number of routes per node") } var rootCmd = &cobra.Command{ Use: "hypervisor [config-path]", - Short: "Manages Skywire App Visors", + Short: "Manages Skywire App Nodes", Run: func(_ *cobra.Command, args []string) { configPath := pathutil.FindConfigPath(args, 0, configEnv, pathutil.HypervisorDefaults()) @@ -51,7 +51,7 @@ var rootCmd = &cobra.Command{ rpcAddr = config.Interfaces.RPCAddr ) - m, err := hypervisor.New(config) + m, err := hypervisor.NewNode(config) if err != nil { log.Fatalln("Failed to start hypervisor:", err) } @@ -69,10 +69,10 @@ var rootCmd = &cobra.Command{ if mock { err := m.AddMockData(hypervisor.MockConfig{ - Visors: mockVisors, - MaxTpsPerVisor: mockMaxTps, - MaxRoutesPerVisor: mockMaxRoutes, - EnableAuth: mockEnableAuth, + Nodes: mockNodes, + MaxTpsPerNode: mockMaxTps, + MaxRoutesPerNode: mockMaxRoutes, + EnableAuth: mockEnableAuth, }) if err != nil { log.Fatalln("Failed to add mock data:", err) @@ -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("Hypervisor exited with error:", err) + log.Fatalln("Node exited with error:", err) } log.Println("Good bye!") diff --git a/cmd/hypervisor/hypervisor.postman_collection.json b/cmd/hypervisor/hypervisor.postman_collection.json index 68fc3d5604..a709fb8e72 100644 --- a/cmd/hypervisor/hypervisor.postman_collection.json +++ b/cmd/hypervisor/hypervisor.postman_collection.json @@ -26,7 +26,7 @@ "nodes" ] }, - "description": "Provides a summary of all connected app visors." + "description": "Provides a summary of all connected app nodes." }, "response": [ { @@ -102,7 +102,7 @@ } ] }, - "description": "Provides a summary of a given connected visor of public key." + "description": "Provides a summary of a given connected app node of public key." }, "response": [ { @@ -180,7 +180,7 @@ "apps" ] }, - "description": "Provides a summary of an Visor's apps." + "description": "Provides a summary of an AppNode's apps." }, "response": [ { @@ -253,7 +253,7 @@ "foo.v1.0" ] }, - "description": "Starts an app on an Visor." + "description": "Starts an app on an AppNode." }, "response": [ { @@ -335,7 +335,7 @@ "foo.v1.0" ] }, - "description": "Starts an app on an Visor." + "description": "Starts an app on an AppNode." }, "response": [ { @@ -415,7 +415,7 @@ "transport-types" ] }, - "description": "Lists supported transport types of the given Visor." + "description": "Lists supported transport types of the given AppNode." }, "response": [ { @@ -494,7 +494,7 @@ } ] }, - "description": "List transports of given Visor." + "description": "List transports of given AppNode." }, "response": [ { @@ -580,7 +580,7 @@ "transports" ] }, - "description": "Adds a transport to a given Visor." + "description": "Adds a transport to a given AppNode." }, "response": [ { @@ -660,7 +660,7 @@ "70836b44-f6e5-4c17-a5e8-e1cbef89a10f" ] }, - "description": "Obtains summary of transport of given TransportID and Visor." + "description": "Obtains summary of transport of given TransportID and AppNode." }, "response": [ { @@ -734,7 +734,7 @@ "d5ace20e-06c8-4867-bda2-9449459a9e5a" ] }, - "description": "Removes transport of given TransportID and Visor." + "description": "Removes transport of given TransportID and AppNode." }, "response": [ { diff --git a/cmd/setup-node/commands/root.go b/cmd/setup-node/commands/root.go index f365c86432..4c94e34d44 100644 --- a/cmd/setup-node/commands/root.go +++ b/cmd/setup-node/commands/root.go @@ -82,7 +82,7 @@ var rootCmd = &cobra.Command{ func init() { rootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", ":2121", "address to bind metrics API to") rootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514") - rootCmd.Flags().StringVar(&tag, "tag", "setup-visor", "logging tag") + rootCmd.Flags().StringVar(&tag, "tag", "setup-node", "logging tag") rootCmd.Flags().BoolVarP(&cfgFromStdin, "stdin", "i", false, "read config from STDIN") } diff --git a/cmd/skywire-cli/commands/mdisc/root.go b/cmd/skywire-cli/commands/mdisc/root.go index 18a27e0c1c..1ad5253985 100644 --- a/cmd/skywire-cli/commands/mdisc/root.go +++ b/cmd/skywire-cli/commands/mdisc/root.go @@ -33,13 +33,13 @@ func init() { } var entryCmd = &cobra.Command{ - Use: "entry ", + Use: "entry ", Short: "fetches an entry from messaging-discovery", Args: cobra.MinimumNArgs(1), Run: func(_ *cobra.Command, args []string) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() - pk := internal.ParsePK("visor-public-key", args[0]) + pk := internal.ParsePK("node-public-key", args[0]) entry, err := disc.NewHTTP(mdAddr).Entry(ctx, pk) internal.Catch(err) fmt.Println(entry) diff --git a/cmd/skywire-cli/commands/visor/app.go b/cmd/skywire-cli/commands/node/app.go similarity index 92% rename from cmd/skywire-cli/commands/visor/app.go rename to cmd/skywire-cli/commands/node/app.go index 78afa22727..23d3092341 100644 --- a/cmd/skywire-cli/commands/visor/app.go +++ b/cmd/skywire-cli/commands/node/app.go @@ -1,4 +1,4 @@ -package visor +package node import ( "fmt" @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" "github.com/skycoin/skywire/cmd/skywire-cli/internal" - "github.com/skycoin/skywire/pkg/visor" + "github.com/skycoin/skywire/pkg/node" ) func init() { @@ -23,7 +23,7 @@ func init() { var lsAppsCmd = &cobra.Command{ Use: "ls-apps", - Short: "Lists apps running on the local visor", + Short: "Lists apps running on the local node", Run: func(_ *cobra.Command, _ []string) { states, err := rpcClient().Apps() internal.Catch(err) @@ -34,7 +34,7 @@ var lsAppsCmd = &cobra.Command{ for _, state := range states { status := "stopped" - if state.Status == visor.AppStatusRunning { + if state.Status == node.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/visor/gen-config.go b/cmd/skywire-cli/commands/node/gen-config.go similarity index 84% rename from cmd/skywire-cli/commands/visor/gen-config.go rename to cmd/skywire-cli/commands/node/gen-config.go index f2d2af6c20..e49230a5bf 100644 --- a/cmd/skywire-cli/commands/visor/gen-config.go +++ b/cmd/skywire-cli/commands/node/gen-config.go @@ -1,4 +1,4 @@ -package visor +package node import ( "encoding/base64" @@ -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() { @@ -34,7 +34,7 @@ var genConfigCmd = &cobra.Command{ Short: "Generates a config file", PreRun: func(_ *cobra.Command, _ []string) { if output == "" { - output = pathutil.VisorDefaults().Get(configLocType) + output = pathutil.NodeDefaults().Get(configLocType) log.Infof("No 'output' set; using default path: %s", output) } var err error @@ -43,7 +43,7 @@ var genConfigCmd = &cobra.Command{ } }, Run: func(_ *cobra.Command, _ []string) { - var conf *visor.Config + var conf *node.Config switch configLocType { case pathutil.WorkingDirLoc: conf = defaultConfig() @@ -58,7 +58,7 @@ var genConfigCmd = &cobra.Command{ }, } -func homeConfig() *visor.Config { +func homeConfig() *node.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() *visor.Config { return c } -func localConfig() *visor.Config { +func localConfig() *node.Config { c := defaultConfig() c.AppsPath = "/usr/local/skycoin/skywire/apps" c.Transport.LogStore.Location = "/usr/local/skycoin/skywire/transport_logs" @@ -74,24 +74,24 @@ func localConfig() *visor.Config { return c } -func defaultConfig() *visor.Config { - conf := &visor.Config{} +func defaultConfig() *node.Config { + conf := &node.Config{} conf.Version = "1.0" pk, sk := cipher.GenerateKeyPair() - conf.Visor.StaticPubKey = pk - conf.Visor.StaticSecKey = sk + conf.Node.StaticPubKey = pk + conf.Node.StaticSecKey = sk conf.Messaging.Discovery = "https://messaging.discovery.skywire.skycoin.net" conf.Messaging.ServerCount = 1 passcode := base64.StdEncoding.EncodeToString(cipher.RandByte(8)) - conf.Apps = []visor.AppConfig{ + conf.Apps = []node.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}}, } - conf.TrustedVisors = []cipher.PubKey{} + conf.TrustedNodes = []cipher.PubKey{} conf.Transport.Discovery = "https://transport.discovery.skywire.skycoin.net" conf.Transport.LogStore.Type = "file" @@ -103,16 +103,16 @@ func defaultConfig() *visor.Config { conf.Routing.SetupNodes = []cipher.PubKey{sPK} conf.Routing.Table.Type = "boltdb" conf.Routing.Table.Location = "./skywire/routing.db" - conf.Routing.RouteFinderTimeout = visor.Duration(10 * time.Second) + conf.Routing.RouteFinderTimeout = node.Duration(10 * time.Second) - conf.Hypervisors = []visor.HypervisorConfig{} + conf.Hypervisors = []node.HypervisorConfig{} conf.AppsPath = "./apps" conf.LocalPath = "./local" conf.LogLevel = "info" - conf.ShutdownTimeout = visor.Duration(10 * time.Second) + conf.ShutdownTimeout = node.Duration(10 * time.Second) conf.Interfaces.RPCAddress = "localhost:3435" diff --git a/cmd/skywire-cli/commands/visor/pk.go b/cmd/skywire-cli/commands/node/pk.go similarity index 84% rename from cmd/skywire-cli/commands/visor/pk.go rename to cmd/skywire-cli/commands/node/pk.go index f8ad77114b..f87379b9e1 100644 --- a/cmd/skywire-cli/commands/visor/pk.go +++ b/cmd/skywire-cli/commands/node/pk.go @@ -1,4 +1,4 @@ -package visor +package node import ( "fmt" @@ -12,7 +12,7 @@ func init() { var pkCmd = &cobra.Command{ Use: "pk", - Short: "Obtains the public key of the visor", + Short: "Obtains the public key of the node", Run: func(_ *cobra.Command, _ []string) { client := rpcClient() diff --git a/cmd/skywire-cli/commands/visor/root.go b/cmd/skywire-cli/commands/node/root.go similarity index 66% rename from cmd/skywire-cli/commands/visor/root.go rename to cmd/skywire-cli/commands/node/root.go index 5dd08bd58a..a2147a1fc9 100644 --- a/cmd/skywire-cli/commands/visor/root.go +++ b/cmd/skywire-cli/commands/node/root.go @@ -1,4 +1,4 @@ -package visor +package node import ( "net/rpc" @@ -6,7 +6,7 @@ import ( "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" - "github.com/skycoin/skywire/pkg/visor" + "github.com/skycoin/skywire/pkg/node" ) 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 visor +// RootCmd contains commands that interact with the skywire-networking-node var RootCmd = &cobra.Command{ - Use: "visor", - Short: "Contains sub-commands that interact with the local Skywire Visor", + Use: "node", + Short: "Contains sub-commands that interact with the local Skywire Networking Node", } -func rpcClient() visor.RPCClient { +func rpcClient() node.RPCClient { client, err := rpc.Dial("tcp", rpcAddr) if err != nil { log.Fatal("RPC connection failed:", err) } - return visor.NewRPCClient(client, visor.RPCPrefix) + return node.NewRPCClient(client, node.RPCPrefix) } diff --git a/cmd/skywire-cli/commands/visor/routes.go b/cmd/skywire-cli/commands/node/routes.go similarity index 94% rename from cmd/skywire-cli/commands/visor/routes.go rename to cmd/skywire-cli/commands/node/routes.go index 2416f3b516..b80c3ab49c 100644 --- a/cmd/skywire-cli/commands/visor/routes.go +++ b/cmd/skywire-cli/commands/node/routes.go @@ -1,4 +1,4 @@ -package visor +package node import ( "errors" @@ -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() { @@ -28,7 +28,7 @@ func init() { var lsRulesCmd = &cobra.Command{ Use: "ls-rules", - Short: "Lists the local visor's routing rules", + Short: "Lists the local node's routing rules", Run: func(_ *cobra.Command, _ []string) { rules, err := rpcClient().RoutingRules() internal.Catch(err) @@ -48,7 +48,7 @@ var ruleCmd = &cobra.Command{ rule, err := rpcClient().RoutingRule(routing.RouteID(id)) internal.Catch(err) - printRoutingRules(&visor.RoutingEntry{Key: rule.RouteID(), Value: rule}) + printRoutingRules(&node.RoutingEntry{Key: rule.RouteID(), Value: rule}) }, } @@ -114,7 +114,7 @@ var addRuleCmd = &cobra.Command{ }, } -func printRoutingRules(rules ...*visor.RoutingEntry) { +func printRoutingRules(rules ...*node.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/visor/transports.go b/cmd/skywire-cli/commands/node/transports.go similarity index 93% rename from cmd/skywire-cli/commands/visor/transports.go rename to cmd/skywire-cli/commands/node/transports.go index 98609fda6e..d0a111dcc0 100644 --- a/cmd/skywire-cli/commands/visor/transports.go +++ b/cmd/skywire-cli/commands/node/transports.go @@ -1,4 +1,4 @@ -package visor +package node import ( "fmt" @@ -12,7 +12,7 @@ import ( "github.com/spf13/cobra" "github.com/skycoin/skywire/cmd/skywire-cli/internal" - "github.com/skycoin/skywire/pkg/visor" + "github.com/skycoin/skywire/pkg/node" ) func init() { @@ -27,7 +27,7 @@ func init() { var lsTypesCmd = &cobra.Command{ Use: "ls-types", - Short: "Lists transport types used by the local visor", + Short: "Lists transport types used by the local node", Run: func(_ *cobra.Command, _ []string) { types, err := rpcClient().TransportTypes() internal.Catch(err) @@ -106,7 +106,7 @@ var rmTpCmd = &cobra.Command{ }, } -func printTransports(tps ...*visor.TransportSummary) { +func printTransports(tps ...*node.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 ...*visor.TransportSummary) { internal.Catch(w.Flush()) } -func sortTransports(tps ...*visor.TransportSummary) { +func sortTransports(tps ...*node.TransportSummary) { sort.Slice(tps, func(i, j int) bool { return tps[i].ID.String() < tps[j].ID.String() }) diff --git a/cmd/skywire-cli/commands/root.go b/cmd/skywire-cli/commands/root.go index 0e51e65501..c08a222bc2 100644 --- a/cmd/skywire-cli/commands/root.go +++ b/cmd/skywire-cli/commands/root.go @@ -4,9 +4,9 @@ import ( "github.com/spf13/cobra" "github.com/skycoin/skywire/cmd/skywire-cli/commands/mdisc" + "github.com/skycoin/skywire/cmd/skywire-cli/commands/node" "github.com/skycoin/skywire/cmd/skywire-cli/commands/rtfind" "github.com/skycoin/skywire/cmd/skywire-cli/commands/tpdisc" - "github.com/skycoin/skywire/cmd/skywire-cli/commands/visor" ) var rootCmd = &cobra.Command{ @@ -16,7 +16,7 @@ var rootCmd = &cobra.Command{ func init() { rootCmd.AddCommand( - visor.RootCmd, + node.RootCmd, mdisc.RootCmd, rtfind.RootCmd, tpdisc.RootCmd, diff --git a/cmd/skywire-cli/commands/rtfind/root.go b/cmd/skywire-cli/commands/rtfind/root.go index 3694c564fb..719b76ef92 100644 --- a/cmd/skywire-cli/commands/rtfind/root.go +++ b/cmd/skywire-cli/commands/rtfind/root.go @@ -24,8 +24,8 @@ func init() { // RootCmd is the command that queries the route-finder. var RootCmd = &cobra.Command{ - Use: "rtfind ", - Short: "Queries the Route Finder for available routes between two visors", + Use: "rtfind ", + Short: "Queries the Route Finder for available routes between two nodes", Args: cobra.MinimumNArgs(2), Run: func(_ *cobra.Command, args []string) { rfc := client.NewHTTP(frAddr, timeout) diff --git a/cmd/skywire-cli/skywire-cli.go b/cmd/skywire-cli/skywire-cli.go index 489cdf2703..ca8bdf893c 100644 --- a/cmd/skywire-cli/skywire-cli.go +++ b/cmd/skywire-cli/skywire-cli.go @@ -1,5 +1,5 @@ /* -CLI for visor +CLI for skywire networking node */ package main diff --git a/cmd/visor/commands/root.go b/cmd/skywire-networking-node/commands/root.go similarity index 83% rename from cmd/visor/commands/root.go rename to cmd/skywire-networking-node/commands/root.go index e927de1bac..dbca8600df 100644 --- a/cmd/visor/commands/root.go +++ b/cmd/skywire-networking-node/commands/root.go @@ -21,12 +21,12 @@ import ( "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" + "github.com/skycoin/skywire/pkg/node" "github.com/skycoin/skywire/pkg/util/pathutil" - "github.com/skycoin/skywire/pkg/visor" ) -const configEnv = "SW_VISOR_CONFIG" -const defaultShutdownTimeout = visor.Duration(10 * time.Second) +const configEnv = "SW_CONFIG" +const defaultShutdownTimeout = node.Duration(10 * time.Second) type runCfg struct { syslogAddr string @@ -39,26 +39,26 @@ type runCfg struct { profileStop func() logger *logging.Logger masterLogger *logging.MasterLogger - conf visor.Config - visor *visor.Visor + conf node.Config + node *node.Node } var cfg *runCfg var rootCmd = &cobra.Command{ - Use: "visor [config-path]", - Short: "Visor for skywire", + Use: "skywire-networking-node [config-path]", + Short: "Networking Node for skywire", Run: func(_ *cobra.Command, args []string) { cfg.args = args cfg.startProfiler(). startLogger(). readConfig(). - runVisor(). + runNode(). waitOsSignals(). - stopVisor() + stopNode() }, - Version: visor.Version, + Version: node.Version, } func init() { @@ -124,7 +124,7 @@ func (cfg *runCfg) readConfig() *runCfg { var rdr io.Reader var err error if !cfg.cfgFromStdin { - configPath := pathutil.FindConfigPath(cfg.args, 0, configEnv, pathutil.VisorDefaults()) + configPath := pathutil.FindConfigPath(cfg.args, 0, configEnv, pathutil.NodeDefaults()) rdr, err = os.Open(configPath) if err != nil { cfg.logger.Fatalf("Failed to open config: %s", err) @@ -134,37 +134,37 @@ func (cfg *runCfg) readConfig() *runCfg { rdr = bufio.NewReader(os.Stdin) } - cfg.conf = visor.Config{} + cfg.conf = node.Config{} if err := json.NewDecoder(rdr).Decode(&cfg.conf); err != nil { cfg.logger.Fatalf("Failed to decode %s: %s", rdr, err) } return cfg } -func (cfg *runCfg) runVisor() *runCfg { - visor, err := visor.New(&cfg.conf, cfg.masterLogger) +func (cfg *runCfg) runNode() *runCfg { + node, err := node.NewNode(&cfg.conf, cfg.masterLogger) if err != nil { - cfg.logger.Fatal("Failed to initialize visor: ", err) + cfg.logger.Fatal("Failed to initialize node: ", err) } go func() { - if err := visor.Start(); err != nil { - cfg.logger.Fatal("Failed to start visor: ", err) + if err := node.Start(); err != nil { + cfg.logger.Fatal("Failed to start node: ", err) } }() if cfg.conf.ShutdownTimeout == 0 { cfg.conf.ShutdownTimeout = defaultShutdownTimeout } - cfg.visor = visor + cfg.node = node return cfg } -func (cfg *runCfg) stopVisor() *runCfg { +func (cfg *runCfg) stopNode() *runCfg { defer cfg.profileStop() - if err := cfg.visor.Close(); err != nil { + if err := cfg.node.Close(); err != nil { if !strings.Contains(err.Error(), "closed") { - cfg.logger.Fatal("Failed to close visor: ", err) + cfg.logger.Fatal("Failed to close node: ", err) } } return cfg diff --git a/cmd/visor/config.json b/cmd/skywire-networking-node/config.json similarity index 98% rename from cmd/visor/config.json rename to cmd/skywire-networking-node/config.json index 2447e35849..72aeb19563 100644 --- a/cmd/visor/config.json +++ b/cmd/skywire-networking-node/config.json @@ -1,6 +1,6 @@ { "version": "1.0", - "visor": { + "node": { "static_public_key": "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7", "static_secret_key": "42bca4df2f3189b28872d40e6c61aacd5e85b8e91f8fea65780af27c142419e5" }, diff --git a/cmd/skywire-networking-node/visor.go b/cmd/skywire-networking-node/visor.go new file mode 100644 index 0000000000..c012625311 --- /dev/null +++ b/cmd/skywire-networking-node/visor.go @@ -0,0 +1,12 @@ +/* +skywire networking node +*/ +package main + +import ( + "github.com/skycoin/skywire/cmd/skywire-networking-node/commands" +) + +func main() { + commands.Execute() +} diff --git a/cmd/visor/visor.go b/cmd/visor/visor.go deleted file mode 100644 index 4a6d0c7de8..0000000000 --- a/cmd/visor/visor.go +++ /dev/null @@ -1,12 +0,0 @@ -/* -skywire visor -*/ -package main - -import ( - "github.com/skycoin/skywire/cmd/visor/commands" -) - -func main() { - commands.Execute() -} diff --git a/integration/InteractiveEnvironments.md b/integration/InteractiveEnvironments.md index 14b6724d19..ab8190cafd 100644 --- a/integration/InteractiveEnvironments.md +++ b/integration/InteractiveEnvironments.md @@ -22,33 +22,33 @@ ```text integration -├── generic # Generic environmnent +├── generic # Generic environment │   ├── env-vars.sh # -│   ├── visorA.json # -│   └── visorC.json # +│   ├── nodeA.json # +│   └── nodeC.json # ├── messaging # Messaging testing environment │   ├── env-vars.sh # -│   ├── visorA.json # -│   └── visorC.json # +│   ├── nodeA.json # +│   └── nodeC.json # ├── proxy # Proxy testing environment │   ├── env-vars.sh # -│   ├── visorA.json # -│   └── visorC.json # +│   ├── nodeA.json # +│   └── nodeC.json # ├── ssh # ssh testing environment │   ├── env-vars.sh # -│   ├── visorA.json # -│   └── visorC.json # +│   ├── nodeA.json # +│   └── nodeC.json # ├── InteractiveEnvironments.md # You're reading it -├── intermediary-visorB.json # VisorB configurationS +├── 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 -├── start-restart-visorB.sh # script for restart in cycle VisorB -├── startup.sh # add transports between visors +├── 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 ├── test-messaging-loop.sh # Test script for messaging in infinite loop -├── test-messaging.sh # Test one message between VisorA-VisorC, VisorC-VisorA +├── test-messaging.sh # Test one message between NodeA-NodeC, NodeC-NodeA ├── test-proxy.sh # Test script for proxy ├── test-ssh.sh # Test script for ssh ``` @@ -80,9 +80,9 @@ Usage: The generic test environment will define the following: - skywire-services running on localhost -- 3 visors: - - VisorA, VisorC running all apps - - VisorB - intermediary visor without apps +- 3 `skywire-networking-node`s: + - NodeA, NodeC running all apps + - NodeB - intermediary node without apps **Run** @@ -90,7 +90,7 @@ The generic test environment will define the following: # Tear down everything $ make integration-teardown -# Start all services and visors +# Start all services and nodes $ make integration-run-generic # Adds pre-defined transports @@ -115,8 +115,8 @@ $ make integration-teardown Instead of `../skywire/skywire-cli --rpc localhost:port [command]`, one can use: -- `CLI_A visor ls-tp` - list transports from visorA -- `CLI_B visor add-tp $PK_A` - add transport on visorB to visorA +- `CLI_A node ls-tp` - list transports from nodeA +- `CLI_B node add-tp $PK_A` - add transport on nodeB to nodeA Consult with `./integration/env-vars.sh` for details. @@ -129,11 +129,11 @@ These tests assume that the generic environment is running (via the aforemention # To be run in the 'shell' tab of tmux. ./integration/test-messaging.sh ``` -- **TEST 2: Test send/receive with unstable VisorB.** - 1. Stop VisorB by switching to the 7th tmux window (`Ctrl+B` & `6`) and sending SIGTERM (`Ctrl-C`). +- **TEST 2: Test send/receive with unstable NodeB.** + 1. Stop NodeB by switching to the 7th tmux window (`Ctrl+B` & `6`) and sending SIGTERM (`Ctrl-C`). 2. Run the following in the same window: ```bash - $ ./integration/start-restart-visorB.sh + $ ./integration/start-restart-nodeB.sh ``` 3. Switch to the `shell` window and run: ```bash @@ -144,22 +144,22 @@ These tests assume that the generic environment is running (via the aforemention The following steps will be performed: -1. copy sw*.json and start-restart-visorB.sh into skywire directory +1. copy sw*.json and start-restart-nodeB.sh into skywire directory 2. Create 9 tmux windows: 1. MSGD: messaging-discovery 2. MSG: messaging-server 3. TRD: transport-discovery 4. RF: route-finder 5. SN: setup-node - 6. VisorA: first visor running with generic/visorA.json - 7. VisorB: first visor running with intermediary-visorB.json - 8. VisorC: first visor running with generic/visorC.json + 6. NodeA: first node running with generic/nodeA.json + 7. NodeB: first node running with intermediary-nodeB.json + 8. NodeC: first node running 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 - 2. $PK_A, $PK_B, $PK_C - public keys of visor_A, visor_B, visor_C + 2. $PK_A, $PK_B, $PK_C - public keys of node_A, node_B, node_C 3. $RPC_A, $RPC_B, $RPC_C - `--rpc` param for ../skywire/skywire-cli - 4. $CHAT_A, $CHAT_B - addresses and ports for `skychat`-apps on visor_A and visor_C + 4. $CHAT_A, $CHAT_B - addresses and ports for `skychat`-apps on node_A and node_C 4. Aliases in shell-window: `CLI_A`, `CLI_B`, `CLI_C` ### SSH Test Environment @@ -167,10 +167,10 @@ The following steps will be performed: The SSH Test Environment will define the following: - skywire-services running on localhost -- 3 visors: - - VisorA - running `SSH` app - - VisorB - intermediary visor without apps - - VisorC - running `SSH-client` app +- 3 `skywire-networking-node`s: + - NodeA - running `SSH` app + - NodeB - intermediary node without apps + - NodeC - running `SSH-client` app **Run** @@ -181,7 +181,7 @@ $ make integration-teardown # Prerequisite $ echo $PK_C > ~/.therealssh/authorized_keys -# Start all services and visors +# Start all services and nodes $ make integration-run-ssh # Adds pre-defined transports @@ -193,12 +193,12 @@ $ make integration-startup - **TEST 1** 1. Run `./integration/run-ssh-env.sh` - it will run: 1. skywire-services on localhost - 2. VisorA with configured `SSH` app - 3. VisorB - intermediary - 4. VisorC with configured `SSH-client` app + 2. NodeA with configured `SSH` app + 3. NodeB - intermediary + 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 visors + 2. kill all `skywire-networking-node`s 3. Collect logs 4. Increase n by power of 2 5. Repeat @@ -208,27 +208,27 @@ $ make integration-startup The proxy test environment will define the following: - skywire-services running on localhost -- 3 visors: - - VisorA - running `SSH` app - - VisorB - intermediary visor without apps - - VisorC - running `SSH-client` app +- 3 `skywire-networking-node`s: + - NodeA - running `SSH` app + - NodeB - intermediary node without apps + - NodeC - running `SSH-client` app #### Preparation It's really tricky to make socks5 proxy work now from clean start. Because `socksproxy-client` needs: -- transport to VisorA -- VisorA must be running **before** start of `socksproxy-client` +- transport to NodeA +- NodeA must be running **before** start of `socksproxy-client` Recipe for clean start: 1. Run `make integration-teardown` 2. Start `./integration/run-proxy-env.sh` 3. Run `make integration-startup` -4. Stop VisorA, VisorB, VisorC -5. Restart all visors -6. Wait for message in VisorC logs about successful start of +4. Stop NodeA, NodeB, NodeC +5. Restart all `skywire-networking-node`s +6. Wait for message in NodeC logs about successful start of socksproxy-client 7. Check `lsof -i :9999` that it's really started 8. Check `curl -v --retry 5 --retry-connrefused 1 --connect-timeout 5 -x socks5://123456:@localhost:9999 https://www.google.com` @@ -249,7 +249,7 @@ It's possible that a service could start earlier or later than needed. Examine windows, in case of failed service - restart it (E.g. `KeyUp`-`Enter`) Problem still exists in proxy test environment: - - VisorC cannot start `SSH-client` when VisorA is still starting `SSH` + - NodeC cannot start `SSH-client` when NodeA is still starting `SSH` ### Tmux for new users diff --git a/integration/generic/env-vars.sh b/integration/generic/env-vars.sh index 31366e9f2e..7a355a47c6 100644 --- a/integration/generic/env-vars.sh +++ b/integration/generic/env-vars.sh @@ -1,14 +1,14 @@ # This script needs to be `source`d from bash-compatible shell # E.g. `source ./integration/generic/env-vars.sh` or `. ./integration/generic/env-vars.sh` -export PK_A=$(jq -r ".visor.static_public_key" ./integration/generic/visorA.json) -export RPC_A=$(jq -r ".interfaces.rpc" ./integration/generic/visorA.json) -export PK_B=$(jq -r ".visor.static_public_key" ./integration/intermediary-visorB.json) -export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-visorB.json) -export PK_C=$(jq -r ".visor.static_public_key" ./integration/generic/visorC.json) -export RPC_C=$(jq -r ".interfaces.rpc" ./integration/generic/visorC.json) +export PK_A=$(jq -r ".node.static_public_key" ./integration/generic/nodeA.json) +export RPC_A=$(jq -r ".interfaces.rpc" ./integration/generic/nodeA.json) +export PK_B=$(jq -r ".node.static_public_key" ./integration/intermediary-nodeB.json) +export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-nodeB.json) +export PK_C=$(jq -r ".node.static_public_key" ./integration/generic/nodeC.json) +export RPC_C=$(jq -r ".interfaces.rpc" ./integration/generic/nodeC.json) export CHAT_A=http://localhost:8000/message -export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/generic/visorC.json)/message +export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/generic/nodeC.json)/message alias CLI_A='./skywire-cli --rpc $RPC_A' alias CLI_B='./skywire-cli --rpc $RPC_B' diff --git a/integration/ssh/visorA.json b/integration/generic/nodeA.json similarity index 89% rename from integration/ssh/visorA.json rename to integration/generic/nodeA.json index 26d95ee16c..13b3facc11 100644 --- a/integration/ssh/visorA.json +++ b/integration/generic/nodeA.json @@ -1,6 +1,6 @@ { "version": "1.0", - "visor": { + "node": { "static_public_key": "02072dd1e2ccd761e717096e1a264de1d8917e78e3176ca99dbf7ccf7292969845", "static_secret_key": "7073e557aa2308b448525397ea2f45d56c9962c4dcdf82c5fdb5cc02fca0481c" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/visorA/transport_logs" + "location": "./local/nodeA/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/visorA/routing.db" + "location": "./local/nodeA/routing.db" } }, "apps": [ @@ -48,10 +48,10 @@ "args": [] } ], - "trusted_visors": [], + "trusted_nodes": [], "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/visorA", + "local_path": "./local/nodeA", "log_level": "info", "interfaces": { "rpc": "localhost:3436" diff --git a/integration/generic/visorC.json b/integration/generic/nodeC.json similarity index 87% rename from integration/generic/visorC.json rename to integration/generic/nodeC.json index e8fd8f452e..601210e9a1 100644 --- a/integration/generic/visorC.json +++ b/integration/generic/nodeC.json @@ -1,6 +1,6 @@ { "version": "1.0", - "visor": { + "node": { "static_public_key": "02c9ddf5c2ae6a5a2166028dafbc814eff3ec2352f429fb0aa37d96e1aa668f332", "static_secret_key": "5ab3744ab56e4d0b82f9a915e07b8f05d51ec0f16ff8496bd92f4e378ca6c1fc" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/visorC/transport_logs" + "location": "./local/nodeC/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/visorC/routing.db" + "location": "./local/nodeC/routing.db" } }, "apps": [ @@ -48,10 +48,10 @@ "args": ["-srv", "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7"] } ], - "trusted_visors": [], + "trusted_nodes": [], "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/visorC", + "local_path": "./local/nodeC", "log_level": "info", "interfaces": { "rpc": "localhost:3438" diff --git a/integration/intermediary-visorB.json b/integration/intermediary-nodeB.json similarity index 86% rename from integration/intermediary-visorB.json rename to integration/intermediary-nodeB.json index 3d6ad265a0..5fc589e1d2 100644 --- a/integration/intermediary-visorB.json +++ b/integration/intermediary-nodeB.json @@ -1,6 +1,6 @@ { "version": "1.0", - "visor": { + "node": { "static_public_key": "0372ee0a2b99b55906ac33b49704073ab90ab4f395d814d48d597b5b42c39e5c79", "static_secret_key": "5092f14fe18bd7dcd34479c5d26bb3bf68b708ec74a12c4557091e82dd6e6c36" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/visorB/transport_logs" + "location": "./local/nodeB/transport_logs" } }, "routing": { @@ -23,11 +23,11 @@ "route_finder_timeout": "60s", "table": { "type": "boltdb", - "location": "./local/visorB/routing.db" + "location": "./local/nodeB/routing.db" } }, "apps": [], - "trusted_visors": [], + "trusted_nodes": [], "hypervisors": [], "apps_path": "./bin/apps", "local_path": "./local/localB", diff --git a/integration/messaging/env-vars.sh b/integration/messaging/env-vars.sh index 2a40809d02..9496714bb3 100644 --- a/integration/messaging/env-vars.sh +++ b/integration/messaging/env-vars.sh @@ -1,14 +1,14 @@ # This script needs to be `source`d from bash-compatible shell # E.g. `source ./integration/generic/env-vars.sh` or `. ./integration/messaging/env-vars.sh` -export PK_A=$(jq -r ".visor.static_public_key" ./integration/messaging/visorA.json) -export RPC_A=$(jq -r ".interfaces.rpc" ./integration/messaging/visorA.json) -export PK_B=$(jq -r ".visor.static_public_key" ./integration/intermediary-visorB.json) -export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-visorB.json) -export PK_C=$(jq -r ".visor.static_public_key" ./integration/messaging/visorC.json) -export RPC_C=$(jq -r ".interfaces.rpc" ./integration/messaging/visorC.json) +export PK_A=$(jq -r ".node.static_public_key" ./integration/messaging/nodeA.json) +export RPC_A=$(jq -r ".interfaces.rpc" ./integration/messaging/nodeA.json) +export PK_B=$(jq -r ".node.static_public_key" ./integration/intermediary-nodeB.json) +export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-nodeB.json) +export PK_C=$(jq -r ".node.static_public_key" ./integration/messaging/nodeC.json) +export RPC_C=$(jq -r ".interfaces.rpc" ./integration/messaging/nodeC.json) export CHAT_A=http://localhost:8000/message -export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/messaging/visorC.json)/message +export CHAT_C=http://localhost$(jq -r '.apps [] |select(.app=="skychat")| .args[1] ' ./integration/messaging/nodeC.json)/message export MSGD=https://messaging.discovery.skywire.skycoin.net export TRD=https://transport.discovery.skywire.skycoin.net @@ -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='./visor ./integration/messaging/visorA.json --tag VisorA' -alias RUN_B='./visor ./integration/messaging/intermediary-visorB.json --tag VisorB' -alias RUN_C='./visor ./integration/messaging/visorC.json --tag VisorC' +alias RUN_A='./skywire-networking-node ./integration/messaging/nodeA.json --tag NodeA' +alias RUN_B='./skywire-networking-node ./integration/messaging/intermediary-nodeB.json --tag NodeB' +alias RUN_C='./skywire-networking-node ./integration/messaging/nodeC.json --tag NodeC' echo PK_A: $PK_A echo PK_B: $PK_B diff --git a/integration/messaging/visorA.json b/integration/messaging/nodeA.json similarity index 86% rename from integration/messaging/visorA.json rename to integration/messaging/nodeA.json index fb5febaef4..d9e022d3c5 100644 --- a/integration/messaging/visorA.json +++ b/integration/messaging/nodeA.json @@ -1,6 +1,6 @@ { "version": "1.0", - "visor": { + "node": { "static_public_key": "02072dd1e2ccd761e717096e1a264de1d8917e78e3176ca99dbf7ccf7292969845", "static_secret_key": "7073e557aa2308b448525397ea2f45d56c9962c4dcdf82c5fdb5cc02fca0481c" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/visorA/transport_logs" + "location": "./local/nodeA/transport_logs" } }, "routing": { @@ -23,7 +23,7 @@ "route_finder_timeout": "60s", "table": { "type": "boltdb", - "location": "./local/visorA/routing.db" + "location": "./local/nodeA/routing.db" } }, "apps": [ @@ -35,11 +35,11 @@ "args": [] } ], - "trusted_visors": [], + "trusted_nodes": [], "hypervisors": [], "apps_path": "./apps", "shutdown_timeout": "30s", - "local_path": "./local/visorA", + "local_path": "./local/nodeA", "log_level": "info", "interfaces": { "rpc": "localhost:3436" diff --git a/integration/messaging/visorC.json b/integration/messaging/nodeC.json similarity index 85% rename from integration/messaging/visorC.json rename to integration/messaging/nodeC.json index 4837f44251..84d22083a7 100644 --- a/integration/messaging/visorC.json +++ b/integration/messaging/nodeC.json @@ -1,6 +1,6 @@ { "version": "1.0", - "visor": { + "node": { "static_public_key": "02c9ddf5c2ae6a5a2166028dafbc814eff3ec2352f429fb0aa37d96e1aa668f332", "static_secret_key": "5ab3744ab56e4d0b82f9a915e07b8f05d51ec0f16ff8496bd92f4e378ca6c1fc" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/visorC/transport_logs" + "location": "./local/nodeC/transport_logs" } }, "routing": { @@ -23,7 +23,7 @@ "route_finder_timeout": "60s", "table": { "type": "boltdb", - "location": "./local/visorC/routing.db" + "location": "./local/nodeC/routing.db" } }, "apps": [ @@ -35,11 +35,11 @@ "args": ["-addr", ":8001"] } ], - "trusted_visors": [], + "trusted_nodes": [], "hypervisors": [], "apps_path": "./apps", "shutdown_timeout": "30s", - "local_path": "./local/visorC", + "local_path": "./local/nodeC", "log_level": "info", "interfaces": { "rpc": "localhost:3438" diff --git a/integration/proxy/env-vars.sh b/integration/proxy/env-vars.sh index ce2f3a838f..2b3e427ab0 100644 --- a/integration/proxy/env-vars.sh +++ b/integration/proxy/env-vars.sh @@ -1,11 +1,11 @@ # This script needs to be `source`d from bash-compatible shell # E.g. `source ./integration/proxy/env-vars.sh` or `. ./integration/proxy/env-vars.sh` -export PK_A=$(jq -r ".visor.static_public_key" ./integration/proxy/visorA.json) -export RPC_A=$(jq -r ".interfaces.rpc" ./integration/proxy/visorA.json) -export PK_B=$(jq -r ".visor.static_public_key" ./integration/intermediary-visorB.json) -export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-visorB.json) -export PK_C=$(jq -r ".visor.static_public_key" ./integration/proxy/visorC.json) -export RPC_C=$(jq -r ".interfaces.rpc" ./integration/proxy/visorC.json) +export PK_A=$(jq -r ".node.static_public_key" ./integration/proxy/nodeA.json) +export RPC_A=$(jq -r ".interfaces.rpc" ./integration/proxy/nodeA.json) +export PK_B=$(jq -r ".node.static_public_key" ./integration/intermediary-nodeB.json) +export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-nodeB.json) +export PK_C=$(jq -r ".node.static_public_key" ./integration/proxy/nodeC.json) +export RPC_C=$(jq -r ".interfaces.rpc" ./integration/proxy/nodeC.json) alias CLI_A='./skywire-cli --rpc $RPC_A' alias CLI_B='./skywire-cli --rpc $RPC_B' @@ -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/visor ./integration/messaging/visorA.json --tag VisorA' -alias RUN_B='go run ./cmd/visor ./integration/intermediary-visorB.json --tag VisorB' -alias RUN_C='go run ./cmd/visor ./integration/messaging/visorC.json --tag VisorC' +alias RUN_A='go run ./cmd/skywire-networking-node ./integration/messaging/nodeA.json --tag NodeA' +alias RUN_B='go run ./cmd/skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB' +alias RUN_C='go run ./cmd/skywire-networking-node ./integration/messaging/nodeC.json --tag NodeC' echo PK_A: $PK_A echo PK_B: $PK_B diff --git a/integration/proxy/visorA.json b/integration/proxy/nodeA.json similarity index 86% rename from integration/proxy/visorA.json rename to integration/proxy/nodeA.json index b1544c57fa..a48121c5f5 100644 --- a/integration/proxy/visorA.json +++ b/integration/proxy/nodeA.json @@ -1,6 +1,6 @@ { "version": "1.0", - "visor": { + "node": { "static_public_key": "02072dd1e2ccd761e717096e1a264de1d8917e78e3176ca99dbf7ccf7292969845", "static_secret_key": "7073e557aa2308b448525397ea2f45d56c9962c4dcdf82c5fdb5cc02fca0481c" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/visorA/transport_logs" + "location": "./local/nodeA/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/visorA/routing.db" + "location": "./local/nodeA/routing.db" } }, "apps": [ @@ -34,10 +34,10 @@ "args": [] } ], - "trusted_visors": [], + "trusted_nodes": [], "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/visorA", + "local_path": "./local/nodeA", "log_level": "info", "interfaces": { "rpc": "localhost:3436" diff --git a/integration/proxy/visorC.json b/integration/proxy/nodeC.json similarity index 85% rename from integration/proxy/visorC.json rename to integration/proxy/nodeC.json index 9425810c45..4429014618 100644 --- a/integration/proxy/visorC.json +++ b/integration/proxy/nodeC.json @@ -1,6 +1,6 @@ { "version": "1.0", - "visor": { + "node": { "static_public_key": "02c9ddf5c2ae6a5a2166028dafbc814eff3ec2352f429fb0aa37d96e1aa668f332", "static_secret_key": "5ab3744ab56e4d0b82f9a915e07b8f05d51ec0f16ff8496bd92f4e378ca6c1fc" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/visorC/transport_logs" + "location": "./local/nodeC/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/visorC/routing.db" + "location": "./local/nodeC/routing.db" } }, "apps": [ @@ -34,10 +34,10 @@ "args": ["-srv", "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7"] } ], - "trusted_visors": [], + "trusted_nodes": [], "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/visorC", + "local_path": "./local/nodeC", "log_level": "info", "interfaces": { "rpc": "localhost:3438" diff --git a/integration/run-generic-env.sh b/integration/run-generic-env.sh index 64a0fd8db0..6a20f7d6e1 100755 --- a/integration/run-generic-env.sh +++ b/integration/run-generic-env.sh @@ -9,14 +9,14 @@ source ./integration/generic/env-vars.sh 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 VisorA -tmux send-keys -t VisorA -l "./visor ./integration/generic/visorA.json --tag VisorA $SYSLOG_OPTS" +tmux rename-window -t skywire NodeA +tmux send-keys -t NodeA -l "./skywire-networking-node ./integration/generic/nodeA.json --tag NodeA $SYSLOG_OPTS" tmux send-keys C-m -tmux new-window -t skywire -n VisorB -tmux send-keys -t VisorB -l "./visor ./integration/intermediary-visorB.json --tag VisorB $SYSLOG_OPTS" +tmux new-window -t skywire -n NodeB +tmux send-keys -t NodeB -l "./skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" tmux send-keys C-m -tmux new-window -t skywire -n VisorC -tmux send-keys -t VisorC -l "./visor ./integration/generic/visorC.json --tag VisorC $SYSLOG_OPTS" +tmux new-window -t skywire -n NodeC +tmux send-keys -t NodeC -l "./skywire-networking-node ./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 18f296796f..c91ba5ace8 100755 --- a/integration/run-messaging-env.sh +++ b/integration/run-messaging-env.sh @@ -9,14 +9,14 @@ source ./integration/messaging/env-vars.sh 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 VisorA -tmux send-keys -t VisorA -l "./visor ./integration/messaging/visorA.json --tag VisorA $SYSLOG_OPTS" +tmux rename-window -t skywire NodeA +tmux send-keys -t NodeA -l "./skywire-networking-node ./integration/messaging/nodeA.json --tag NodeA $SYSLOG_OPTS" tmux send-keys C-m -tmux new-window -t skywire -n VisorB -tmux send-keys -t VisorB -l "./visor ./integration/intermediary-visorB.json --tag VisorB $SYSLOG_OPTS" +tmux new-window -t skywire -n NodeB +tmux send-keys -t NodeB -l "./skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" tmux send-keys C-m -tmux new-window -t skywire -n VisorC -tmux send-keys -t VisorC -l "./visor ./integration/messaging/visorC.json --tag VisorC $SYSLOG_OPTS" +tmux new-window -t skywire -n NodeC +tmux send-keys -t NodeC -l "./skywire-networking-node ./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 1ec59ef2b7..5b047521ac 100755 --- a/integration/run-proxy-env.sh +++ b/integration/run-proxy-env.sh @@ -9,14 +9,14 @@ source ./integration/proxy/env-vars.sh 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 VisorA -tmux send-keys -t VisorA -l "./visor ./integration/proxy/visorA.json --tag VisorA $SYSLOG_OPTS" +tmux rename-window -t skywire NodeA +tmux send-keys -t NodeA -l "./skywire-networking-node ./integration/proxy/nodeA.json --tag NodeA $SYSLOG_OPTS" tmux send-keys C-m -tmux new-window -t skywire -n VisorB -tmux send-keys -t VisorB -l "./visor ./integration/intermediary-visorB.json --tag VisorB $SYSLOG_OPTS" +tmux new-window -t skywire -n NodeB +tmux send-keys -t NodeB -l "./skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" tmux send-keys C-m -tmux new-window -t skywire -n VisorC -tmux send-keys -t VisorC -l "./visor ./integration/proxy/visorC.json --tag VisorC $SYSLOG_OPTS" +tmux new-window -t skywire -n NodeC +tmux send-keys -t NodeC -l "./skywire-networking-node ./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 2bd3a16bd1..7c62ff10bb 100755 --- a/integration/run-ssh-env.sh +++ b/integration/run-ssh-env.sh @@ -9,14 +9,14 @@ source ./integration/ssh/env-vars.sh 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 VisorA -tmux send-keys -t VisorA -l "./visor ./integration/ssh/visorA.json --tag VisorA $SYSLOG_OPTS" +tmux rename-window -t skywire NodeA +tmux send-keys -t NodeA -l "./skywire-networking-node ./integration/ssh/nodeA.json --tag NodeA $SYSLOG_OPTS" tmux send-keys C-m -tmux new-window -t skywire -n VisorB -tmux send-keys -t VisorB -l "./visor ./integration/intermediary-visorB.json --tag VisorB $SYSLOG_OPTS" +tmux new-window -t skywire -n NodeB +tmux send-keys -t NodeB -l "./skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB $SYSLOG_OPTS" tmux send-keys C-m -tmux new-window -t skywire -n VisorC -tmux send-keys -t VisorC -l "./visor ./integration/ssh/visorC.json --tag VisorC $SYSLOG_OPTS" +tmux new-window -t skywire -n NodeC +tmux send-keys -t NodeC -l "./skywire-networking-node ./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 e739403175..c4a0820bca 100644 --- a/integration/ssh/env-vars.sh +++ b/integration/ssh/env-vars.sh @@ -1,11 +1,11 @@ # This script needs to be `source`d from bash-compatible shell # E.g. `source ./integration/ssh/env-vars.sh` or `. ./integration/ssh/env-vars.sh` -export PK_A=$(jq -r ".visor.static_public_key" ./integration/ssh/visorA.json) -export RPC_A=$(jq -r ".interfaces.rpc" ./integration/ssh/visorA.json) -export PK_B=$(jq -r ".visor.static_public_key" ./integration/intermediary-visorB.json) -export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-visorB.json) -export PK_C=$(jq -r ".visor.static_public_key" ./integration/ssh/visorC.json) -export RPC_C=$(jq -r ".interfaces.rpc" ./integration/ssh/visorC.json) +export PK_A=$(jq -r ".node.static_public_key" ./integration/ssh/nodeA.json) +export RPC_A=$(jq -r ".interfaces.rpc" ./integration/ssh/nodeA.json) +export PK_B=$(jq -r ".node.static_public_key" ./integration/intermediary-nodeB.json) +export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-nodeB.json) +export PK_C=$(jq -r ".node.static_public_key" ./integration/ssh/nodeC.json) +export RPC_C=$(jq -r ".interfaces.rpc" ./integration/ssh/nodeC.json) alias CLI_A='./skywire-cli --rpc $RPC_A' alias CLI_B='./skywire-cli --rpc $RPC_B' @@ -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/visor ./integration/messaging/visorA.json --tag VisorA' -alias RUN_B='go run ./cmd/visor ./integration/intermediary-visorB.json --tag VisorB' -alias RUN_C='go run ./cmd/visor ./integration/messaging/visorC.json --tag VisorC' +alias RUN_A='go run ./cmd/skywire-networking-node ./integration/messaging/nodeA.json --tag NodeA' +alias RUN_B='go run ./cmd/skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB' +alias RUN_C='go run ./cmd/skywire-networking-node ./integration/messaging/nodeC.json --tag NodeC' echo PK_A: $PK_A echo PK_B: $PK_B diff --git a/integration/generic/visorA.json b/integration/ssh/nodeA.json similarity index 89% rename from integration/generic/visorA.json rename to integration/ssh/nodeA.json index 26d95ee16c..13b3facc11 100644 --- a/integration/generic/visorA.json +++ b/integration/ssh/nodeA.json @@ -1,6 +1,6 @@ { "version": "1.0", - "visor": { + "node": { "static_public_key": "02072dd1e2ccd761e717096e1a264de1d8917e78e3176ca99dbf7ccf7292969845", "static_secret_key": "7073e557aa2308b448525397ea2f45d56c9962c4dcdf82c5fdb5cc02fca0481c" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/visorA/transport_logs" + "location": "./local/nodeA/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/visorA/routing.db" + "location": "./local/nodeA/routing.db" } }, "apps": [ @@ -48,10 +48,10 @@ "args": [] } ], - "trusted_visors": [], + "trusted_nodes": [], "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/visorA", + "local_path": "./local/nodeA", "log_level": "info", "interfaces": { "rpc": "localhost:3436" diff --git a/integration/ssh/visorC.json b/integration/ssh/nodeC.json similarity index 87% rename from integration/ssh/visorC.json rename to integration/ssh/nodeC.json index e8fd8f452e..601210e9a1 100644 --- a/integration/ssh/visorC.json +++ b/integration/ssh/nodeC.json @@ -1,6 +1,6 @@ { "version": "1.0", - "visor": { + "node": { "static_public_key": "02c9ddf5c2ae6a5a2166028dafbc814eff3ec2352f429fb0aa37d96e1aa668f332", "static_secret_key": "5ab3744ab56e4d0b82f9a915e07b8f05d51ec0f16ff8496bd92f4e378ca6c1fc" }, @@ -12,7 +12,7 @@ "discovery": "https://transport.discovery.skywire.skycoin.net", "log_store": { "type": "file", - "location": "./local/visorC/transport_logs" + "location": "./local/nodeC/transport_logs" } }, "routing": { @@ -22,7 +22,7 @@ "route_finder": "https://routefinder.skywire.skycoin.net/", "table": { "type": "boltdb", - "location": "./local/visorC/routing.db" + "location": "./local/nodeC/routing.db" } }, "apps": [ @@ -48,10 +48,10 @@ "args": ["-srv", "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7"] } ], - "trusted_visors": [], + "trusted_nodes": [], "hypervisors": [], "apps_path": "./apps", - "local_path": "./local/visorC", + "local_path": "./local/nodeC", "log_level": "info", "interfaces": { "rpc": "localhost:3438" diff --git a/integration/start-restart-nodeB.sh b/integration/start-restart-nodeB.sh new file mode 100755 index 0000000000..0e3e55d3cd --- /dev/null +++ b/integration/start-restart-nodeB.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +mkdir -p ./logs +echo Press Ctrl-C to exit +for ((;;)) +do + ./bin/skywire-networking-node ./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}') + kill $(ps aux |grep "[N]odeB" |awk '{print $2}') + sleep 3 + echo Restarting NodeB +done diff --git a/integration/start-restart-visorB.sh b/integration/start-restart-visorB.sh deleted file mode 100755 index f854c0236c..0000000000 --- a/integration/start-restart-visorB.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -mkdir -p ./logs -echo Press Ctrl-C to exit -for ((;;)) -do - ./bin/visor ./integration/intermediary-visorB.json --tag VisorB 2>> ./logs/visorB.log >> ./logs/visorB.log & - echo visor starting VisorB - sleep 25 - echo Killing VisorB on $(ps aux |grep "[V]isorB" |awk '{print $2}') - kill $(ps aux |grep "[V]isorB" |awk '{print $2}') - sleep 3 - echo Restarting VisorB -done diff --git a/integration/startup.sh b/integration/startup.sh index 86e9ad2aeb..1ca41aa4c5 100755 --- a/integration/startup.sh +++ b/integration/startup.sh @@ -4,12 +4,12 @@ # - inside tmux session created by run-*-env.sh scripts # - or standalone `source ./integration/[name of environment]/env-vars.sh && ./integration/startup.sh` -./skywire-cli --rpc $RPC_A visor add-tp $PK_B -./skywire-cli --rpc $RPC_C visor add-tp $PK_B +./skywire-cli --rpc $RPC_A node add-tp $PK_B +./skywire-cli --rpc $RPC_C node add-tp $PK_B sleep 1 -echo "VisorA Transports:" -./skywire-cli --rpc $RPC_A visor ls-tp +echo "NodeA Transports:" +./skywire-cli --rpc $RPC_A node ls-tp -echo "VisorB Transports:" -./skywire-cli --rpc $RPC_B visor ls-tp +echo "NodeB Transports:" +./skywire-cli --rpc $RPC_B node ls-tp diff --git a/integration/tear-down.sh b/integration/tear-down.sh index 8d80fbafd2..809ea3580f 100755 --- a/integration/tear-down.sh +++ b/integration/tear-down.sh @@ -1,9 +1,9 @@ #!/bin/sh -# In case visors are not stopped properly. -kill $(ps aux |grep "[V]isorA" |awk '{print $2}') -kill $(ps aux |grep "[V]isorB" |awk '{print $2}') -kill $(ps aux |grep "[V]isorC" |awk '{print $2}') +# In case skywire-networking-nodes 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}') echo Removing ./local rm -rf ./local diff --git a/integration/test-proxy.sh b/integration/test-proxy.sh index c60f5e2945..50be88f482 100755 --- a/integration/test-proxy.sh +++ b/integration/test-proxy.sh @@ -11,21 +11,21 @@ do echo Test with $N requests mkdir -p ./logs/proxy/$N - echo Killing visors - echo Killing $(ps aux |grep "[V]isorA\|[V]isorB\|[V]isorC" |awk '{print $2}') - kill $(ps aux |grep "[V]isorA\|[V]isorB\|[V]isorC" |awk '{print $2}') + 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}') - # This sleep needed to allow clean exit of visor + # This sleep needed to allow clean exit of node sleep 10 - echo Restarting visorA and VisorB - ./bin/visor ./integration/proxy/visorA.json --tag VisorA &> ./logs/proxy/$N/visorA.log & - ./bin/visor ./integration/intermediary-visorB.json --tag VisorB &> ./logs/proxy/$N/visorB.log & + echo Restarting nodeA and NodeB + ./bin/skywire-networking-node ./integration/proxy/nodeA.json --tag NodeA &> ./logs/proxy/$N/nodeA.log & + ./bin/skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB &> ./logs/proxy/$N/nodeB.log & # TODO: improve this sleep sleep 5 - echo Restarting visorC - ./bin/visor ./integration/proxy/visorC.json --tag VisorC &> ./logs/proxy/$N/visorC.log & + echo Restarting nodeC + ./bin/skywire-networking-note ./integration/proxy/nodeC.json --tag NodeC &> ./logs/proxy/$N/nodeC.log & sleep 20 echo Trying socks5 proxy diff --git a/integration/test-ssh.sh b/integration/test-ssh.sh index 02974472af..22929635cd 100755 --- a/integration/test-ssh.sh +++ b/integration/test-ssh.sh @@ -11,14 +11,14 @@ do echo Test with $N lines mkdir -p ./logs/ssh/$N - echo Killing visors and SSH-cli - echo Killing $(ps aux |grep "[V]isorA\|[V]isorB\|[V]isorC\|[s]kywire/SSH-cli" |awk '{print $2}') - kill $(ps aux |grep "[V]isorA\|[V]isorB\|[V]isorC\|[s]kywire/SSH-cli" |awk '{print $2}') - - echo Restarting visors - ./bin/visor ./integration/ssh/visorA.json --tag VisorA &> ./logs/ssh/$N/visorA.log & - ./bin/visor ./integration/intermediary-visorB.json --tag VisorB &> ./logs/ssh/$N/visorB.log & - ./bin/visor ./integration/ssh/visorC.json --tag VisorC &> ./logs/ssh/$N/visorC.log & + echo Killing nodes and SSH-cli + echo Killing $(ps aux |grep "[N]odeA\|[N]odeB\|[N]odeC\|[s]kywire/SSH-cli" |awk '{print $2}') + kill $(ps aux |grep "[N]odeA\|[N]odeB\|[N]odeC\|[s]kywire/SSH-cli" |awk '{print $2}') + + echo Restarting nodes + ./bin/skywire-networking-node ./integration/ssh/nodeA.json --tag NodeA &> ./logs/ssh/$N/nodeA.log & + ./bin/skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB &> ./logs/ssh/$N/nodeB.log & + ./bin/skywire-networking-node ./integration/ssh/nodeC.json --tag NodeC &> ./logs/ssh/$N/nodeC.log & sleep 20 echo Trying SSH-cli diff --git a/internal/therealssh/client.go b/internal/therealssh/client.go index 2b9c02b98f..6d4130f8b6 100644 --- a/internal/therealssh/client.go +++ b/internal/therealssh/client.go @@ -20,7 +20,7 @@ import ( var r = netutil.NewRetrier(50*time.Millisecond, 5, 2) -// Dialer dials to a remote visor. +// Dialer dials to a remote node. type Dialer interface { Dial(raddr *app.Addr) (net.Conn, error) } diff --git a/pkg/app/app.go b/pkg/app/app.go index 7a3e131528..d0f40a2701 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -1,5 +1,5 @@ /* -Package app implements app to visor communication interface. +Package app implements app to node communication interface. */ package app @@ -16,10 +16,10 @@ import ( ) const ( - // DefaultIn holds value of inFd for Apps setup via Visor + // DefaultIn holds value of inFd for Apps setup via Node DefaultIn = uintptr(3) - // DefaultOut holds value of outFd for Apps setup via Visor + // DefaultOut holds value of outFd for Apps setup via Node DefaultOut = uintptr(4) ) @@ -111,7 +111,7 @@ func (app *App) Close() error { return app.proto.Close() } -// Accept awaits for incoming loop confirmation request from a Visor and +// Accept awaits for incoming loop confirmation request from a Node and // returns net.Conn for received loop. func (app *App) Accept() (net.Conn, error) { addrs := <-app.acceptChan @@ -127,7 +127,7 @@ func (app *App) Accept() (net.Conn, error) { return newAppConn(out, laddr, raddr), nil } -// Dial sends create loop request to a Visor and returns net.Conn for created loop. +// Dial sends create loop request to a Node and returns net.Conn for created loop. func (app *App) Dial(raddr *Addr) (net.Conn, error) { laddr := &Addr{} err := app.proto.Send(FrameCreateLoop, raddr, laddr) diff --git a/pkg/app/packet.go b/pkg/app/packet.go index e4d964d9cf..7fb8567b30 100644 --- a/pkg/app/packet.go +++ b/pkg/app/packet.go @@ -31,7 +31,7 @@ func (l *LoopAddr) String() string { return fmt.Sprintf(":%d <-> %s:%d", l.Port, l.Remote.PubKey, l.Remote.Port) } -// Packet represents message exchanged between App and Visor. +// Packet represents message exchanged between App and Node. type Packet struct { Addr *LoopAddr `json:"addr"` Payload []byte `json:"payload"` diff --git a/pkg/app/protocol.go b/pkg/app/protocol.go index 384645b3c8..dcdd20cdeb 100644 --- a/pkg/app/protocol.go +++ b/pkg/app/protocol.go @@ -48,7 +48,7 @@ const ( FrameSuccess = 0xff ) -// Protocol implements full-duplex protocol for App to Visor communication. +// Protocol implements full-duplex protocol for App to Node communication. type Protocol struct { rw io.ReadWriteCloser chans *chanList diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index d79e02f468..aaf8b82142 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -1,4 +1,4 @@ -// Package hypervisor implements visor manager +// Package hypervisor implements node manager package hypervisor import ( @@ -21,45 +21,45 @@ import ( "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("hypervisor") ) -type visorConn struct { +type appNodeConn struct { Addr *noise.Addr - Client visor.RPCClient + Client node.RPCClient } -// Hypervisor manages Visors. -type Hypervisor struct { - c Config - visors map[cipher.PubKey]visorConn // connected remote visors. - users *UserManager - mu *sync.RWMutex +// Node manages AppNodes. +type Node struct { + c Config + nodes map[cipher.PubKey]appNodeConn // connected remote nodes. + users *UserManager + mu *sync.RWMutex } -// New creates a new Hypervisor. -func New(config Config) (*Hypervisor, error) { +// NewNode creates a new Node. +func NewNode(config Config) (*Node, error) { boltUserDB, err := NewBoltUserStore(config.DBPath) if err != nil { return nil, err } singleUserDB := NewSingleUserStore("admin", boltUserDB) - return &Hypervisor{ - c: config, - visors: make(map[cipher.PubKey]visorConn), - users: NewUserManager(singleUserDB, config.Cookies), - mu: new(sync.RWMutex), + return &Node{ + c: config, + nodes: make(map[cipher.PubKey]appNodeConn), + users: NewUserManager(singleUserDB, config.Cookies), + mu: new(sync.RWMutex), }, nil } -// ServeRPC serves RPC of a Visor. -func (m *Hypervisor) ServeRPC(lis net.Listener) error { +// ServeRPC serves RPC of a Node. +func (m *Node) ServeRPC(lis net.Listener) error { for { conn, err := noise.WrapListener(lis, m.c.PK, m.c.SK, false, noise.HandshakeXK).Accept() if err != nil { @@ -67,9 +67,9 @@ func (m *Hypervisor) ServeRPC(lis net.Listener) error { } addr := conn.RemoteAddr().(*noise.Addr) m.mu.RLock() - m.visors[addr.PK] = visorConn{ + m.nodes[addr.PK] = appNodeConn{ Addr: addr, - Client: visor.NewRPCClient(rpc.NewClient(conn), visor.RPCPrefix), + Client: node.NewRPCClient(rpc.NewClient(conn), node.RPCPrefix), } m.mu.RUnlock() } @@ -82,19 +82,19 @@ func (a mockAddr) String() string { return string(a) } // MockConfig configures how mock data is to be added. type MockConfig struct { - Visors int - MaxTpsPerVisor int - MaxRoutesPerVisor int - EnableAuth bool + Nodes int + MaxTpsPerNode int + MaxRoutesPerNode int + EnableAuth bool } -// AddMockData adds mock data to Hypervisor. -func (m *Hypervisor) AddMockData(config MockConfig) error { +// 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.Visors; i++ { - pk, client := visor.NewMockRPCClient(r, config.MaxTpsPerVisor, config.MaxRoutesPerVisor) + for i := 0; i < config.Nodes; i++ { + pk, client := node.NewMockRPCClient(r, config.MaxTpsPerNode, config.MaxRoutesPerNode) m.mu.Lock() - m.visors[pk] = visorConn{ + m.nodes[pk] = appNodeConn{ Addr: &noise.Addr{ PK: pk, Addr: mockAddr(fmt.Sprintf("0.0.0.0:%d", i)), @@ -108,7 +108,7 @@ func (m *Hypervisor) AddMockData(config MockConfig) error { } // ServeHTTP implements http.Handler -func (m *Hypervisor) ServeHTTP(w http.ResponseWriter, req *http.Request) { +func (m *Node) ServeHTTP(w http.ResponseWriter, req *http.Request) { r := chi.NewRouter() r.Use(middleware.Timeout(time.Second * 30)) r.Use(middleware.Logger) @@ -126,8 +126,8 @@ func (m *Hypervisor) ServeHTTP(w http.ResponseWriter, req *http.Request) { } r.Get("/user", m.users.UserInfo()) r.Post("/change-password", m.users.ChangePassword()) - r.Get("/nodes", m.getVisors()) - r.Get("/nodes/{pk}", m.getVisor()) + r.Get("/nodes", m.getNodes()) + r.Get("/nodes/{pk}", m.getNode()) r.Get("/nodes/{pk}/apps", m.getApps()) r.Get("/nodes/{pk}/apps/{app}", m.getApp()) r.Put("/nodes/{pk}/apps/{app}", m.putApp()) @@ -149,19 +149,19 @@ func (m *Hypervisor) ServeHTTP(w http.ResponseWriter, req *http.Request) { type summaryResp struct { TCPAddr string `json:"tcp_addr"` - *visor.Summary + *node.Summary } -// provides summary of all visors. -func (m *Hypervisor) getVisors() http.HandlerFunc { +// provides summary of all nodes. +func (m *Node) getNodes() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var summaries []summaryResp m.mu.RLock() - for pk, c := range m.visors { + for pk, c := range m.nodes { summary, err := c.Client.Summary() if err != nil { - log.Printf("failed to obtain summary from Visor with pk %s. Error: %v", pk, err) - summary = &visor.Summary{PubKey: pk} + log.Printf("failed to obtain summary from AppNode with pk %s. Error: %v", pk, err) + summary = &node.Summary{PubKey: pk} } summaries = append(summaries, summaryResp{ TCPAddr: c.Addr.Addr.String(), @@ -173,9 +173,9 @@ func (m *Hypervisor) getVisors() http.HandlerFunc { } } -// provides summary of single visor. -func (m *Hypervisor) getVisor() http.HandlerFunc { - return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +// provides summary of single node. +func (m *Node) getNode() http.HandlerFunc { + return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { summary, err := ctx.RPC.Summary() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) @@ -188,9 +188,9 @@ func (m *Hypervisor) getVisor() http.HandlerFunc { }) } -// returns app summaries of a given visor of pk -func (m *Hypervisor) getApps() http.HandlerFunc { - return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +// returns app summaries of a given node of pk +func (m *Node) getApps() http.HandlerFunc { + return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { apps, err := ctx.RPC.Apps() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) @@ -200,14 +200,14 @@ func (m *Hypervisor) getApps() http.HandlerFunc { }) } -// returns an app summary of a given visor's pk and app name -func (m *Hypervisor) getApp() http.HandlerFunc { +// returns an app summary of a given node's pk and app name +func (m *Node) getApp() http.HandlerFunc { return m.withCtx(m.appCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { httputil.WriteJSON(w, r, http.StatusOK, ctx.App) }) } -func (m *Hypervisor) putApp() http.HandlerFunc { +func (m *Node) putApp() http.HandlerFunc { return m.withCtx(m.appCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { var reqBody struct { Autostart *bool `json:"autostart,omitempty"` @@ -246,8 +246,8 @@ func (m *Hypervisor) putApp() http.HandlerFunc { }) } -func (m *Hypervisor) getTransportTypes() http.HandlerFunc { - return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Node) getTransportTypes() http.HandlerFunc { + return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { types, err := ctx.RPC.TransportTypes() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) @@ -257,8 +257,8 @@ func (m *Hypervisor) getTransportTypes() http.HandlerFunc { }) } -func (m *Hypervisor) getTransports() http.HandlerFunc { - return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Node) getTransports() http.HandlerFunc { + return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { var ( qTypes []string qPKs []cipher.PubKey @@ -283,8 +283,8 @@ func (m *Hypervisor) getTransports() http.HandlerFunc { }) } -func (m *Hypervisor) postTransport() http.HandlerFunc { - return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Node) postTransport() http.HandlerFunc { + return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { var reqBody struct { Remote cipher.PubKey `json:"remote_pk"` TpType string `json:"transport_type"` @@ -303,13 +303,13 @@ func (m *Hypervisor) postTransport() http.HandlerFunc { }) } -func (m *Hypervisor) getTransport() http.HandlerFunc { +func (m *Node) getTransport() http.HandlerFunc { return m.withCtx(m.tpCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { httputil.WriteJSON(w, r, http.StatusOK, ctx.Tp) }) } -func (m *Hypervisor) deleteTransport() http.HandlerFunc { +func (m *Node) deleteTransport() http.HandlerFunc { return m.withCtx(m.tpCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { if err := ctx.RPC.RemoveTransport(ctx.Tp.ID); err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) @@ -336,8 +336,8 @@ func makeRoutingRuleResp(key routing.RouteID, rule routing.Rule, summary bool) r return resp } -func (m *Hypervisor) getRoutes() http.HandlerFunc { - return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Node) getRoutes() http.HandlerFunc { + return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { qSummary, err := httputil.BoolFromQuery(r, "summary", false) if err != nil { httputil.WriteJSON(w, r, http.StatusBadRequest, err) @@ -356,8 +356,8 @@ func (m *Hypervisor) getRoutes() http.HandlerFunc { }) } -func (m *Hypervisor) postRoute() http.HandlerFunc { - return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Node) postRoute() http.HandlerFunc { + return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { var summary routing.RuleSummary if err := httputil.ReadJSON(r, &summary); err != nil { httputil.WriteJSON(w, r, http.StatusBadRequest, err) @@ -377,7 +377,7 @@ func (m *Hypervisor) postRoute() http.HandlerFunc { }) } -func (m *Hypervisor) getRoute() http.HandlerFunc { +func (m *Node) getRoute() http.HandlerFunc { return m.withCtx(m.routeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { qSummary, err := httputil.BoolFromQuery(r, "summary", true) if err != nil { @@ -393,7 +393,7 @@ func (m *Hypervisor) getRoute() http.HandlerFunc { }) } -func (m *Hypervisor) putRoute() http.HandlerFunc { +func (m *Node) putRoute() http.HandlerFunc { return m.withCtx(m.routeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { var summary routing.RuleSummary if err := httputil.ReadJSON(r, &summary); err != nil { @@ -413,7 +413,7 @@ func (m *Hypervisor) putRoute() http.HandlerFunc { }) } -func (m *Hypervisor) deleteRoute() http.HandlerFunc { +func (m *Node) deleteRoute() http.HandlerFunc { return m.withCtx(m.routeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { if err := ctx.RPC.RemoveRoutingRule(ctx.RtKey); err != nil { httputil.WriteJSON(w, r, http.StatusNotFound, err) @@ -428,7 +428,7 @@ type loopResp struct { FwdRule routing.RuleForwardFields `json:"resp"` } -func makeLoopResp(info visor.LoopInfo) loopResp { +func makeLoopResp(info node.LoopInfo) loopResp { if len(info.FwdRule) == 0 || len(info.AppRule) == 0 { return loopResp{} } @@ -438,8 +438,8 @@ func makeLoopResp(info visor.LoopInfo) loopResp { } } -func (m *Hypervisor) getLoops() http.HandlerFunc { - return m.withCtx(m.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { +func (m *Node) getLoops() http.HandlerFunc { + return m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) { loops, err := ctx.RPC.Loops() if err != nil { httputil.WriteJSON(w, r, http.StatusInternalServerError, err) @@ -457,24 +457,24 @@ func (m *Hypervisor) getLoops() http.HandlerFunc { <<< Helper functions >>> */ -func (m *Hypervisor) client(pk cipher.PubKey) (*noise.Addr, visor.RPCClient, bool) { +func (m *Node) client(pk cipher.PubKey) (*noise.Addr, node.RPCClient, bool) { m.mu.RLock() - conn, ok := m.visors[pk] + conn, ok := m.nodes[pk] m.mu.RUnlock() return conn.Addr, conn.Client, ok } type httpCtx struct { - // Visor + // Node PK cipher.PubKey Addr *noise.Addr - RPC visor.RPCClient + RPC node.RPCClient // App - App *visor.AppState + App *node.AppState // Transport - Tp *visor.TransportSummary + Tp *node.TransportSummary // Route RtKey routing.RouteID @@ -485,7 +485,7 @@ type ( handlerFunc func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) ) -func (m *Hypervisor) withCtx(vFunc valuesFunc, hFunc handlerFunc) http.HandlerFunc { +func (m *Node) withCtx(vFunc valuesFunc, hFunc handlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if rv, ok := vFunc(w, r); ok { hFunc(w, r, rv) @@ -493,7 +493,7 @@ func (m *Hypervisor) withCtx(vFunc valuesFunc, hFunc handlerFunc) http.HandlerFu } } -func (m *Hypervisor) visorCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { +func (m *Node) nodeCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { pk, err := pkFromParam(r, "pk") if err != nil { httputil.WriteJSON(w, r, http.StatusBadRequest, err) @@ -501,7 +501,7 @@ func (m *Hypervisor) visorCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, } addr, client, ok := m.client(pk) if !ok { - httputil.WriteJSON(w, r, http.StatusNotFound, fmt.Errorf("visor of pk '%s' not found", pk)) + httputil.WriteJSON(w, r, http.StatusNotFound, fmt.Errorf("node of pk '%s' not found", pk)) return nil, false } return &httpCtx{ @@ -511,8 +511,8 @@ func (m *Hypervisor) visorCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, }, true } -func (m *Hypervisor) appCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { - ctx, ok := m.visorCtx(w, r) +func (m *Node) appCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { + ctx, ok := m.nodeCtx(w, r) if !ok { return nil, false } @@ -529,11 +529,11 @@ func (m *Hypervisor) appCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, b } } httputil.WriteJSON(w, r, http.StatusNotFound, - fmt.Errorf("can not find app of name %s from visor %s", appName, ctx.PK)) + fmt.Errorf("can not find app of name %s from node %s", appName, ctx.PK)) return nil, false } -func (m *Hypervisor) tpCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { +func (m *Node) tpCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { ctx, ok := m.appCtx(w, r) if !ok { return nil, false @@ -545,7 +545,7 @@ func (m *Hypervisor) tpCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bo } tp, err := ctx.RPC.Transport(tid) if err != nil { - if err.Error() == visor.ErrNotFound.Error() { + if err.Error() == node.ErrNotFound.Error() { httputil.WriteJSON(w, r, http.StatusNotFound, fmt.Errorf("transport of ID %s is not found", tid)) return nil, false @@ -557,7 +557,7 @@ func (m *Hypervisor) tpCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bo return ctx, true } -func (m *Hypervisor) routeCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { +func (m *Node) routeCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) { ctx, ok := m.tpCtx(w, r) if !ok { return nil, false diff --git a/pkg/hypervisor/hypervisor_test.go b/pkg/hypervisor/hypervisor_test.go index c574402490..74becc374e 100644 --- a/pkg/hypervisor/hypervisor_test.go +++ b/pkg/hypervisor/hypervisor_test.go @@ -33,7 +33,7 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -func TestNew(t *testing.T) { +func TestNewNode(t *testing.T) { config := makeConfig() confDir, err := ioutil.TempDir(os.TempDir(), "SWHV") @@ -42,20 +42,20 @@ func TestNew(t *testing.T) { defaultMockConfig := func() MockConfig { return MockConfig{ - Visors: 5, - MaxTpsPerVisor: 10, - MaxRoutesPerVisor: 10, - EnableAuth: true, + Nodes: 5, + MaxTpsPerNode: 10, + MaxRoutesPerNode: 10, + EnableAuth: true, } } - startHypervisor := func(mock MockConfig) (string, *http.Client, func()) { - hypervisor, err := New(config) + startNode := func(mock MockConfig) (string, *http.Client, func()) { + node, err := NewNode(config) require.NoError(t, err) - require.NoError(t, hypervisor.AddMockData(mock)) + require.NoError(t, node.AddMockData(mock)) - srv := httptest.NewTLSServer(hypervisor) - hypervisor.c.Cookies.Domain = srv.Listener.Addr().String() + srv := httptest.NewTLSServer(node) + node.c.Cookies.Domain = srv.Listener.Addr().String() client := srv.Client() jar, err := cookiejar.New(&cookiejar.Options{}) @@ -94,7 +94,7 @@ func TestNew(t *testing.T) { } t.Run("no_access_without_login", func(t *testing.T) { - addr, client, stop := startHypervisor(defaultMockConfig()) + addr, client, stop := startNode(defaultMockConfig()) defer stop() makeCase := func(method string, uri string, body io.Reader) TestCase { @@ -119,7 +119,7 @@ func TestNew(t *testing.T) { }) t.Run("only_admin_account_allowed", func(t *testing.T) { - addr, client, stop := startHypervisor(defaultMockConfig()) + addr, client, stop := startNode(defaultMockConfig()) defer stop() testCases(t, addr, client, []TestCase{ @@ -149,7 +149,7 @@ func TestNew(t *testing.T) { }) t.Run("cannot_login_twice", func(t *testing.T) { - addr, client, stop := startHypervisor(defaultMockConfig()) + addr, client, stop := startNode(defaultMockConfig()) defer stop() testCases(t, addr, client, []TestCase{ @@ -190,7 +190,7 @@ func TestNew(t *testing.T) { }) t.Run("access_after_login", func(t *testing.T) { - addr, client, stop := startHypervisor(defaultMockConfig()) + addr, client, stop := startNode(defaultMockConfig()) defer stop() testCases(t, addr, client, []TestCase{ @@ -230,7 +230,7 @@ func TestNew(t *testing.T) { }) t.Run("no_access_after_logout", func(t *testing.T) { - addr, client, stop := startHypervisor(defaultMockConfig()) + addr, client, stop := startNode(defaultMockConfig()) defer stop() testCases(t, addr, client, []TestCase{ @@ -297,7 +297,7 @@ func TestNew(t *testing.T) { // - Login with old password (should fail). // - Login with new password (should succeed). - addr, client, stop := startHypervisor(defaultMockConfig()) + addr, client, stop := startNode(defaultMockConfig()) defer stop() testCases(t, addr, client, []TestCase{ diff --git a/pkg/visor/config.go b/pkg/node/config.go similarity index 91% rename from pkg/visor/config.go rename to pkg/node/config.go index 3124afa02c..3f8daf8942 100644 --- a/pkg/visor/config.go +++ b/pkg/node/config.go @@ -1,4 +1,4 @@ -package visor +package node import ( "encoding/json" @@ -17,14 +17,14 @@ import ( "github.com/skycoin/skywire/pkg/transport/dmsg" ) -// Config defines configuration parameters for Visor. +// Config defines configuration parameters for Node. type Config struct { Version string `json:"version"` - Visor struct { + Node struct { StaticPubKey cipher.PubKey `json:"static_public_key"` StaticSecKey cipher.SecKey `json:"static_secret_key"` - } `json:"visor"` + } `json:"node"` Messaging struct { Discovery string `json:"discovery"` @@ -51,8 +51,8 @@ type Config struct { Apps []AppConfig `json:"apps"` - TrustedVisors []cipher.PubKey `json:"trusted_visors"` - Hypervisors []HypervisorConfig `json:"hypervisors"` + TrustedNodes []cipher.PubKey `json:"trusted_nodes"` + Hypervisors []HypervisorConfig `json:"hypervisors"` AppsPath string `json:"apps_path"` LocalPath string `json:"local_path"` @@ -73,8 +73,8 @@ func (c *Config) MessagingConfig() (*dmsg.Config, error) { } return &dmsg.Config{ - PubKey: c.Visor.StaticPubKey, - SecKey: c.Visor.StaticSecKey, + PubKey: c.Node.StaticPubKey, + SecKey: c.Node.StaticSecKey, Discovery: disc.NewHTTP(msgConfig.Discovery), Retries: 5, RetryDelay: time.Second, @@ -87,7 +87,7 @@ func (c *Config) TransportDiscovery() (transport.DiscoveryClient, error) { return nil, errors.New("empty transport_discovery") } - return trClient.NewHTTP(c.Transport.Discovery, c.Visor.StaticPubKey, c.Visor.StaticSecKey) + return trClient.NewHTTP(c.Transport.Discovery, c.Node.StaticPubKey, c.Node.StaticSecKey) } // TransportLogStore returns configure transport.LogStore. @@ -173,7 +173,7 @@ type AppConfig struct { Args []string `json:"args"` } -// InterfaceConfig defines listening interfaces for skywire Visor. +// InterfaceConfig defines listening interfaces for skywire networking node. 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/visor/config_test.go b/pkg/node/config_test.go similarity index 97% rename from pkg/visor/config_test.go rename to pkg/node/config_test.go index e0be3c6f8b..abc7a6a746 100644 --- a/pkg/visor/config_test.go +++ b/pkg/node/config_test.go @@ -1,4 +1,4 @@ -package visor +package node import ( "encoding/json" @@ -20,8 +20,8 @@ import ( func TestMessagingDiscovery(t *testing.T) { pk, sk := cipher.GenerateKeyPair() conf := Config{} - conf.Visor.StaticPubKey = pk - conf.Visor.StaticSecKey = sk + conf.Node.StaticPubKey = pk + conf.Node.StaticSecKey = sk conf.Messaging.Discovery = "skywire.skycoin.net:8001" conf.Messaging.ServerCount = 10 diff --git a/pkg/visor/visor.go b/pkg/node/node.go similarity index 56% rename from pkg/visor/visor.go rename to pkg/node/node.go index f07bbfecfe..26f1dff199 100644 --- a/pkg/visor/visor.go +++ b/pkg/node/node.go @@ -1,5 +1,5 @@ -// Package visor implements skywire visor. -package visor +// Package node implements skywire networking node. +package node import ( "bufio" @@ -45,7 +45,7 @@ const ( // ErrUnknownApp represents lookup error for App related calls. var ErrUnknownApp = errors.New("unknown app") -// Version is the visor version. +// Version is the node version. const Version = "0.0.1" const supportedProtocolVersion = "0.0.1" @@ -79,9 +79,9 @@ type PacketRouter interface { IsSetupTransport(tr *transport.ManagedTransport) bool } -// Visor provides messaging runtime for Apps by setting up all +// Node provides messaging runtime for Apps by setting up all // necessary connections and performing messaging gateway functions. -type Visor struct { +type Node struct { config *Config router PacketRouter messenger *dmsg.Client @@ -105,25 +105,25 @@ type Visor struct { rpcDialers []*noise.RPCClientDialer } -// New constructs new Visor. -func New(config *Config, masterLogger *logging.MasterLogger) (*Visor, error) { - visor := &Visor{ +// NewNode constructs new Node. +func NewNode(config *Config, masterLogger *logging.MasterLogger) (*Node, error) { + node := &Node{ config: config, executer: newOSExecuter(), startedApps: make(map[string]*appBind), } - visor.Logger = masterLogger - visor.logger = visor.Logger.PackageLogger("skywire") + node.Logger = masterLogger + node.logger = node.Logger.PackageLogger("skywire") - pk := config.Visor.StaticPubKey - sk := config.Visor.StaticSecKey + pk := config.Node.StaticPubKey + sk := config.Node.StaticSecKey mConfig, err := config.MessagingConfig() if err != nil { return nil, fmt.Errorf("invalid Messaging config: %s", err) } - visor.messenger = dmsg.NewClient(mConfig.PubKey, mConfig.SecKey, mConfig.Discovery, dmsg.SetLogger(visor.Logger.PackageLogger(dmsg.Type))) + node.messenger = dmsg.NewClient(mConfig.PubKey, mConfig.SecKey, mConfig.Discovery, dmsg.SetLogger(node.Logger.PackageLogger(dmsg.Type))) trDiscovery, err := config.TransportDiscovery() if err != nil { @@ -137,47 +137,47 @@ func New(config *Config, masterLogger *logging.MasterLogger) (*Visor, error) { PubKey: pk, SecKey: sk, DiscoveryClient: trDiscovery, LogStore: logStore, - DefaultVisors: config.TrustedVisors, + DefaultNodes: config.TrustedNodes, } - visor.tm, err = transport.NewManager(tmConfig, visor.messenger) + node.tm, err = transport.NewManager(tmConfig, node.messenger) if err != nil { return nil, fmt.Errorf("transport manager: %s", err) } - visor.tm.Logger = visor.Logger.PackageLogger("trmanager") + node.tm.Logger = node.Logger.PackageLogger("trmanager") - visor.rt, err = config.RoutingTable() + node.rt, err = config.RoutingTable() if err != nil { return nil, fmt.Errorf("routing table: %s", err) } rConfig := &router.Config{ - Logger: visor.Logger.PackageLogger("router"), + Logger: node.Logger.PackageLogger("router"), PubKey: pk, SecKey: sk, - TransportManager: visor.tm, - RoutingTable: visor.rt, + TransportManager: node.tm, + RoutingTable: node.rt, RouteFinder: routeFinder.NewHTTP(config.Routing.RouteFinder, time.Duration(config.Routing.RouteFinderTimeout)), SetupNodes: config.Routing.SetupNodes, } r := router.New(rConfig) - visor.router = r + node.router = r - visor.appsConf, err = config.AppsConfig() + node.appsConf, err = config.AppsConfig() if err != nil { return nil, fmt.Errorf("invalid AppsConfig: %s", err) } - visor.appsPath, err = config.AppsDir() + node.appsPath, err = config.AppsDir() if err != nil { return nil, fmt.Errorf("invalid AppsPath: %s", err) } - visor.localPath, err = config.LocalDir() + node.localPath, err = config.LocalDir() if err != nil { return nil, fmt.Errorf("invalid LocalPath: %s", err) } if lvl, err := logging.LevelFromString(config.LogLevel); err == nil { - visor.Logger.SetLevel(lvl) + node.Logger.SetLevel(lvl) } if config.Interfaces.RPCAddress != "" { @@ -185,11 +185,11 @@ func New(config *Config, masterLogger *logging.MasterLogger) (*Visor, error) { if err != nil { return nil, fmt.Errorf("failed to setup RPC listener: %s", err) } - visor.rpcListener = l + node.rpcListener = l } - visor.rpcDialers = make([]*noise.RPCClientDialer, len(config.Hypervisors)) + node.rpcDialers = make([]*noise.RPCClientDialer, len(config.Hypervisors)) for i, entry := range config.Hypervisors { - visor.rpcDialers[i] = noise.NewRPCClientDialer(entry.Addr, noise.HandshakeXK, noise.Config{ + node.rpcDialers[i] = noise.NewRPCClientDialer(entry.Addr, noise.HandshakeXK, noise.Config{ LocalPK: pk, LocalSK: sk, RemotePK: entry.PubKey, @@ -197,62 +197,62 @@ func New(config *Config, masterLogger *logging.MasterLogger) (*Visor, error) { }) } - return visor, err + return node, err } // Start spawns auto-started Apps, starts router and RPC interfaces . -func (visor *Visor) Start() error { +func (node *Node) Start() error { ctx := context.Background() - err := visor.messenger.InitiateServerConnections(ctx, visor.config.Messaging.ServerCount) + err := node.messenger.InitiateServerConnections(ctx, node.config.Messaging.ServerCount) if err != nil { return fmt.Errorf("%s: %s", dmsg.Type, err) } - visor.logger.Info("Connected to messaging servers") + node.logger.Info("Connected to messaging servers") - pathutil.EnsureDir(visor.dir()) - visor.closePreviousApps() - for _, ac := range visor.appsConf { + pathutil.EnsureDir(node.dir()) + node.closePreviousApps() + for _, ac := range node.appsConf { if !ac.AutoStart { continue } go func(a AppConfig) { - if err := visor.SpawnApp(&a, nil); err != nil { - visor.logger.Warnf("Failed to start %s: %s\n", a.App, err) + if err := node.SpawnApp(&a, nil); err != nil { + node.logger.Warnf("Failed to start %s: %s\n", a.App, err) } }(ac) } rpcSvr := rpc.NewServer() - if err := rpcSvr.RegisterName(RPCPrefix, &RPC{visor: visor}); err != nil { + if err := rpcSvr.RegisterName(RPCPrefix, &RPC{node: node}); err != nil { return fmt.Errorf("rpc server created failed: %s", err) } - if visor.rpcListener != nil { - visor.logger.Info("Starting RPC interface on ", visor.rpcListener.Addr()) - go rpcSvr.Accept(visor.rpcListener) + if node.rpcListener != nil { + node.logger.Info("Starting RPC interface on ", node.rpcListener.Addr()) + go rpcSvr.Accept(node.rpcListener) } - for _, dialer := range visor.rpcDialers { + for _, dialer := range node.rpcDialers { go func(dialer *noise.RPCClientDialer) { if err := dialer.Run(rpcSvr, time.Second); err != nil { - visor.logger.Errorf("Dialer exited with error: %v", err) + node.logger.Errorf("Dialer exited with error: %v", err) } }(dialer) } - visor.logger.Info("Starting packet router") - if err := visor.router.Serve(ctx); err != nil { - return fmt.Errorf("failed to start Visor: %s", err) + node.logger.Info("Starting packet router") + if err := node.router.Serve(ctx); err != nil { + return fmt.Errorf("failed to start Node: %s", err) } return nil } -func (visor *Visor) dir() string { - return pathutil.VisorDir(visor.config.Visor.StaticPubKey) +func (node *Node) dir() string { + return pathutil.NodeDir(node.config.Node.StaticPubKey) } -func (visor *Visor) pidFile() *os.File { - f, err := os.OpenFile(filepath.Join(visor.dir(), "apps-pid.txt"), os.O_RDWR|os.O_CREATE, 0600) +func (node *Node) pidFile() *os.File { + f, err := os.OpenFile(filepath.Join(node.dir(), "apps-pid.txt"), os.O_RDWR|os.O_CREATE, 0600) if err != nil { panic(err) } @@ -260,36 +260,36 @@ func (visor *Visor) pidFile() *os.File { return f } -func (visor *Visor) closePreviousApps() { - visor.logger.Info("killing previously ran apps if any...") +func (node *Node) closePreviousApps() { + node.logger.Info("killing previously ran apps if any...") - pids := visor.pidFile() + pids := node.pidFile() defer pids.Close() // nocheck: err scanner := bufio.NewScanner(pids) for scanner.Scan() { appInfo := strings.Split(scanner.Text(), " ") if len(appInfo) != 2 { - visor.logger.Fatal("error parsing %s. Err: %s", pids.Name(), errors.New("line should be: [app name] [pid]")) + node.logger.Fatal("error parsing %s. Err: %s", pids.Name(), errors.New("line should be: [app name] [pid]")) } pid, err := strconv.Atoi(appInfo[1]) if err != nil { - visor.logger.Fatal("error parsing %s. Err: %s", pids.Name(), err) + node.logger.Fatal("error parsing %s. Err: %s", pids.Name(), err) } - visor.stopUnhandledApp(appInfo[0], pid) + node.stopUnhandledApp(appInfo[0], pid) } // empty file pathutil.AtomicWriteFile(pids.Name(), []byte{}) } -func (visor *Visor) stopUnhandledApp(name string, pid int) { +func (node *Node) stopUnhandledApp(name string, pid int) { p, err := os.FindProcess(pid) if err != nil { if runtime.GOOS != "windows" { - visor.logger.Infof("Previous app %s ran by this visor with pid: %d not found", name, pid) + node.logger.Infof("Previous app %s ran by this node with pid: %d not found", name, pid) } return } @@ -299,55 +299,55 @@ func (visor *Visor) stopUnhandledApp(name string, pid int) { return } - visor.logger.Infof("Found and killed hanged app %s with pid %d previously ran by this visor", name, pid) + node.logger.Infof("Found and killed hanged app %s with pid %d previously ran by this node", name, pid) } -// Close safely stops spawned Apps and messaging Visor. -func (visor *Visor) Close() (err error) { - if visor == nil { +// Close safely stops spawned Apps and messaging Node. +func (node *Node) Close() (err error) { + if node == nil { return nil } - if visor.rpcListener != nil { - if err = visor.rpcListener.Close(); err != nil { - visor.logger.WithError(err).Error("failed to stop RPC interface") + if node.rpcListener != nil { + if err = node.rpcListener.Close(); err != nil { + node.logger.WithError(err).Error("failed to stop RPC interface") } else { - visor.logger.Info("RPC interface stopped successfully") + node.logger.Info("RPC interface stopped successfully") } } - for i, dialer := range visor.rpcDialers { + for i, dialer := range node.rpcDialers { if err = dialer.Close(); err != nil { - visor.logger.WithError(err).Errorf("(%d) failed to stop RPC dialer", i) + node.logger.WithError(err).Errorf("(%d) failed to stop RPC dialer", i) } else { - visor.logger.Infof("(%d) RPC dialer closed successfully", i) + node.logger.Infof("(%d) RPC dialer closed successfully", i) } } - visor.startedMu.Lock() - for a, bind := range visor.startedApps { - if err = visor.stopApp(a, bind); err != nil { - visor.logger.WithError(err).Errorf("(%s) failed to stop app", a) + node.startedMu.Lock() + for a, bind := range node.startedApps { + if err = node.stopApp(a, bind); err != nil { + node.logger.WithError(err).Errorf("(%s) failed to stop app", a) } else { - visor.logger.Infof("(%s) app stopped successfully", a) + node.logger.Infof("(%s) app stopped successfully", a) } } - visor.startedMu.Unlock() - if err = visor.router.Close(); err != nil { - visor.logger.WithError(err).Error("failed to stop router") + node.startedMu.Unlock() + if err = node.router.Close(); err != nil { + node.logger.WithError(err).Error("failed to stop router") } else { - visor.logger.Info("router stopped successfully") + node.logger.Info("router stopped successfully") } return err } // Apps returns list of AppStates for all registered apps. -func (visor *Visor) Apps() []*AppState { +func (node *Node) Apps() []*AppState { res := []*AppState{} - for _, app := range visor.appsConf { + for _, app := range node.appsConf { state := &AppState{app.App, app.AutoStart, app.Port, AppStatusStopped} - visor.startedMu.RLock() - if visor.startedApps[app.App] != nil { + node.startedMu.RLock() + if node.startedApps[app.App] != nil { state.Status = AppStatusRunning } - visor.startedMu.RUnlock() + node.startedMu.RUnlock() res = append(res, state) } @@ -356,13 +356,13 @@ func (visor *Visor) Apps() []*AppState { } // StartApp starts registered App. -func (visor *Visor) StartApp(appName string) error { - for _, app := range visor.appsConf { +func (node *Node) StartApp(appName string) error { + for _, app := range node.appsConf { if app.App == appName { startCh := make(chan struct{}) go func() { - if err := visor.SpawnApp(&app, startCh); err != nil { - visor.logger.Warnf("Failed to start app %s: %s", appName, err) + if err := node.SpawnApp(&app, startCh); err != nil { + node.logger.Warnf("Failed to start app %s: %s", appName, err) } }() @@ -375,11 +375,11 @@ func (visor *Visor) StartApp(appName string) error { } // SpawnApp configures and starts new App. -func (visor *Visor) SpawnApp(config *AppConfig, startCh chan<- struct{}) error { - visor.logger.Infof("Starting %s.v%s", config.App, config.Version) +func (node *Node) SpawnApp(config *AppConfig, startCh chan<- struct{}) error { + node.logger.Infof("Starting %s.v%s", config.App, config.Version) conn, cmd, err := app.Command( &app.Config{ProtocolVersion: supportedProtocolVersion, AppName: config.App, AppVersion: config.Version}, - visor.appsPath, + node.appsPath, config.Args, ) if err != nil { @@ -391,48 +391,48 @@ func (visor *Visor) SpawnApp(config *AppConfig, startCh chan<- struct{}) error { return fmt.Errorf("can't bind to reserved port %d", config.Port) } - visor.startedMu.Lock() - if visor.startedApps[config.App] != nil { - visor.startedMu.Unlock() + node.startedMu.Lock() + if node.startedApps[config.App] != nil { + node.startedMu.Unlock() return fmt.Errorf("app %s is already started", config.App) } - visor.startedApps[config.App] = bind - visor.startedMu.Unlock() + node.startedApps[config.App] = bind + node.startedMu.Unlock() // TODO: make PackageLogger return *Entry. FieldLogger doesn't expose Writer. - logger := visor.logger.WithField("_module", fmt.Sprintf("%s.v%s", config.App, config.Version)).Writer() + logger := node.logger.WithField("_module", fmt.Sprintf("%s.v%s", config.App, config.Version)).Writer() defer logger.Close() cmd.Stdout = logger cmd.Stderr = logger - cmd.Dir = filepath.Join(visor.localPath, config.App, fmt.Sprintf("v%s", config.Version)) + cmd.Dir = filepath.Join(node.localPath, config.App, fmt.Sprintf("v%s", config.Version)) if _, err := ensureDir(cmd.Dir); err != nil { return err } appCh := make(chan error) go func() { - pid, err := visor.executer.Start(cmd) + pid, err := node.executer.Start(cmd) if err != nil { appCh <- err return } - visor.startedMu.Lock() + node.startedMu.Lock() bind.pid = pid - visor.startedMu.Unlock() + node.startedMu.Unlock() - visor.pidMu.Lock() - visor.logger.Infof("storing app %s pid %d", config.App, pid) - visor.persistPID(config.App, pid) - visor.pidMu.Unlock() - appCh <- visor.executer.Wait(cmd) + node.pidMu.Lock() + node.logger.Infof("storing app %s pid %d", config.App, pid) + node.persistPID(config.App, pid) + node.pidMu.Unlock() + appCh <- node.executer.Wait(cmd) }() srvCh := make(chan error) go func() { - srvCh <- visor.router.ServeApp(conn, config.Port, &app.Config{AppName: config.App, AppVersion: config.Version}) + srvCh <- node.router.ServeApp(conn, config.Port, &app.Config{AppName: config.App, AppVersion: config.Version}) }() if startCh != nil { @@ -453,15 +453,15 @@ func (visor *Visor) SpawnApp(config *AppConfig, startCh chan<- struct{}) error { } } - visor.startedMu.Lock() - delete(visor.startedApps, config.App) - visor.startedMu.Unlock() + node.startedMu.Lock() + delete(node.startedApps, config.App) + node.startedMu.Unlock() return appErr } -func (visor *Visor) persistPID(name string, pid int) { - pidF := visor.pidFile() +func (node *Node) persistPID(name string, pid int) { + pidF := node.pidFile() pidFName := pidF.Name() pidF.Close() @@ -469,39 +469,39 @@ func (visor *Visor) persistPID(name string, pid int) { } // StopApp stops running App. -func (visor *Visor) StopApp(appName string) error { - visor.startedMu.Lock() - bind := visor.startedApps[appName] - visor.startedMu.Unlock() +func (node *Node) StopApp(appName string) error { + node.startedMu.Lock() + bind := node.startedApps[appName] + node.startedMu.Unlock() if bind == nil { return ErrUnknownApp } - return visor.stopApp(appName, bind) + return node.stopApp(appName, bind) } // SetAutoStart sets an app to auto start or not. -func (visor *Visor) SetAutoStart(appName string, autoStart bool) error { - for i, ac := range visor.appsConf { +func (node *Node) SetAutoStart(appName string, autoStart bool) error { + for i, ac := range node.appsConf { if ac.App == appName { - visor.appsConf[i].AutoStart = autoStart + node.appsConf[i].AutoStart = autoStart return nil } } return ErrUnknownApp } -func (visor *Visor) stopApp(app string, bind *appBind) (err error) { - visor.logger.Infof("Stopping app %s and closing ports", app) +func (node *Node) stopApp(app string, bind *appBind) (err error) { + node.logger.Infof("Stopping app %s and closing ports", app) - if excErr := visor.executer.Stop(bind.pid); excErr != nil && err == nil { - visor.logger.Warn("Failed to stop app: ", excErr) + if excErr := node.executer.Stop(bind.pid); excErr != nil && err == nil { + node.logger.Warn("Failed to stop app: ", excErr) err = excErr } if srvErr := bind.conn.Close(); srvErr != nil && err == nil { - visor.logger.Warnf("Failed to close App conn: %s", srvErr) + node.logger.Warnf("Failed to close App conn: %s", srvErr) err = srvErr } diff --git a/pkg/visor/visor_test.go b/pkg/node/node_test.go similarity index 91% rename from pkg/visor/visor_test.go rename to pkg/node/node_test.go index f773fcd93d..59768e3e52 100644 --- a/pkg/visor/visor_test.go +++ b/pkg/node/node_test.go @@ -1,4 +1,4 @@ -package visor +package node import ( "context" @@ -46,7 +46,7 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -func TestNew(t *testing.T) { +func TestNewNode(t *testing.T) { pk, sk := cipher.GenerateKeyPair() srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(&httpauth.NextNonceResponse{Edge: pk, NextNonce: 1}) // nolint: errcheck @@ -54,8 +54,8 @@ func TestNew(t *testing.T) { defer srv.Close() conf := Config{Version: "1.0", LocalPath: "local", AppsPath: "apps"} - conf.Visor.StaticPubKey = pk - conf.Visor.StaticSecKey = sk + conf.Node.StaticPubKey = pk + conf.Node.StaticSecKey = sk conf.Messaging.Discovery = "http://skywire.skycoin.net:8001" conf.Messaging.ServerCount = 10 conf.Transport.Discovery = srv.URL @@ -66,7 +66,7 @@ func TestNew(t *testing.T) { defer os.RemoveAll("local") - node, err := New(&conf, masterLogger) + node, err := NewNode(&conf, masterLogger) require.NoError(t, err) assert.NotNil(t, node.router) @@ -76,7 +76,7 @@ func TestNew(t *testing.T) { assert.NotNil(t, node.startedApps) } -func TestVisorStartClose(t *testing.T) { +func TestNodeStartClose(t *testing.T) { r := new(mockRouter) executer := &MockExecuter{} conf := []AppConfig{ @@ -84,7 +84,7 @@ func TestVisorStartClose(t *testing.T) { {App: "foo", Version: "1.0", AutoStart: false}, } defer os.RemoveAll("skychat") - node := &Visor{config: &Config{}, router: r, executer: executer, appsConf: conf, + node := &Node{config: &Config{}, router: r, executer: executer, appsConf: conf, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test")} mConf := &dmsg.Config{PubKey: cipher.PubKey{}, SecKey: cipher.SecKey{}, Discovery: disc.NewMock()} node.messenger = dmsg.NewClient(mConf.PubKey, mConf.SecKey, mConf.Discovery) @@ -110,15 +110,15 @@ func TestVisorStartClose(t *testing.T) { assert.Equal(t, "skychat/v1.0", executer.cmds[0].Dir) } -func TestVisorSpawnApp(t *testing.T) { +func TestNodeSpawnApp(t *testing.T) { pk, _ := cipher.GenerateKeyPair() r := new(mockRouter) executer := &MockExecuter{} defer os.RemoveAll("skychat") apps := []AppConfig{{App: "skychat", Version: "1.0", AutoStart: false, Port: 10, Args: []string{"foo"}}} - node := &Visor{router: r, executer: executer, appsConf: apps, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test"), + node := &Node{router: r, executer: executer, appsConf: apps, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test"), config: &Config{}} - node.config.Visor.StaticPubKey = pk + node.config.Node.StaticPubKey = pk pathutil.EnsureDir(node.dir()) defer os.RemoveAll(node.dir()) @@ -141,12 +141,12 @@ func TestVisorSpawnApp(t *testing.T) { require.NoError(t, node.StopApp("skychat")) } -func TestVisorSpawnAppValidations(t *testing.T) { +func TestNodeSpawnAppValidations(t *testing.T) { conn, _ := net.Pipe() r := new(mockRouter) executer := &MockExecuter{err: errors.New("foo")} defer os.RemoveAll("skychat") - node := &Visor{router: r, executer: executer, + node := &Node{router: r, executer: executer, startedApps: map[string]*appBind{"skychat": {conn, 10}}, logger: logging.MustGetLogger("test")} diff --git a/pkg/visor/rpc.go b/pkg/node/rpc.go similarity index 73% rename from pkg/visor/rpc.go rename to pkg/node/rpc.go index 71222b42e4..1465103f87 100644 --- a/pkg/visor/rpc.go +++ b/pkg/node/rpc.go @@ -1,4 +1,4 @@ -package visor +package node import ( "context" @@ -14,7 +14,7 @@ import ( const ( // RPCPrefix is the prefix used with all RPC calls. - RPCPrefix = "visor" + RPCPrefix = "app-node" ) var ( @@ -28,9 +28,9 @@ var ( ErrNotFound = errors.New("not found") ) -// RPC defines RPC methods for Visor. +// RPC defines RPC methods for Node. type RPC struct { - visor *Visor + node *Node } /* @@ -67,31 +67,31 @@ func newTransportSummary(tm *transport.Manager, tp *transport.ManagedTransport, return summary } -// Summary provides a summary of an Visor. +// Summary provides a summary of an AppNode. type Summary struct { PubKey cipher.PubKey `json:"local_pk"` - VisorVersion string `json:"visor_version"` + NodeVersion string `json:"node_version"` AppProtoVersion string `json:"app_protocol_version"` Apps []*AppState `json:"apps"` Transports []*TransportSummary `json:"transports"` RoutesCount int `json:"routes_count"` } -// Summary provides a summary of the Visor. +// Summary provides a summary of the AppNode. func (r *RPC) Summary(_ *struct{}, out *Summary) error { var summaries []*TransportSummary - r.visor.tm.WalkTransports(func(tp *transport.ManagedTransport) bool { + r.node.tm.WalkTransports(func(tp *transport.ManagedTransport) bool { summaries = append(summaries, - newTransportSummary(r.visor.tm, tp, false, r.visor.router.IsSetupTransport(tp))) + newTransportSummary(r.node.tm, tp, false, r.node.router.IsSetupTransport(tp))) return true }) *out = Summary{ - PubKey: r.visor.config.Visor.StaticPubKey, - VisorVersion: Version, + PubKey: r.node.config.Node.StaticPubKey, + NodeVersion: Version, AppProtoVersion: supportedProtocolVersion, - Apps: r.visor.Apps(), + Apps: r.node.Apps(), Transports: summaries, - RoutesCount: r.visor.rt.Count(), + RoutesCount: r.node.rt.Count(), } return nil } @@ -100,20 +100,20 @@ func (r *RPC) Summary(_ *struct{}, out *Summary) error { <<< APP MANAGEMENT >>> */ -// Apps returns list of Apps registered on the Visor. +// Apps returns list of Apps registered on the Node. func (r *RPC) Apps(_ *struct{}, reply *[]*AppState) error { - *reply = r.visor.Apps() + *reply = r.node.Apps() return nil } // StartApp start App with provided name. func (r *RPC) StartApp(name *string, _ *struct{}) error { - return r.visor.StartApp(*name) + return r.node.StartApp(*name) } // StopApp stops App with provided name. func (r *RPC) StopApp(name *string, _ *struct{}) error { - return r.visor.StopApp(*name) + return r.node.StopApp(*name) } // SetAutoStartIn is input for SetAutoStart. @@ -124,16 +124,16 @@ type SetAutoStartIn struct { // SetAutoStart sets auto-start settings for an app. func (r *RPC) SetAutoStart(in *SetAutoStartIn, _ *struct{}) error { - return r.visor.SetAutoStart(in.AppName, in.AutoStart) + return r.node.SetAutoStart(in.AppName, in.AutoStart) } /* <<< TRANSPORT MANAGEMENT >>> */ -// TransportTypes lists all transport types supported by the Visor. +// TransportTypes lists all transport types supported by the Node. func (r *RPC) TransportTypes(_ *struct{}, out *[]string) error { - *out = r.visor.tm.Factories() + *out = r.node.tm.Factories() return nil } @@ -144,7 +144,7 @@ type TransportsIn struct { ShowLogs bool } -// Transports lists Transports of the Visor and provides a summary of each. +// Transports lists Transports of the Node and provides a summary of each. func (r *RPC) Transports(in *TransportsIn, out *[]*TransportSummary) error { typeIncluded := func(tType string) bool { if in.FilterTypes != nil { @@ -168,10 +168,10 @@ func (r *RPC) Transports(in *TransportsIn, out *[]*TransportSummary) error { } return true } - r.visor.tm.WalkTransports(func(tp *transport.ManagedTransport) bool { - if remote, ok := r.visor.tm.Remote(tp.Edges()); ok { - if typeIncluded(tp.Type()) && pkIncluded(r.visor.tm.Local(), remote) { - *out = append(*out, newTransportSummary(r.visor.tm, tp, in.ShowLogs, r.visor.router.IsSetupTransport(tp))) + r.node.tm.WalkTransports(func(tp *transport.ManagedTransport) bool { + if remote, ok := r.node.tm.Remote(tp.Edges()); ok { + if typeIncluded(tp.Type()) && pkIncluded(r.node.tm.Local(), remote) { + *out = append(*out, newTransportSummary(r.node.tm, tp, in.ShowLogs, r.node.router.IsSetupTransport(tp))) } return true } @@ -182,11 +182,11 @@ func (r *RPC) Transports(in *TransportsIn, out *[]*TransportSummary) error { // Transport obtains a Transport Summary of Transport of given Transport ID. func (r *RPC) Transport(in *uuid.UUID, out *TransportSummary) error { - tp := r.visor.tm.Transport(*in) + tp := r.node.tm.Transport(*in) if tp == nil { return ErrNotFound } - *out = *newTransportSummary(r.visor.tm, tp, true, r.visor.router.IsSetupTransport(tp)) + *out = *newTransportSummary(r.node.tm, tp, true, r.node.router.IsSetupTransport(tp)) return nil } @@ -198,7 +198,7 @@ type AddTransportIn struct { Timeout time.Duration } -// AddTransport creates a transport for the visor. +// AddTransport creates a transport for the node. func (r *RPC) AddTransport(in *AddTransportIn, out *TransportSummary) error { ctx := context.Background() if in.Timeout > 0 { @@ -207,17 +207,17 @@ func (r *RPC) AddTransport(in *AddTransportIn, out *TransportSummary) error { defer cancel() } - tp, err := r.visor.tm.CreateTransport(ctx, in.RemotePK, in.TpType, in.Public) + tp, err := r.node.tm.CreateTransport(ctx, in.RemotePK, in.TpType, in.Public) if err != nil { return err } - *out = *newTransportSummary(r.visor.tm, tp, false, r.visor.router.IsSetupTransport(tp)) + *out = *newTransportSummary(r.node.tm, tp, false, r.node.router.IsSetupTransport(tp)) return nil } -// RemoveTransport removes a Transport from the visor. +// RemoveTransport removes a Transport from the node. func (r *RPC) RemoveTransport(tid *uuid.UUID, _ *struct{}) error { - return r.visor.tm.DeleteTransport(*tid) + return r.node.tm.DeleteTransport(*tid) } /* @@ -232,7 +232,7 @@ type RoutingEntry struct { // RoutingRules obtains all routing rules of the RoutingTable. func (r *RPC) RoutingRules(_ *struct{}, out *[]*RoutingEntry) error { - return r.visor.rt.RangeRules(func(routeID routing.RouteID, rule routing.Rule) (next bool) { + return r.node.rt.RangeRules(func(routeID routing.RouteID, rule routing.Rule) (next bool) { *out = append(*out, &RoutingEntry{Key: routeID, Value: rule}) return true }) @@ -241,25 +241,25 @@ func (r *RPC) RoutingRules(_ *struct{}, out *[]*RoutingEntry) error { // RoutingRule obtains a routing rule of given RouteID. func (r *RPC) RoutingRule(key *routing.RouteID, rule *routing.Rule) error { var err error - *rule, err = r.visor.rt.Rule(*key) + *rule, err = r.node.rt.Rule(*key) return err } // AddRoutingRule adds a RoutingRule and returns a Key in which the rule is stored under. func (r *RPC) AddRoutingRule(rule *routing.Rule, routeID *routing.RouteID) error { var err error - *routeID, err = r.visor.rt.AddRule(*rule) + *routeID, err = r.node.rt.AddRule(*rule) return err } // SetRoutingRule sets a routing rule. func (r *RPC) SetRoutingRule(in *RoutingEntry, out *struct{}) error { - return r.visor.rt.SetRule(in.Key, in.Value) + return r.node.rt.SetRule(in.Key, in.Value) } // RemoveRoutingRule removes a RoutingRule based on given RouteID key. func (r *RPC) RemoveRoutingRule(key *routing.RouteID, _ *struct{}) error { - return r.visor.rt.DeleteRules(*key) + return r.node.rt.DeleteRules(*key) } /* @@ -276,7 +276,7 @@ type LoopInfo struct { // Loops retrieves loops via rules of the routing table. func (r *RPC) Loops(_ *struct{}, out *[]LoopInfo) error { var loops []LoopInfo - err := r.visor.rt.RangeRules(func(_ routing.RouteID, rule routing.Rule) (next bool) { + err := r.node.rt.RangeRules(func(_ routing.RouteID, rule routing.Rule) (next bool) { if rule.Type() == routing.RuleApp { loops = append(loops, LoopInfo{AppRule: rule}) } @@ -287,7 +287,7 @@ func (r *RPC) Loops(_ *struct{}, out *[]LoopInfo) error { } for i, l := range loops { fwdRID := l.AppRule.RouteID() - rule, err := r.visor.rt.Rule(fwdRID) + rule, err := r.node.rt.Rule(fwdRID) if err != nil { return err } diff --git a/pkg/visor/rpc_client.go b/pkg/node/rpc_client.go similarity index 99% rename from pkg/visor/rpc_client.go rename to pkg/node/rpc_client.go index ce68130852..638d857226 100644 --- a/pkg/visor/rpc_client.go +++ b/pkg/node/rpc_client.go @@ -1,4 +1,4 @@ -package visor +package node import ( "encoding/binary" @@ -224,7 +224,7 @@ func NewMockRPCClient(r *rand.Rand, maxTps int, maxRules int) (cipher.PubKey, RP return localPK, &mockRPCClient{ s: &Summary{ PubKey: localPK, - VisorVersion: Version, + NodeVersion: Version, AppProtoVersion: supportedProtocolVersion, Apps: []*AppState{ {Name: "foo.v1.0", AutoStart: false, Port: 10}, diff --git a/pkg/visor/rpc_test.go b/pkg/node/rpc_test.go similarity index 93% rename from pkg/visor/rpc_test.go rename to pkg/node/rpc_test.go index bc1e084668..b8ec54c11d 100644 --- a/pkg/visor/rpc_test.go +++ b/pkg/node/rpc_test.go @@ -1,4 +1,4 @@ -package visor +package node import ( "context" @@ -29,7 +29,7 @@ func TestListApps(t *testing.T) { sApps := map[string]*appBind{ "bar": {}, } - rpc := &RPC{&Visor{appsConf: apps, startedApps: sApps}} + rpc := &RPC{&Node{appsConf: apps, startedApps: sApps}} var reply []*AppState require.NoError(t, rpc.Apps(nil, &reply)) @@ -55,12 +55,12 @@ func TestStartStopApp(t *testing.T) { defer os.RemoveAll("skychat") apps := []AppConfig{{App: "foo", Version: "1.0", AutoStart: false, Port: 10}} - node := &Visor{router: router, executer: executer, appsConf: apps, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test"), config: &Config{}} - node.config.Visor.StaticPubKey = pk + node := &Node{router: router, executer: executer, appsConf: apps, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test"), config: &Config{}} + node.config.Node.StaticPubKey = pk pathutil.EnsureDir(node.dir()) defer os.RemoveAll(node.dir()) - rpc := &RPC{visor: node} + rpc := &RPC{node: node} unknownApp := "bar" app := "foo" @@ -114,8 +114,8 @@ func TestRPC(t *testing.T) { {App: "bar", Version: "2.0", AutoStart: false, Port: 20}, } conf := &Config{} - conf.Visor.StaticPubKey = pk1 - node := &Visor{ + conf.Node.StaticPubKey = pk1 + node := &Node{ config: conf, router: r, tm: tm1, @@ -132,7 +132,7 @@ func TestRPC(t *testing.T) { require.NoError(t, node.StartApp("bar")) time.Sleep(time.Second) - gateway := &RPC{visor: node} + gateway := &RPC{node: node} sConn, cConn := net.Pipe() defer func() { @@ -224,10 +224,10 @@ func TestRPC(t *testing.T) { //assert.Equal(t, ErrUnknownApp.Error(), err.Error()) // //require.NoError(t, client.SetAutoStart(in2.AppName, in2.AutoStart)) - //assert.True(t, visor.appsConf[0].AutoStart) + //assert.True(t, node.appsConf[0].AutoStart) // //require.NoError(t, client.SetAutoStart(in3.AppName, in3.AutoStart)) - //assert.False(t, visor.appsConf[0].AutoStart) + //assert.False(t, node.appsConf[0].AutoStart) }) t.Run("TransportTypes", func(t *testing.T) { diff --git a/pkg/route-finder/client/client.go b/pkg/route-finder/client/client.go index 61c4993355..4ad7bccc13 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 visor to destiny, that has at least the given minHops and as much +// PairedRoutes returns routes from source skywire networking node 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 cafab3bb39..464a3628e7 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -1,4 +1,4 @@ -// Package router implements package router for skywire visor. +// Package router implements package router for skywire networking node. package router import ( @@ -39,7 +39,7 @@ type Config struct { SetupNodes []cipher.PubKey } -// Router implements visor.PacketRouter. It manages routing table by +// Router implements node.PacketRouter. It manages routing table by // communicating with setup nodes, forward packets according to local // rules and manages loops for apps. type Router struct { diff --git a/pkg/routing/packet.go b/pkg/routing/packet.go index c152a4c9d4..bb713efcae 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 networking nodes. type Packet []byte // MakePacket constructs a new Packet. If payload size is more than diff --git a/pkg/routing/route.go b/pkg/routing/route.go index 87dca45e7d..86a962748c 100644 --- a/pkg/routing/route.go +++ b/pkg/routing/route.go @@ -20,7 +20,7 @@ func (h Hop) String() string { return fmt.Sprintf("%s -> %s @ %s", h.From, h.To, h.Transport) } -// Route is a succession of transport entries that denotes a path from source visor to destination visor +// Route is a succession of transport entries that denotes a path from source node to destination node type Route []*Hop func (r Route) String() string { diff --git a/pkg/setup/protocol.go b/pkg/setup/protocol.go index e7831fe102..cc3d1f0734 100644 --- a/pkg/setup/protocol.go +++ b/pkg/setup/protocol.go @@ -1,4 +1,4 @@ -// Package setup defines setup visor protocol. +// Package setup defines setup node protocol. package setup import ( diff --git a/pkg/transport/manager.go b/pkg/transport/manager.go index 65bd6b7617..8614c39615 100644 --- a/pkg/transport/manager.go +++ b/pkg/transport/manager.go @@ -20,7 +20,7 @@ type ManagerConfig struct { SecKey cipher.SecKey DiscoveryClient DiscoveryClient LogStore LogStore - DefaultVisors []cipher.PubKey // Visors to automatically connect to + DefaultNodes []cipher.PubKey // Nodes to automatically connect to } // Manager manages Transports. @@ -141,9 +141,9 @@ func (tm *Manager) Remote(edges [2]cipher.PubKey) (cipher.PubKey, bool) { return cipher.PubKey{}, false } -// createDefaultTransports created transports to DefaultVisors if they don't exist. +// createDefaultTransports created transports to DefaultNodes if they don't exist. func (tm *Manager) createDefaultTransports(ctx context.Context) { - for _, pk := range tm.config.DefaultVisors { + for _, pk := range tm.config.DefaultNodes { exist := false tm.WalkTransports(func(tr *ManagedTransport) bool { remote, ok := tm.Remote(tr.Edges()) @@ -158,7 +158,7 @@ func (tm *Manager) createDefaultTransports(ctx context.Context) { } _, err := tm.CreateTransport(ctx, pk, "messaging", true) if err != nil { - tm.Logger.Warnf("Failed to establish transport to a visor %s: %s", pk, err) + tm.Logger.Warnf("Failed to establish transport to a node %s: %s", pk, err) } } } @@ -200,7 +200,7 @@ func (tm *Manager) Serve(ctx context.Context) error { return nil } -// CreateTransport begins to attempt to establish transports to the given 'remote' visor. +// CreateTransport begins to attempt to establish transports to the given 'remote' node. func (tm *Manager) CreateTransport(ctx context.Context, remote cipher.PubKey, tpType string, public bool) (*ManagedTransport, error) { return tm.createTransport(ctx, remote, tpType, public) } diff --git a/pkg/transport/tcp_transport.go b/pkg/transport/tcp_transport.go index 9ab00e441a..906bab428c 100644 --- a/pkg/transport/tcp_transport.go +++ b/pkg/transport/tcp_transport.go @@ -44,7 +44,7 @@ func (f *TCPFactory) Accept(ctx context.Context) (Transport, error) { return &TCPTransport{conn, [2]cipher.PubKey{f.lpk, rpk}}, nil } -// Dial initiates a Transport with a remote visor. +// Dial initiates a Transport with a remote node. func (f *TCPFactory) Dial(ctx context.Context, remote cipher.PubKey) (Transport, error) { raddr := f.pkt.RemoteAddr(remote) if raddr == nil { diff --git a/pkg/transport/transport.go b/pkg/transport/transport.go index ed1f8ee335..96c4061c7b 100644 --- a/pkg/transport/transport.go +++ b/pkg/transport/transport.go @@ -10,7 +10,7 @@ import ( "github.com/skycoin/dmsg/cipher" ) -// Transport represents communication between two visors via a single hop. +// Transport represents communication between two nodes via a single hop. type Transport interface { // Read implements io.Reader @@ -39,7 +39,7 @@ type Factory interface { // Accept accepts a remotely-initiated Transport. Accept(ctx context.Context) (Transport, error) - // Dial initiates a Transport with a remote visor. + // Dial initiates a Transport with a remote node. Dial(ctx context.Context, remote cipher.PubKey) (Transport, error) // Close implements io.Closer diff --git a/pkg/util/pathutil/configpath.go b/pkg/util/pathutil/configpath.go index 7bf92effeb..774ddfad02 100644 --- a/pkg/util/pathutil/configpath.go +++ b/pkg/util/pathutil/configpath.go @@ -71,14 +71,14 @@ func (dp ConfigPaths) Get(cpType ConfigLocationType) string { return "" } -// VisorDefaults returns the default config paths for visor. -func VisorDefaults() ConfigPaths { +// NodeDefaults returns the default config paths for skywire-networking-node. +func NodeDefaults() ConfigPaths { paths := make(ConfigPaths) if wd, err := os.Getwd(); err == nil { - paths[WorkingDirLoc] = filepath.Join(wd, "visor-config.json") + paths[WorkingDirLoc] = filepath.Join(wd, "skywire-config.json") } - paths[HomeLoc] = filepath.Join(HomeDir(), ".skycoin/visor/visor-config.json") - paths[LocalLoc] = "/usr/local/skycoin/visor/visor-config.json" + paths[HomeLoc] = filepath.Join(HomeDir(), ".skycoin/skywire/skywire-config.json") + paths[LocalLoc] = "/usr/local/skycoin/skywire/skywire-config.json" return paths } diff --git a/pkg/util/pathutil/homedir.go b/pkg/util/pathutil/homedir.go index bd6af341b7..439eea8dbf 100644 --- a/pkg/util/pathutil/homedir.go +++ b/pkg/util/pathutil/homedir.go @@ -23,8 +23,8 @@ func HomeDir() string { return os.Getenv("HOME") } -// VisorDir returns a path to a directory used to store specific visor configuration. Such dir is ~/.skywire/{PK} -func VisorDir(pk cipher.PubKey) string { +// NodeDir returns a path to a directory used to store specific node configuration. Such dir is ~/.skywire/{PK} +func NodeDir(pk cipher.PubKey) string { return filepath.Join(HomeDir(), ".skycoin", "skywire", pk.String()) } From 178239160417666cf37f176415e3fe49800f49ee Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 10 Jul 2019 01:16:20 +0300 Subject: [PATCH 04/10] Rename App Manager to Visor --- ci_scripts/run-pkg-tests.sh | 8 ++-- pkg/router/router.go | 2 +- pkg/router/{app_manager.go => visor.go} | 38 +++++++++---------- .../{app_manager_test.go => visor_test.go} | 16 ++++---- 4 files changed, 32 insertions(+), 32 deletions(-) rename pkg/router/{app_manager.go => visor.go} (57%) rename pkg/router/{app_manager_test.go => visor_test.go} (93%) diff --git a/ci_scripts/run-pkg-tests.sh b/ci_scripts/run-pkg-tests.sh index 96d4c88006..559259f462 100644 --- a/ci_scripts/run-pkg-tests.sh +++ b/ci_scripts/run-pkg-tests.sh @@ -28,10 +28,10 @@ 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/node -run TestStartStopApp >> ./logs/pkg/TestStartStopApp.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestRPC >> ./logs/pkg/TestRPC.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerInit >> ./logs/pkg/TestAppManagerInit.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerSetupLoop >> ./logs/pkg/TestAppManagerSetupLoop.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerCloseLoop >> ./logs/pkg/TestAppManagerCloseLoop.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerForward >> ./logs/pkg/TestAppManagerForward.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestVisorInit >> ./logs/pkg/TestVisorInit.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestVisorSetupLoop >> ./logs/pkg/TestVisorSetupLoop.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestVisorCloseLoop >> ./logs/pkg/TestVisorCloseLoop.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestVisorForward >> ./logs/pkg/TestVisorForward.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestManagedRoutingTableCleanup >> ./logs/pkg/TestManagedRoutingTableCleanup.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestPortManager >> ./logs/pkg/TestPortManager.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestRouteManagerGetRule >> ./logs/pkg/TestRouteManagerGetRule.log diff --git a/pkg/router/router.go b/pkg/router/router.go index 464a3628e7..848c21f302 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -141,7 +141,7 @@ func (r *Router) ServeApp(conn net.Conn, port uint16, appConf *app.Config) error CloseLoop: r.closeLoop, Forward: r.forwardAppPacket, } - am := &appManager{r.Logger, appProto, appConf, callbacks} + am := &visor{r.Logger, appProto, appConf, callbacks} err := am.Serve() for _, port := range r.pm.AppPorts(appProto) { diff --git a/pkg/router/app_manager.go b/pkg/router/visor.go similarity index 57% rename from pkg/router/app_manager.go rename to pkg/router/visor.go index 49565f85c4..fa41f265f6 100644 --- a/pkg/router/app_manager.go +++ b/pkg/router/visor.go @@ -17,7 +17,7 @@ type appCallbacks struct { Forward func(conn *app.Protocol, packet *app.Packet) error } -type appManager struct { +type visor struct { Logger *logging.Logger proto *app.Protocol @@ -25,31 +25,31 @@ type appManager struct { callbacks *appCallbacks } -func (am *appManager) Serve() error { - return am.proto.Serve(func(frame app.Frame, payload []byte) (res interface{}, err error) { - am.Logger.Infof("Got new App request with type %s: %s", frame, string(payload)) +func (v *visor) Serve() error { + return v.proto.Serve(func(frame app.Frame, payload []byte) (res interface{}, err error) { + v.Logger.Infof("Got new App request with type %s: %s", frame, string(payload)) switch frame { case app.FrameInit: - err = am.initApp(payload) + err = v.initApp(payload) case app.FrameCreateLoop: - res, err = am.setupLoop(payload) + res, err = v.setupLoop(payload) case app.FrameClose: - err = am.handleCloseLoop(payload) + err = v.handleCloseLoop(payload) case app.FrameSend: - err = am.forwardAppPacket(payload) + err = v.forwardAppPacket(payload) default: err = errors.New("unexpected frame") } if err != nil { - am.Logger.Infof("App request with type %s failed: %s", frame, err) + v.Logger.Infof("App request with type %s failed: %s", frame, err) } return res, err }) } -func (am *appManager) initApp(payload []byte) error { +func (v *visor) initApp(payload []byte) error { config := &app.Config{} if err := json.Unmarshal(payload, config); err != nil { return errors.New("invalid Init payload") @@ -59,41 +59,41 @@ func (am *appManager) initApp(payload []byte) error { return errors.New("unsupported protocol version") } - if am.appConf.AppName != config.AppName { + if v.appConf.AppName != config.AppName { return errors.New("unexpected app") } - if am.appConf.AppVersion != config.AppVersion { + if v.appConf.AppVersion != config.AppVersion { return errors.New("unexpected app version") } - am.Logger.Infof("Handshaked new connection with the app %s.v%s", config.AppName, config.AppVersion) + v.Logger.Infof("Handshaked new connection with the app %s.v%s", config.AppName, config.AppVersion) return nil } -func (am *appManager) setupLoop(payload []byte) (*app.Addr, error) { +func (v *visor) setupLoop(payload []byte) (*app.Addr, error) { raddr := &app.Addr{} if err := json.Unmarshal(payload, raddr); err != nil { return nil, err } - return am.callbacks.CreateLoop(am.proto, raddr) + return v.callbacks.CreateLoop(v.proto, raddr) } -func (am *appManager) handleCloseLoop(payload []byte) error { +func (v *visor) handleCloseLoop(payload []byte) error { addr := &app.LoopAddr{} if err := json.Unmarshal(payload, addr); err != nil { return err } - return am.callbacks.CloseLoop(am.proto, addr) + return v.callbacks.CloseLoop(v.proto, addr) } -func (am *appManager) forwardAppPacket(payload []byte) error { +func (v *visor) forwardAppPacket(payload []byte) error { packet := &app.Packet{} if err := json.Unmarshal(payload, packet); err != nil { return err } - return am.callbacks.Forward(am.proto, packet) + return v.callbacks.Forward(v.proto, packet) } diff --git a/pkg/router/app_manager_test.go b/pkg/router/visor_test.go similarity index 93% rename from pkg/router/app_manager_test.go rename to pkg/router/visor_test.go index 041866db2a..b818cd3623 100644 --- a/pkg/router/app_manager_test.go +++ b/pkg/router/visor_test.go @@ -12,9 +12,9 @@ import ( "github.com/skycoin/skywire/pkg/app" ) -func TestAppManagerInit(t *testing.T) { +func TestVisorInit(t *testing.T) { in, out := net.Pipe() - am := &appManager{ + am := &visor{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -51,9 +51,9 @@ func TestAppManagerInit(t *testing.T) { require.NoError(t, <-srvCh) } -func TestAppManagerSetupLoop(t *testing.T) { +func TestVisorSetupLoop(t *testing.T) { in, out := net.Pipe() - am := &appManager{ + am := &visor{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -81,10 +81,10 @@ func TestAppManagerSetupLoop(t *testing.T) { require.NoError(t, <-srvCh) } -func TestAppManagerCloseLoop(t *testing.T) { +func TestVisorCloseLoop(t *testing.T) { in, out := net.Pipe() var inAddr *app.LoopAddr - am := &appManager{ + am := &visor{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -112,10 +112,10 @@ func TestAppManagerCloseLoop(t *testing.T) { require.NoError(t, <-srvCh) } -func TestAppManagerForward(t *testing.T) { +func TestVisorForward(t *testing.T) { in, out := net.Pipe() var inPacket *app.Packet - am := &appManager{ + am := &visor{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, From 6226ffb604dabfdbb5488d061a53e2575326de98 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 10 Jul 2019 01:31:09 +0300 Subject: [PATCH 05/10] Fix forgotten renaming --- CHANGELOG.md | 2 +- Makefile | 6 +++--- README.md | 10 +++++----- cmd/hypervisor/commands/root.go | 2 +- .../{visor.go => skywire-networking-node.go} | 0 docker/images/node/Dockerfile | 6 +++--- integration/InteractiveEnvironments.md | 8 ++++---- pkg/hypervisor/hypervisor.go | 2 +- pkg/router/router.go | 4 ++-- pkg/router/visor_test.go | 16 ++++++++-------- 10 files changed, 28 insertions(+), 28 deletions(-) rename cmd/skywire-networking-node/{visor.go => skywire-networking-node.go} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b009717f2..8b852ce1e6 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 networking node and apps for testing. diff --git a/Makefile b/Makefile index 707c3a63b7..b47875c688 100644 --- a/Makefile +++ b/Makefile @@ -137,7 +137,7 @@ docker-bin: ## Build `skywire-networking-node`, `skywire-cli`, `hypervisor`, `th docker-volume: dep docker-apps docker-bin bin ## Prepare docker volume for dockerized skywire-networking-node -${DOCKER_OPTS} go build -o ./docker/skywire-services/setup-node ./cmd/setup-node -./skywire-cli node gen-config -o ./skywire-networking-node/skywire.json -r - perl -pi -e 's/localhost//g' ./node/skywire.json # To make skywire-networking-node accessible from outside with skywire-cli + 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-networking-node ${DOCKER_NODE} in image ${DOCKER_IMAGE} with network ${DOCKER_NETWORK} docker run -it -v $(shell pwd)/node:/sky --network=${DOCKER_NETWORK} \ @@ -155,7 +155,7 @@ docker-stop: ## Stop running dockerized skywire-networking-node ${DOCKER_NODE} docker-rerun: docker-stop -./skywire-cli gen-config -o ./node/skywire.json -r - perl -pi -e 's/localhost//g' ./node/skywire.json # To make skywire-networking-node accessible from outside with skywire-cli + 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-networking-node ./cmd/skywire-networking-node docker container start -i ${DOCKER_NODE} @@ -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-networking-node's of interactive testing environment +integration-startup: ## Starts up the required transports between `skywire-networking-node`s of interactive testing environment ./integration/startup.sh integration-teardown: ## Tears down all saved configs and states of integration executables diff --git a/README.md b/README.md index 0de373f534..2e9152f7cf 100644 --- a/README.md +++ b/README.md @@ -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 networking 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 networking node 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 networking 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. 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 networking 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 networking 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. 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. @@ -154,7 +154,7 @@ After `skywire-networking-node` is up and running with default environment, defa ### 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 networking node, a transport to that remote Skywire networking node needs to be established. Transports can be established via the `skywire-cli`. @@ -375,7 +375,7 @@ let's look how to create new node. ```bash # 1. We need a folder for docker volume $ mkdir /tmp/SKYNODE -# 2. compile `skywire-node` +# 2. compile `skywire-networking-node` $ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/skywire-networking-node ./cmd/skywire-networking-node # 3. compile apps $ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/skychat.v1.0 ./cmd/apps/skychat diff --git a/cmd/hypervisor/commands/root.go b/cmd/hypervisor/commands/root.go index 62e0510f2f..2e77d36837 100644 --- a/cmd/hypervisor/commands/root.go +++ b/cmd/hypervisor/commands/root.go @@ -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("Node exited with error:", err) + log.Fatalln("Hypervisor exited with error:", err) } log.Println("Good bye!") diff --git a/cmd/skywire-networking-node/visor.go b/cmd/skywire-networking-node/skywire-networking-node.go similarity index 100% rename from cmd/skywire-networking-node/visor.go rename to cmd/skywire-networking-node/skywire-networking-node.go diff --git a/docker/images/node/Dockerfile b/docker/images/node/Dockerfile index efa78efa5a..fdfcc30497 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-networking-node cmd/skywire-networking-node/skywire-networking-node.go &&\ 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 &&\ go build -mod=vendor -ldflags="-w -s" -o ./apps/socksproxy.v1.0 ./cmd/apps/therealproxy &&\ @@ -26,13 +26,13 @@ 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-networking-node skywire-networking-node COPY --from=builder /go/skywire/apps bin/apps COPY --from=builder /go/skywire/docker/images/node/update.sh update.sh RUN ./update.sh -ENTRYPOINT [ "./skywire-node" ] +ENTRYPOINT [ "./skywire-networking-node" ] # default target FROM node-runner diff --git a/integration/InteractiveEnvironments.md b/integration/InteractiveEnvironments.md index ab8190cafd..db069d6303 100644 --- a/integration/InteractiveEnvironments.md +++ b/integration/InteractiveEnvironments.md @@ -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 node running with generic/nodeA.json - 7. NodeB: first node running with intermediary-nodeB.json - 8. NodeC: first node running with generic/nodeC.json + 6. NodeA: first skywire-networking-node with generic/nodeA.json + 7. NodeB: first skywire-networking-node with intermediary-nodeB.json + 8. NodeC: first skywire-networking-node 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 @@ -227,7 +227,7 @@ Recipe for clean start: 2. Start `./integration/run-proxy-env.sh` 3. Run `make integration-startup` 4. Stop NodeA, NodeB, NodeC -5. Restart all `skywire-networking-node`s +5. Restart all nodes 6. Wait for message in NodeC logs about successful start of socksproxy-client 7. Check `lsof -i :9999` that it's really started diff --git a/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index aaf8b82142..e386f26c7a 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -1,4 +1,4 @@ -// Package hypervisor implements node manager +// Package hypervisor implements management node package hypervisor import ( diff --git a/pkg/router/router.go b/pkg/router/router.go index 848c21f302..dcbb20f262 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -141,8 +141,8 @@ func (r *Router) ServeApp(conn net.Conn, port uint16, appConf *app.Config) error CloseLoop: r.closeLoop, Forward: r.forwardAppPacket, } - am := &visor{r.Logger, appProto, appConf, callbacks} - err := am.Serve() + visor := &visor{r.Logger, appProto, appConf, callbacks} + err := visor.Serve() for _, port := range r.pm.AppPorts(appProto) { for _, addr := range r.pm.Close(port) { diff --git a/pkg/router/visor_test.go b/pkg/router/visor_test.go index b818cd3623..1ba6240393 100644 --- a/pkg/router/visor_test.go +++ b/pkg/router/visor_test.go @@ -14,7 +14,7 @@ import ( func TestVisorInit(t *testing.T) { in, out := net.Pipe() - am := &visor{ + visor := &visor{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -22,7 +22,7 @@ func TestVisorInit(t *testing.T) { } srvCh := make(chan error) - go func() { srvCh <- am.Serve() }() + go func() { srvCh <- visor.Serve() }() proto := app.NewProtocol(in) go proto.Serve(nil) // nolint: errcheck @@ -53,7 +53,7 @@ func TestVisorInit(t *testing.T) { func TestVisorSetupLoop(t *testing.T) { in, out := net.Pipe() - am := &visor{ + visor := &visor{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -65,7 +65,7 @@ func TestVisorSetupLoop(t *testing.T) { } srvCh := make(chan error) - go func() { srvCh <- am.Serve() }() + go func() { srvCh <- visor.Serve() }() proto := app.NewProtocol(in) go proto.Serve(nil) // nolint: errcheck @@ -84,7 +84,7 @@ func TestVisorSetupLoop(t *testing.T) { func TestVisorCloseLoop(t *testing.T) { in, out := net.Pipe() var inAddr *app.LoopAddr - am := &visor{ + visor := &visor{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -97,7 +97,7 @@ func TestVisorCloseLoop(t *testing.T) { } srvCh := make(chan error) - go func() { srvCh <- am.Serve() }() + go func() { srvCh <- visor.Serve() }() proto := app.NewProtocol(in) go proto.Serve(nil) // nolint: errcheck @@ -115,7 +115,7 @@ func TestVisorCloseLoop(t *testing.T) { func TestVisorForward(t *testing.T) { in, out := net.Pipe() var inPacket *app.Packet - am := &visor{ + visor := &visor{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -128,7 +128,7 @@ func TestVisorForward(t *testing.T) { } srvCh := make(chan error) - go func() { srvCh <- am.Serve() }() + go func() { srvCh <- visor.Serve() }() proto := app.NewProtocol(in) go proto.Serve(nil) // nolint: errcheck From 84c2b5bcfef170bb29203ac0d931c2da2f592f14 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 10 Jul 2019 02:12:16 +0300 Subject: [PATCH 06/10] Add hypervisor binary to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 423a3ec4eb..3136318d82 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ pkg/node/foo/ /node /users.db +/hypervisor /*-node /*-cli /*-server From d51b7bff5b13284255163cd4cbc0b2f814804324 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 10 Jul 2019 12:46:27 +0300 Subject: [PATCH 07/10] Rename visor back to appManager --- ci_scripts/run-pkg-tests.sh | 8 ++++---- pkg/router/router.go | 4 ++-- pkg/router/visor.go | 38 ++++++++++++++++++------------------- pkg/router/visor_test.go | 24 +++++++++++------------ 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/ci_scripts/run-pkg-tests.sh b/ci_scripts/run-pkg-tests.sh index 559259f462..96d4c88006 100644 --- a/ci_scripts/run-pkg-tests.sh +++ b/ci_scripts/run-pkg-tests.sh @@ -28,10 +28,10 @@ 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/node -run TestStartStopApp >> ./logs/pkg/TestStartStopApp.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestRPC >> ./logs/pkg/TestRPC.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestVisorInit >> ./logs/pkg/TestVisorInit.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestVisorSetupLoop >> ./logs/pkg/TestVisorSetupLoop.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestVisorCloseLoop >> ./logs/pkg/TestVisorCloseLoop.log -go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestVisorForward >> ./logs/pkg/TestVisorForward.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerInit >> ./logs/pkg/TestAppManagerInit.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerSetupLoop >> ./logs/pkg/TestAppManagerSetupLoop.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerCloseLoop >> ./logs/pkg/TestAppManagerCloseLoop.log +go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestAppManagerForward >> ./logs/pkg/TestAppManagerForward.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestManagedRoutingTableCleanup >> ./logs/pkg/TestManagedRoutingTableCleanup.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestPortManager >> ./logs/pkg/TestPortManager.log go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/router -run TestRouteManagerGetRule >> ./logs/pkg/TestRouteManagerGetRule.log diff --git a/pkg/router/router.go b/pkg/router/router.go index dcbb20f262..464a3628e7 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -141,8 +141,8 @@ func (r *Router) ServeApp(conn net.Conn, port uint16, appConf *app.Config) error CloseLoop: r.closeLoop, Forward: r.forwardAppPacket, } - visor := &visor{r.Logger, appProto, appConf, callbacks} - err := visor.Serve() + am := &appManager{r.Logger, appProto, appConf, callbacks} + err := am.Serve() for _, port := range r.pm.AppPorts(appProto) { for _, addr := range r.pm.Close(port) { diff --git a/pkg/router/visor.go b/pkg/router/visor.go index fa41f265f6..49565f85c4 100644 --- a/pkg/router/visor.go +++ b/pkg/router/visor.go @@ -17,7 +17,7 @@ type appCallbacks struct { Forward func(conn *app.Protocol, packet *app.Packet) error } -type visor struct { +type appManager struct { Logger *logging.Logger proto *app.Protocol @@ -25,31 +25,31 @@ type visor struct { callbacks *appCallbacks } -func (v *visor) Serve() error { - return v.proto.Serve(func(frame app.Frame, payload []byte) (res interface{}, err error) { - v.Logger.Infof("Got new App request with type %s: %s", frame, string(payload)) +func (am *appManager) Serve() error { + return am.proto.Serve(func(frame app.Frame, payload []byte) (res interface{}, err error) { + am.Logger.Infof("Got new App request with type %s: %s", frame, string(payload)) switch frame { case app.FrameInit: - err = v.initApp(payload) + err = am.initApp(payload) case app.FrameCreateLoop: - res, err = v.setupLoop(payload) + res, err = am.setupLoop(payload) case app.FrameClose: - err = v.handleCloseLoop(payload) + err = am.handleCloseLoop(payload) case app.FrameSend: - err = v.forwardAppPacket(payload) + err = am.forwardAppPacket(payload) default: err = errors.New("unexpected frame") } if err != nil { - v.Logger.Infof("App request with type %s failed: %s", frame, err) + am.Logger.Infof("App request with type %s failed: %s", frame, err) } return res, err }) } -func (v *visor) initApp(payload []byte) error { +func (am *appManager) initApp(payload []byte) error { config := &app.Config{} if err := json.Unmarshal(payload, config); err != nil { return errors.New("invalid Init payload") @@ -59,41 +59,41 @@ func (v *visor) initApp(payload []byte) error { return errors.New("unsupported protocol version") } - if v.appConf.AppName != config.AppName { + if am.appConf.AppName != config.AppName { return errors.New("unexpected app") } - if v.appConf.AppVersion != config.AppVersion { + if am.appConf.AppVersion != config.AppVersion { return errors.New("unexpected app version") } - v.Logger.Infof("Handshaked new connection with the app %s.v%s", config.AppName, config.AppVersion) + am.Logger.Infof("Handshaked new connection with the app %s.v%s", config.AppName, config.AppVersion) return nil } -func (v *visor) setupLoop(payload []byte) (*app.Addr, error) { +func (am *appManager) setupLoop(payload []byte) (*app.Addr, error) { raddr := &app.Addr{} if err := json.Unmarshal(payload, raddr); err != nil { return nil, err } - return v.callbacks.CreateLoop(v.proto, raddr) + return am.callbacks.CreateLoop(am.proto, raddr) } -func (v *visor) handleCloseLoop(payload []byte) error { +func (am *appManager) handleCloseLoop(payload []byte) error { addr := &app.LoopAddr{} if err := json.Unmarshal(payload, addr); err != nil { return err } - return v.callbacks.CloseLoop(v.proto, addr) + return am.callbacks.CloseLoop(am.proto, addr) } -func (v *visor) forwardAppPacket(payload []byte) error { +func (am *appManager) forwardAppPacket(payload []byte) error { packet := &app.Packet{} if err := json.Unmarshal(payload, packet); err != nil { return err } - return v.callbacks.Forward(v.proto, packet) + return am.callbacks.Forward(am.proto, packet) } diff --git a/pkg/router/visor_test.go b/pkg/router/visor_test.go index 1ba6240393..041866db2a 100644 --- a/pkg/router/visor_test.go +++ b/pkg/router/visor_test.go @@ -12,9 +12,9 @@ import ( "github.com/skycoin/skywire/pkg/app" ) -func TestVisorInit(t *testing.T) { +func TestAppManagerInit(t *testing.T) { in, out := net.Pipe() - visor := &visor{ + am := &appManager{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -22,7 +22,7 @@ func TestVisorInit(t *testing.T) { } srvCh := make(chan error) - go func() { srvCh <- visor.Serve() }() + go func() { srvCh <- am.Serve() }() proto := app.NewProtocol(in) go proto.Serve(nil) // nolint: errcheck @@ -51,9 +51,9 @@ func TestVisorInit(t *testing.T) { require.NoError(t, <-srvCh) } -func TestVisorSetupLoop(t *testing.T) { +func TestAppManagerSetupLoop(t *testing.T) { in, out := net.Pipe() - visor := &visor{ + am := &appManager{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -65,7 +65,7 @@ func TestVisorSetupLoop(t *testing.T) { } srvCh := make(chan error) - go func() { srvCh <- visor.Serve() }() + go func() { srvCh <- am.Serve() }() proto := app.NewProtocol(in) go proto.Serve(nil) // nolint: errcheck @@ -81,10 +81,10 @@ func TestVisorSetupLoop(t *testing.T) { require.NoError(t, <-srvCh) } -func TestVisorCloseLoop(t *testing.T) { +func TestAppManagerCloseLoop(t *testing.T) { in, out := net.Pipe() var inAddr *app.LoopAddr - visor := &visor{ + am := &appManager{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -97,7 +97,7 @@ func TestVisorCloseLoop(t *testing.T) { } srvCh := make(chan error) - go func() { srvCh <- visor.Serve() }() + go func() { srvCh <- am.Serve() }() proto := app.NewProtocol(in) go proto.Serve(nil) // nolint: errcheck @@ -112,10 +112,10 @@ func TestVisorCloseLoop(t *testing.T) { require.NoError(t, <-srvCh) } -func TestVisorForward(t *testing.T) { +func TestAppManagerForward(t *testing.T) { in, out := net.Pipe() var inPacket *app.Packet - visor := &visor{ + am := &appManager{ logging.MustGetLogger("routesetup"), app.NewProtocol(out), &app.Config{AppName: "foo", AppVersion: "0.0.1"}, @@ -128,7 +128,7 @@ func TestVisorForward(t *testing.T) { } srvCh := make(chan error) - go func() { srvCh <- visor.Serve() }() + go func() { srvCh <- am.Serve() }() proto := app.NewProtocol(in) go proto.Serve(nil) // nolint: errcheck From 1de6722c34397866d1afb783ab159402b4719f4e Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 10 Jul 2019 12:57:55 +0300 Subject: [PATCH 08/10] Rename /pkg/node to /pkg/visor --- .gitignore | 6 ++--- cmd/skywire-cli/commands/node/app.go | 4 ++-- cmd/skywire-cli/commands/node/gen-config.go | 20 ++++++++-------- cmd/skywire-cli/commands/node/root.go | 6 ++--- cmd/skywire-cli/commands/node/routes.go | 6 ++--- cmd/skywire-cli/commands/node/transports.go | 6 ++--- cmd/skywire-networking-node/commands/root.go | 14 +++++------ pkg/hypervisor/hypervisor.go | 24 +++++++++---------- pkg/{node => visor}/config.go | 2 +- pkg/{node => visor}/config_test.go | 2 +- pkg/{node => visor}/rpc.go | 2 +- pkg/{node => visor}/rpc_client.go | 2 +- pkg/{node => visor}/rpc_test.go | 2 +- pkg/{node/node.go => visor/visor.go} | 4 ++-- .../node_test.go => visor/visor_test.go} | 2 +- 15 files changed, 51 insertions(+), 51 deletions(-) rename pkg/{node => visor}/config.go (99%) rename pkg/{node => visor}/config_test.go (99%) rename pkg/{node => visor}/rpc.go (99%) rename pkg/{node => visor}/rpc_client.go (99%) rename pkg/{node => visor}/rpc_test.go (99%) rename pkg/{node/node.go => visor/visor.go} (99%) rename pkg/{node/node_test.go => visor/visor_test.go} (99%) diff --git a/.gitignore b/.gitignore index 3136318d82..33e6de3b70 100644 --- a/.gitignore +++ b/.gitignore @@ -15,9 +15,9 @@ /skywire/ /local* -pkg/node/apps/ -pkg/node/bar/ -pkg/node/foo/ +pkg/visor/apps/ +pkg/visor/bar/ +pkg/visor/foo/ /node /users.db 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 e49230a5bf..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.Hypervisors = []node.HypervisorConfig{} + 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 a2147a1fc9..ef1780451a 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") @@ -23,10 +23,10 @@ var RootCmd = &cobra.Command{ Short: "Contains sub-commands that interact with the local Skywire Networking Node", } -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-networking-node/commands/root.go b/cmd/skywire-networking-node/commands/root.go index dbca8600df..da278981fd 100644 --- a/cmd/skywire-networking-node/commands/root.go +++ b/cmd/skywire-networking-node/commands/root.go @@ -21,12 +21,12 @@ import ( "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" - "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 @@ -39,8 +39,8 @@ 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 @@ -58,7 +58,7 @@ var rootCmd = &cobra.Command{ waitOsSignals(). stopNode() }, - Version: node.Version, + Version: visor.Version, } func init() { @@ -134,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) } @@ -142,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/pkg/hypervisor/hypervisor.go b/pkg/hypervisor/hypervisor.go index e386f26c7a..5fa6ac75b0 100644 --- a/pkg/hypervisor/hypervisor.go +++ b/pkg/hypervisor/hypervisor.go @@ -21,8 +21,8 @@ import ( "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 ( @@ -31,7 +31,7 @@ var ( type appNodeConn struct { Addr *noise.Addr - Client node.RPCClient + Client visor.RPCClient } // Node manages AppNodes. @@ -69,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() } @@ -92,7 +92,7 @@ type MockConfig struct { 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{ @@ -149,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. @@ -161,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(), @@ -428,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{} } @@ -457,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() @@ -468,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 @@ -545,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/node/config.go b/pkg/visor/config.go similarity index 99% rename from pkg/node/config.go rename to pkg/visor/config.go index 3f8daf8942..6e1f4044b4 100644 --- a/pkg/node/config.go +++ b/pkg/visor/config.go @@ -1,4 +1,4 @@ -package node +package visor import ( "encoding/json" 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 99% rename from pkg/node/node.go rename to pkg/visor/visor.go index 26f1dff199..c1eb638141 100644 --- a/pkg/node/node.go +++ b/pkg/visor/visor.go @@ -1,5 +1,5 @@ -// Package node implements skywire networking node. -package node +// Package visor implements skywire networking node. +package visor import ( "bufio" 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" From 662ec2fa7edeeb306848b1d1a22134cabaee9ab5 Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Wed, 10 Jul 2019 13:08:09 +0300 Subject: [PATCH 09/10] Rename skywire-networking-node (skywire-node) to skywire-visor --- CHANGELOG.md | 2 +- Makefile | 52 +++++++------- README.md | 70 +++++++++---------- cmd/apps/helloworld/helloworld.go | 2 +- cmd/apps/skychat/README.md | 6 +- cmd/apps/skychat/chat.go | 2 +- .../therealproxy-client.go | 2 +- cmd/apps/therealproxy/README.md | 4 +- cmd/apps/therealproxy/therealproxy.go | 2 +- .../therealssh-client/therealssh-client.go | 2 +- cmd/apps/therealssh/README.md | 4 +- cmd/apps/therealssh/therealssh.go | 2 +- cmd/skywire-cli/commands/node/root.go | 4 +- cmd/skywire-cli/skywire-cli.go | 2 +- .../skywire-networking-node.go | 12 ---- .../commands/root.go | 4 +- .../config.json | 0 cmd/skywire-visor/skywire-visor.go | 12 ++++ docker/images/node/Dockerfile | 6 +- integration/InteractiveEnvironments.md | 14 ++-- integration/messaging/env-vars.sh | 6 +- integration/proxy/env-vars.sh | 6 +- integration/run-generic-env.sh | 6 +- integration/run-messaging-env.sh | 6 +- integration/run-proxy-env.sh | 6 +- integration/run-ssh-env.sh | 6 +- integration/ssh/env-vars.sh | 6 +- integration/start-restart-nodeB.sh | 2 +- integration/tear-down.sh | 2 +- integration/test-proxy.sh | 6 +- integration/test-ssh.sh | 6 +- pkg/route-finder/client/client.go | 2 +- pkg/router/router.go | 2 +- pkg/routing/packet.go | 2 +- pkg/util/pathutil/configpath.go | 2 +- pkg/visor/config.go | 2 +- pkg/visor/visor.go | 2 +- 37 files changed, 137 insertions(+), 137 deletions(-) delete mode 100644 cmd/skywire-networking-node/skywire-networking-node.go rename cmd/{skywire-networking-node => skywire-visor}/commands/root.go (98%) rename cmd/{skywire-networking-node => skywire-visor}/config.json (100%) create mode 100644 cmd/skywire-visor/skywire-visor.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b852ce1e6..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 networking node and apps for testing. +- First release of the mainnet Skywire visor and apps for testing. diff --git a/Makefile b/Makefile index b47875c688..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-networking-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-networking-node on host - ./skywire-networking-node skywire.json +run: stop build config ## Run skywire-visor on host + ./skywire-visor skywire.json -stop: ## Stop running skywire-networking-node on host - -bash -c "kill $$(ps aux |grep '[s]kywire-networking-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-networking-node ./skywire-cli ./setup-node ./hypervisor ./SSH-cli + -rm -f ./skywire-visor ./skywire-cli ./setup-node ./hypervisor ./SSH-cli -install: ## Install `skywire-networking-node`, `skywire-cli`, `hypervisor`, `SSH-cli` - ${OPTS} go install ./cmd/skywire-networking-node ./cmd/skywire-cli ./cmd/setup-node ./cmd/hypervisor ./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-networking-node ./cmd/skywire-networking-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-networking-node skywire.json + ./skywire-visor skywire.json lint: ## Run linters. Use make install-linters first @@ -54,7 +54,7 @@ vendorcheck: ## Run vendorcheck GO111MODULE=off vendorcheck ./cmd/hypervisor/... GO111MODULE=off vendorcheck ./cmd/setup-node/... GO111MODULE=off vendorcheck ./cmd/skywire-cli/... - GO111MODULE=off vendorcheck ./cmd/skywire-networking-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,8 +90,8 @@ host-apps: ## Build app ${OPTS} go build ${BUILD_OPTS} -o ./apps/SSH-client.v1.0 ./cmd/apps/therealssh-client # Bin -bin: ## Build `skywire-networking-node`, `skywire-cli`, `hypervisor`, `SSH-cli` - ${OPTS} go build ${BUILD_OPTS} -o ./skywire-networking-node ./cmd/skywire-networking-node +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 @@ -99,8 +99,8 @@ bin: ## Build `skywire-networking-node`, `skywire-cli`, `hypervisor`, `SSH-cli` ${OPTS} go build ${BUILD_OPTS} -o ./SSH-cli ./cmd/therealssh-cli -release: ## Build `skywire-networking-node`, `skywire-cli`, `hypervisor`, `SSH-cli` and apps without -race flag - ${OPTS} go build -o ./skywire-networking-node ./cmd/skywire-networking-node +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 ./hypervisor ./cmd/hypervisor @@ -112,7 +112,7 @@ release: ## Build `skywire-networking-node`, `skywire-cli`, `hypervisor`, `SSH-c ${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-networking-node +# Dockerized skywire-visor docker-image: ## Build docker image `skywire-runner` docker image build --tag=skywire-runner --rm - < skywire-runner.Dockerfile @@ -123,7 +123,7 @@ docker-clean: ## Clean docker system: remove container ${DOCKER_NODE} and networ docker-network: ## Create docker network ${DOCKER_NETWORK} -docker network create ${DOCKER_NETWORK} -docker-apps: ## Build apps binaries for dockerized skywire-networking-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-networking-node. `go -${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-networking-node`, `skywire-cli`, `hypervisor`, `therealssh-cli`. `go build` with ${DOCKER_OPTS} - ${DOCKER_OPTS} go build -race -o ./node/skywire-networking-node ./cmd/skywire-networking-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-networking-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 ./skywire-networking-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-networking-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-networking-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-networking-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 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-networking-node ./cmd/skywire-networking-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-networking-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 diff --git a/README.md b/README.md index 2e9152f7cf..ec949bef30 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ - [Build and run](#Build-and-run) - [Requirements](#Requirements) - [Build](#Build) - - [Run `skywire-networking-node`](#Run-skywire-networking-node) - - [Run `skywire-networking-node` in docker container](#Run-skywire-networking-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](#SYSLOGOPTS) - [Updater](#Updater) - [Running skywire in docker containers](#Running-skywire-in-docker-containers) - - [Run dockerized `skywire-networking-node`](#Run-dockerized-skywire-networking-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-DOCKERNETWORK) - [3. DOCKER_NODE](#3-DOCKERNODE) - [4. DOCKER_OPTS](#4-DOCKEROPTS) - - [Dockerized `skywire-networking-node` recipes](#Dockerized-skywire-networking-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-networking-node`s](#4-Create-new-dockerized-skywire-networking-nodes) + - [4. Create new dockerized `skywire-visor`s](#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-%22Hello-Mike-Hello-Joe%22-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 networking 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 networking 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 networking 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 networking 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 networking 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-networking-node, skywire-cli, hypervisor 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-networking-node` +### Run `skywire-visor` -`skywire-networking-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-networking-node. It takes one argument; the path of a configuration file (`skywire-config.json` if unspecified). -$ skywire-networking-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-networking-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-networking-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 (Networking) 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-networking-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-networking-node` is up and running with default environment, defa ### Transports -In order for a local Skywire App to communicate with an App running on a remote Skywire networking node, a transport to that remote Skywire networking 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: https://gith ## Running skywire in docker containers -There are two make goals for running in development environment dockerized `skywire-networking-node`. +There are two make goals for running in development environment dockerized `skywire-visor`. -### Run dockerized `skywire-networking-node` +### Run dockerized `skywire-visor` ```bash $ make docker-run @@ -261,7 +261,7 @@ $ make docker-run This will: -- create docker image `skywire-runner` for running `skywire-networking-node` +- create docker image `skywire-runner` for running `skywire-visor` - create docker network `SKYNET` (can be customized) - create docker volume ./node with linux binaries and apps - create container `SKY01` and starts it (can be customized) @@ -286,14 +286,14 @@ This will: │   ├── routing.db # │   └── transport_logs # ├── skywire-config.json # config of node -└── skywire-networking-node # `skywire-networking-node` binary compiled with DOCKER_OPTS +└── skywire-visor # `skywire-visor` binary compiled with DOCKER_OPTS ``` -Directory `./node` is mounted as docker volume for `skywire-networking-node` container. +Directory `./node` is mounted as docker volume for `skywire-visor` container. Inside docker container it is mounted on `/sky` -Structure of `./skywire-networking-node` partially replicates structure of project root directory. +Structure of `./skywire-visor` partially replicates structure of project root directory. Note that files created inside docker container has ownership `root:root`, so in case you want to `rm -rf ./node` (or other file operations) - you will need `sudo` it. @@ -309,14 +309,14 @@ $ make refresh-node This will: - stops running node - - recompiles `skywire-networking-node` for container + - recompiles `skywire-visor` for container - start node again ### Customization of dockers #### 1. DOCKER_IMAGE -Docker image for running `skywire-networking-node`. +Docker image for running `skywire-visor`. Default value: `skywire-runner` (built with `make docker-image`) @@ -329,13 +329,13 @@ DOCKER_IMAGE=golang make docker-run #buildpack-deps:stretch-scm is OK too #### 2. DOCKER_NETWORK -Name of virtual network for `skywire-networking-node` +Name of virtual network for `skywire-visor` Default value: SKYNET #### 3. DOCKER_NODE -Name of container for `skywire-networking-node` +Name of container for `skywire-visor` Default value: SKY01 @@ -345,7 +345,7 @@ Default value: SKY01 Default value: "GO111MODULE=on GOOS=linux" -### Dockerized `skywire-networking-node` recipes +### Dockerized `skywire-visor` recipes #### 1. Get Public Key of docker-node @@ -367,7 +367,7 @@ $ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' S $ firefox http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01):8000 ``` -#### 4. Create new dockerized `skywire-networking-node`s +#### 4. Create new dockerized `skywire-visor`s In case you need more dockerized nodes or maybe it's needed to customize node let's look how to create new node. @@ -375,8 +375,8 @@ let's look how to create new node. ```bash # 1. We need a folder for docker volume $ mkdir /tmp/SKYNODE -# 2. compile `skywire-networking-node` -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/skywire-networking-node ./cmd/skywire-networking-node +# 2. compile `skywire-visor` +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/skywire-visor ./cmd/skywire-visor # 3. compile apps $ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/skychat.v1.0 ./cmd/apps/skychat $ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/helloworld.v1.0 ./cmd/apps/helloworld @@ -395,9 +395,9 @@ $ tree /tmp/SKYNODE # │   ├── SSH-client.v1.0 # │   └── SSH.v1.0 # ├── skywire-config.json -# └── skywire-networking-node +# └── skywire-visor # So far so good. We prepared docker volume. Now we can: -$ docker run -it -v /tmp/SKYNODE:/sky --network=SKYNET --name=SKYNODE skywire-runner bash -c "cd /sky && ./skywire-networking-node" +$ docker run -it -v /tmp/SKYNODE:/sky --network=SKYNET --name=SKYNODE skywire-runner bash -c "cd /sky && ./skywire-visor" # [2019-03-15T13:55:08Z] INFO [messenger]: Opened new link with the server # 02a49bc0aa1b5b78f638e9189be4ed095bac5d6839c828465a8350f80ac07629c0 # [2019-03-15T13:55:08Z] INFO [messenger]: Updating discovery entry # [2019-03-15T13:55:10Z] INFO [skywire]: Connected to messaging servers @@ -438,7 +438,7 @@ export SW_NODE_B_PK=$(cat ./node/skywire-config.json|grep static_public_key |cut Idea of test from Erlang classics: https://youtu.be/uKfKtXYLG78?t=120 ```bash -# Setup: run skywire-networking-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/cmd/apps/helloworld/helloworld.go b/cmd/apps/helloworld/helloworld.go index b52d2307ac..ab65fdbed3 100644 --- a/cmd/apps/helloworld/helloworld.go +++ b/cmd/apps/helloworld/helloworld.go @@ -1,5 +1,5 @@ /* -simple client server app for skywire networking 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 6b145895fa..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 networking nodes. +Chat implements basic text messaging between skywire visors. Messaging UI is exposed via web interface. @@ -45,8 +45,8 @@ Compile binaries and start 2 nodes: ```bash $ go build -o apps/skychat.v1.0 ./cmd/apps/skychat -$ ./skywire-networking-node skywire1.json -$ ./skywire-networking-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 c9cc69c14b..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 networking 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 de3559ef84..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 networking node +proxy client app for skywire visor */ package main diff --git a/cmd/apps/therealproxy/README.md b/cmd/apps/therealproxy/README.md index ce35629017..e456c7c146 100644 --- a/cmd/apps/therealproxy/README.md +++ b/cmd/apps/therealproxy/README.md @@ -49,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-networking-node skywire1.json -$ ./skywire-networking-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 98ecd61974..e053c5badb 100644 --- a/cmd/apps/therealproxy/therealproxy.go +++ b/cmd/apps/therealproxy/therealproxy.go @@ -1,5 +1,5 @@ /* -proxy server app for skywire networking 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 7dae9166a0..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 networking node +ssh client app for skywire visor */ package main diff --git a/cmd/apps/therealssh/README.md b/cmd/apps/therealssh/README.md index 62d4454467..c61dfb028d 100644 --- a/cmd/apps/therealssh/README.md +++ b/cmd/apps/therealssh/README.md @@ -53,8 +53,8 @@ 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-networking-node skywire1.json -$ ./skywire-networking-node skywire2.json +$ ./skywire-visor skywire1.json +$ ./skywire-visor skywire2.json ``` Add public key of the second node to the auth file: diff --git a/cmd/apps/therealssh/therealssh.go b/cmd/apps/therealssh/therealssh.go index 7a4ce32e97..c7aa0f7189 100644 --- a/cmd/apps/therealssh/therealssh.go +++ b/cmd/apps/therealssh/therealssh.go @@ -1,5 +1,5 @@ /* -ssh server app for skywire networking node +ssh server app for skywire visor */ package main diff --git a/cmd/skywire-cli/commands/node/root.go b/cmd/skywire-cli/commands/node/root.go index ef1780451a..75d29467a5 100644 --- a/cmd/skywire-cli/commands/node/root.go +++ b/cmd/skywire-cli/commands/node/root.go @@ -17,10 +17,10 @@ func init() { RootCmd.PersistentFlags().StringVarP(&rpcAddr, "rpc", "", "localhost:3435", "RPC server address") } -// RootCmd contains commands that interact with the skywire-networking-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 Networking Node", + Short: "Contains sub-commands that interact with the local Skywire Visor", } func rpcClient() visor.RPCClient { diff --git a/cmd/skywire-cli/skywire-cli.go b/cmd/skywire-cli/skywire-cli.go index ca8bdf893c..0d2da60dec 100644 --- a/cmd/skywire-cli/skywire-cli.go +++ b/cmd/skywire-cli/skywire-cli.go @@ -1,5 +1,5 @@ /* -CLI for skywire networking node +CLI for skywire visor */ package main diff --git a/cmd/skywire-networking-node/skywire-networking-node.go b/cmd/skywire-networking-node/skywire-networking-node.go deleted file mode 100644 index c012625311..0000000000 --- a/cmd/skywire-networking-node/skywire-networking-node.go +++ /dev/null @@ -1,12 +0,0 @@ -/* -skywire networking node -*/ -package main - -import ( - "github.com/skycoin/skywire/cmd/skywire-networking-node/commands" -) - -func main() { - commands.Execute() -} diff --git a/cmd/skywire-networking-node/commands/root.go b/cmd/skywire-visor/commands/root.go similarity index 98% rename from cmd/skywire-networking-node/commands/root.go rename to cmd/skywire-visor/commands/root.go index da278981fd..55bde19769 100644 --- a/cmd/skywire-networking-node/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -46,8 +46,8 @@ type runCfg struct { var cfg *runCfg var rootCmd = &cobra.Command{ - Use: "skywire-networking-node [config-path]", - Short: "Networking Node for skywire", + Use: "skywire-visor [config-path]", + Short: "Visor for skywire", Run: func(_ *cobra.Command, args []string) { cfg.args = args diff --git a/cmd/skywire-networking-node/config.json b/cmd/skywire-visor/config.json similarity index 100% rename from cmd/skywire-networking-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 fdfcc30497..7f5ba19269 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-networking-node cmd/skywire-networking-node/skywire-networking-node.go &&\ + -o skywire-visor cmd/skywire-visor/skywire-visor.go &&\ 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 &&\ go build -mod=vendor -ldflags="-w -s" -o ./apps/socksproxy.v1.0 ./cmd/apps/therealproxy &&\ @@ -26,13 +26,13 @@ RUN go build -mod=vendor -tags netgo -ldflags="-w -s" \ ## Resulting image FROM ${base} as node-runner -COPY --from=builder /go/skywire/skywire-networking-node skywire-networking-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 RUN ./update.sh -ENTRYPOINT [ "./skywire-networking-node" ] +ENTRYPOINT [ "./skywire-visor" ] # default target FROM node-runner diff --git a/integration/InteractiveEnvironments.md b/integration/InteractiveEnvironments.md index db069d6303..f031d52ee5 100644 --- a/integration/InteractiveEnvironments.md +++ b/integration/InteractiveEnvironments.md @@ -80,7 +80,7 @@ Usage: The generic test environment will define the following: - skywire-services running on localhost -- 3 `skywire-networking-node`s: +- 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-networking-node with generic/nodeA.json - 7. NodeB: first skywire-networking-node with intermediary-nodeB.json - 8. NodeC: first skywire-networking-node 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-networking-node`s: +- 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-networking-node`s + 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-networking-node`s: +- 3 `skywire-visor`s: - NodeA - running `SSH` app - NodeB - intermediary node without apps - NodeC - running `SSH-client` app diff --git a/integration/messaging/env-vars.sh b/integration/messaging/env-vars.sh index 9496714bb3..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-networking-node ./integration/messaging/nodeA.json --tag NodeA' -alias RUN_B='./skywire-networking-node ./integration/messaging/intermediary-nodeB.json --tag NodeB' -alias RUN_C='./skywire-networking-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/proxy/env-vars.sh b/integration/proxy/env-vars.sh index 2b3e427ab0..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-networking-node ./integration/messaging/nodeA.json --tag NodeA' -alias RUN_B='go run ./cmd/skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB' -alias RUN_C='go run ./cmd/skywire-networking-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/run-generic-env.sh b/integration/run-generic-env.sh index 6a20f7d6e1..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-networking-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-networking-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-networking-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 c91ba5ace8..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-networking-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-networking-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-networking-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 5b047521ac..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-networking-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-networking-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-networking-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 7c62ff10bb..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-networking-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-networking-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-networking-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 c4a0820bca..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-networking-node ./integration/messaging/nodeA.json --tag NodeA' -alias RUN_B='go run ./cmd/skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB' -alias RUN_C='go run ./cmd/skywire-networking-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/start-restart-nodeB.sh b/integration/start-restart-nodeB.sh index 0e3e55d3cd..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-networking-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 809ea3580f..72dbdf8150 100755 --- a/integration/tear-down.sh +++ b/integration/tear-down.sh @@ -1,6 +1,6 @@ #!/bin/sh -# In case skywire-networking-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 50be88f482..5ccf5f9e6d 100755 --- a/integration/test-proxy.sh +++ b/integration/test-proxy.sh @@ -19,13 +19,13 @@ do sleep 10 echo Restarting nodeA and NodeB - ./bin/skywire-networking-node ./integration/proxy/nodeA.json --tag NodeA &> ./logs/proxy/$N/nodeA.log & - ./bin/skywire-networking-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-networking-note ./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 diff --git a/integration/test-ssh.sh b/integration/test-ssh.sh index 22929635cd..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-networking-node ./integration/ssh/nodeA.json --tag NodeA &> ./logs/ssh/$N/nodeA.log & - ./bin/skywire-networking-node ./integration/intermediary-nodeB.json --tag NodeB &> ./logs/ssh/$N/nodeB.log & - ./bin/skywire-networking-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/route-finder/client/client.go b/pkg/route-finder/client/client.go index 4ad7bccc13..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 networking 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 464a3628e7..a341836c74 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -1,4 +1,4 @@ -// Package router implements package router for skywire networking node. +// Package router implements package router for skywire visor. package router import ( diff --git a/pkg/routing/packet.go b/pkg/routing/packet.go index bb713efcae..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 networking 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 774ddfad02..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-networking-node. +// NodeDefaults returns the default config paths for skywire-visor. func NodeDefaults() ConfigPaths { paths := make(ConfigPaths) if wd, err := os.Getwd(); err == nil { diff --git a/pkg/visor/config.go b/pkg/visor/config.go index 6e1f4044b4..9652567223 100644 --- a/pkg/visor/config.go +++ b/pkg/visor/config.go @@ -173,7 +173,7 @@ type AppConfig struct { Args []string `json:"args"` } -// InterfaceConfig defines listening interfaces for skywire networking 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/visor/visor.go b/pkg/visor/visor.go index c1eb638141..0924aaf286 100644 --- a/pkg/visor/visor.go +++ b/pkg/visor/visor.go @@ -1,4 +1,4 @@ -// Package visor implements skywire networking node. +// Package visor implements skywire visor. package visor import ( From 4a21008886876f0f94d2a7a697f2f15422e11c6d Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Fri, 12 Jul 2019 09:20:02 +0300 Subject: [PATCH 10/10] Add skywire-visor binary to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 33e6de3b70..702eeda553 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ pkg/visor/foo/ /users.db /hypervisor /*-node +/*-visor /*-cli /*-server /*.json