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()) }