Skip to content

Commit

Permalink
rename node to visor in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Kifen committed Jan 30, 2020
1 parent 94e9571 commit 1f5a3cd
Show file tree
Hide file tree
Showing 30 changed files with 146 additions and 137 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ The configuration file provides the configuration for `skywire-visor`. It is a t
You can generate a default configuration file by running:

```bash
$ skywire-cli node gen-config
$ skywire-cli visor gen-config
```

Additional options are displayed when `skywire-cli node gen-config -h` is run.
Additional options are displayed when `skywire-cli visor gen-config -h` is run.

We will cover certain fields of the configuration file below.

Expand Down Expand Up @@ -138,7 +138,7 @@ For `dmsgpty` usage, refer to [#run-dmsgpty](#run-dmsgpty).

### Run `skywire-visor`

`skywire-visor` hosts apps, proxies app's requests to remote nodes and exposes communication API that apps can use to implement communication protocols. App binaries are spawned by the node, communication between node and app is performed via unix pipes provided on app startup.
`skywire-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.

Note that `skywire-visor` requires a valid configuration file in order to execute.

Expand Down Expand Up @@ -195,17 +195,17 @@ Transports can be established via the `skywire-cli`.

```bash
# Establish transport to `0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881`.
$ skywire-cli node add-tp 0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881
$ skywire-cli visor add-tp 0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881

# List established transports.
$ skywire-cli node ls-tp
$ skywire-cli visor ls-tp
```

## App programming API

App is a generic binary that can be executed by the node. On app
startup node will open pair of unix pipes that will be used for
communication between app and node. `app` packages exposes
App is a generic binary that can be executed by the visor. On app
startup visor will open pair of unix pipes that will be used for
communication between app and visor. `app` packages exposes
communication API over the pipe.

```golang
Expand All @@ -214,13 +214,13 @@ communication API over the pipe.
// Setup setups app using default pair of pipes
func Setup(config *Config) (*App, error) {}

// Accept awaits for incoming loop confirmation request from a Node and
// Accept awaits for incoming loop confirmation request from a Visor and
// returns net.Conn for a received loop.
func (app *App) Accept() (net.Conn, error) {}

// Addr implements net.Addr for App connections.
&Addr{PubKey: pk, Port: 12}
// Dial sends create loop request to a Node and returns net.Conn for created loop.
// Dial sends create loop request to a Visor and returns net.Conn for created loop.
func (app *App) Dial(raddr *Addr) (net.Conn, error) {}

// Close implements io.Closer for App.
Expand Down Expand Up @@ -277,7 +277,7 @@ E.g.
$ make run_syslog ## run syslog-ng in docker container with logs mounted to /tmp/syslog
$ export SYSLOG_OPTS='--syslog localhost:514'
$ make integration-run-messaging ## or other integration-run-* goal
$ sudo cat /tmp/syslog/messages ## collected logs from NodeA, NodeB, NodeC instances
$ sudo cat /tmp/syslog/messages ## collected logs from VisorA, VisorB, VisorC instances
```

## Running skywire in docker containers
Expand Down Expand Up @@ -448,10 +448,10 @@ Instead of skywire-runner you can use:
#### 5. Env-vars for development-/testing- purposes

```bash
export SW_NODE_A=127.0.0.1
export SW_NODE_A_PK=$(cat ./skywire-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ')
export SW_NODE_B=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01)
export SW_NODE_B_PK=$(cat ./node/skywire-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ')
export SW_VISOR_A=127.0.0.1
export SW_VISOR_A_PK=$(cat ./skywire-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/skywire-config.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ')
```

#### 6. "Hello-Mike-Hello-Joe" test
Expand All @@ -463,13 +463,13 @@ Idea of test from Erlang classics: <https://youtu.be/uKfKtXYLG78?t=120>
$ make run
$ make docker-run
# Open in browser skychat application
$ firefox http://$SW_NODE_B:8000 &
$ firefox http://$SW_VISOR_B:8000 &
# add transport
$ ./skywire-cli add-transport $SW_NODE_B_PK
$ ./skywire-cli add-transport $SW_VISOR_B_PK
# "Hello Mike!" - "Hello Joe!" - "System is working!"
$ curl --data {'"recipient":"'$SW_NODE_A_PK'", "message":"Hello Mike!"}' -X POST http://$SW_NODE_B:8000/message
$ curl --data {'"recipient":"'$SW_NODE_B_PK'", "message":"Hello Joe!"}' -X POST http://$SW_NODE_A:8000/message
$ curl --data {'"recipient":"'$SW_NODE_A_PK'", "message":"System is working!"}' -X POST http://$SW_NODE_B:8000/message
$ curl --data {'"recipient":"'$SW_VISOR_A_PK'", "message":"Hello Mike!"}' -X POST http://$SW_VISOR_B:8000/message
$ curl --data {'"recipient":"'$SW_VISOR_B_PK'", "message":"Hello Joe!"}' -X POST http://$SW_VISOR_A:8000/message
$ curl --data {'"recipient":"'$SW_VISOR_A_PK'", "message":"System is working!"}' -X POST http://$SW_VISOR_B:8000/message
# Teardown
$ make stop && make docker-stop
```
2 changes: 1 addition & 1 deletion cmd/skywire-cli/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/spf13/cobra"

"github.com/SkycoinProject/skywire-mainnet/cmd/skywire-cli/commands/mdisc"
"github.com/SkycoinProject/skywire-mainnet/cmd/skywire-cli/commands/visor"
"github.com/SkycoinProject/skywire-mainnet/cmd/skywire-cli/commands/rtfind"
"github.com/SkycoinProject/skywire-mainnet/cmd/skywire-cli/commands/visor"
)

var rootCmd = &cobra.Command{
Expand Down
4 changes: 2 additions & 2 deletions cmd/skywire-cli/commands/visor/gen-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var genConfigCmd = &cobra.Command{
Short: "Generates a config file",
PreRun: func(_ *cobra.Command, _ []string) {
if output == "" {
output = pathutil.Defaults().Get(configLocType)
output = pathutil.VisorDefaults().Get(configLocType)
log.Infof("No 'output' set; using default path: %s", output)
}
var err error
Expand Down Expand Up @@ -110,7 +110,7 @@ func defaultConfig() *visor.Config {
defaultSkysocksConfig(""),
defaultSkysocksClientConfig(),
}
conf.Trusteds = []cipher.PubKey{}
conf.TrustedNodes = []cipher.PubKey{}

if testenv {
conf.Transport.Discovery = skyenv.TestTpDiscAddr
Expand Down
64 changes: 32 additions & 32 deletions integration/InteractiveEnvironments.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@
integration
├── generic # Generic environment
│   ├── env-vars.sh #
│   ├── nodeA.json #
│   └── nodeC.json #
│   ├── visorA.json #
│   └── visorC.json #
├── messaging # Messaging testing environment
│   ├── env-vars.sh #
│   ├── nodeA.json #
│   └── nodeC.json #
│   ├── visorA.json #
│   └── visorC.json #
├── proxy # Proxy testing environment
│   ├── env-vars.sh #
│   ├── nodeA.json #
│   └── nodeC.json #
│   ├── visorA.json #
│   └── visorC.json #
├── InteractiveEnvironments.md # You're reading it
├── intermediary-nodeB.json # NodeB configurationS
├── intermediary-visorB.json # VisorB configurationS
├── run-base-env.sh # base environment in detached tmux session
├── run-generic-env.sh # generic environment in tmux
├── run-proxy-env.sh # proxy environment in tmux
├── start-restart-nodeB.sh # script for restart in cycle NodeB
├── startup.sh # add transports between nodes
├── start-restart-visorB.sh # script for restart in cycle VisorB
├── startup.sh # add transports between visors
├── tear-down.sh # tear down everything
├── test-messaging-loop.sh # Test script for messaging in infinite loop
├── test-messaging.sh # Test one message between NodeA-NodeC, NodeC-NodeA
├── test-messaging.sh # Test one message between VisorA-VisorC, VisorC-VisorA
└── test-proxy.sh # Test script for proxy
```

Expand Down Expand Up @@ -74,16 +74,16 @@ The generic test environment will define the following:

- skywire-services running on localhost
- 3 `skywire-visor`s:
- NodeA, NodeC running all apps
- NodeB - intermediary node without apps
- VisorA, VisorC running all apps
- VisorB - intermediary visor without apps

**Run**

```bash
# Tear down everything
$ make integration-teardown

# Start all services and nodes
# Start all services and visors
$ make integration-run-generic

# Adds pre-defined transports
Expand All @@ -108,8 +108,8 @@ $ make integration-teardown

Instead of `../skywire/skywire-cli --rpc localhost:port [command]`, one can use:

- `CLI_A node ls-tp` - list transports from nodeA
- `CLI_B node add-tp $PK_A` - add transport on nodeB to nodeA
- `CLI_A visor ls-tp` - list transports from visorA
- `CLI_B visor add-tp $PK_A` - add transport on visorB to visorA

Consult with `./integration/env-vars.sh` for details.

Expand All @@ -122,11 +122,11 @@ These tests assume that the generic environment is running (via the aforemention
# To be run in the 'shell' tab of tmux.
./integration/test-messaging.sh
```
- **TEST 2: Test send/receive with unstable NodeB.**
1. Stop NodeB by switching to the 7th tmux window (`Ctrl+B` & `6`) and sending SIGTERM (`Ctrl-C`).
- **TEST 2: Test send/receive with unstable VisorB.**
1. Stop VisorB by switching to the 7th tmux window (`Ctrl+B` & `6`) and sending SIGTERM (`Ctrl-C`).
2. Run the following in the same window:
```bash
$ ./integration/start-restart-nodeB.sh
$ ./integration/start-restart-visorB.sh
```
3. Switch to the `shell` window and run:
```bash
Expand All @@ -137,22 +137,22 @@ These tests assume that the generic environment is running (via the aforemention

The following steps will be performed:

1. copy sw*.json and start-restart-nodeB.sh into skywire directory
1. copy sw*.json and start-restart-visorB.sh into skywire directory
2. Create 9 tmux windows:
1. MSGD: dmsg-discovery
2. MSG: dmsg-server
3. TRD: transport-discovery
4. RF: route-finder
5. SN: setup-node
6. NodeA: first skywire-visor with generic/nodeA.json
7. NodeB: first skywire-visor with intermediary-nodeB.json
8. NodeC: first skywire-visor with generic/nodeC.json
6. VisorA: first skywire-visor with generic/visorA.json
7. VisorB: first skywire-visor with intermediary-visorB.json
8. VisorC: first skywire-visor with generic/visorC.json
9. shell: new shell for interactive exploration
3. ENV-vars in shell-window:
1. $MSG_PK, $SN_PK - public keys of dmsg-server and setup-node
2. $PK_A, $PK_B, $PK_C - public keys of node_A, node_B, node_C
2. $PK_A, $PK_B, $PK_C - public keys of visor_A, visor_B, visor_C
3. $RPC_A, $RPC_B, $RPC_C - `--rpc` param for ../skywire/skywire-cli
4. $CHAT_A, $CHAT_B - addresses and ports for `skychat`-apps on node_A and node_C
4. $CHAT_A, $CHAT_B - addresses and ports for `skychat`-apps on visor_A and visor_C
4. Aliases in shell-window: `CLI_A`, `CLI_B`, `CLI_C`

### Proxy test environment
Expand All @@ -161,26 +161,26 @@ The proxy test environment will define the following:

- skywire-services running on localhost
- 3 `skywire-visor`s:
- NodeA - running `proxy` app
- NodeB - intermediary node without apps
- NodeC - running `proxy-client` app
- VisorA - running `proxy` app
- VsorB - intermediary visor without apps
- VisorC - running `proxy-client` app

#### Preparation

It's really tricky to make socks5 proxy work now from clean start.
Because `skysocks-client` needs:
- transport to NodeA
- NodeA must be running **before** start of `skysocks-client`
- transport to VisorA
- VisorA must be running **before** start of `skysocks-client`
Recipe for clean start:
1. Run `make integration-teardown`
2. Start `./integration/run-proxy-env.sh`
3. Run `make integration-startup`
4. Stop NodeA, NodeB, NodeC
5. Restart all nodes
6. Wait for message in NodeC logs about successful start of
4. Stop VisorA, VisorB, VisorC
5. Restart all visors
6. Wait for message in VisorC logs about successful start of
skysocks-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`
Expand Down
8 changes: 4 additions & 4 deletions integration/generic/env-vars.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This script needs to be `source`d from bash-compatible shell
# E.g. `source ./integration/generic/env-vars.sh` or `. ./integration/generic/env-vars.sh`
export PK_A=$(jq -r ".node.static_public_key" ./integration/generic/visorA.json)
export PK_A=$(jq -r ".visor.static_public_key" ./integration/generic/visorA.json)
export RPC_A=$(jq -r ".interfaces.rpc" ./integration/generic/visorA.json)
export PK_B=$(jq -r ".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/visorC.json)
export PK_B=$(jq -r ".visor.static_public_key" ./integration/intermediary-visorB.json)
export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-visorB.json)
export PK_C=$(jq -r ".visor.static_public_key" ./integration/generic/visorC.json)
export RPC_C=$(jq -r ".interfaces.rpc" ./integration/generic/visorC.json)

export CHAT_A=http://localhost:8000/message
Expand Down
6 changes: 3 additions & 3 deletions integration/generic/visorA.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.0",
"node": {
"visor": {
"static_public_key": "02072dd1e2ccd761e717096e1a264de1d8917e78e3176ca99dbf7ccf7292969845",
"static_secret_key": "7073e557aa2308b448525397ea2f45d56c9962c4dcdf82c5fdb5cc02fca0481c"
},
Expand All @@ -12,7 +12,7 @@
"discovery": "https://transport.discovery.skywire.skycoin.com",
"log_store": {
"type": "file",
"location": "./local/nodeA/transport_logs"
"location": "./local/visorA/transport_logs"
}
},
"routing": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"trusted_nodes": [],
"hypervisors": [],
"apps_path": "./apps",
"local_path": "./local/nodeA",
"local_path": "./local/visorA",
"log_level": "info",
"interfaces": {
"rpc": "localhost:3436"
Expand Down
6 changes: 3 additions & 3 deletions integration/generic/visorC.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.0",
"node": {
"visor": {
"static_public_key": "02c9ddf5c2ae6a5a2166028dafbc814eff3ec2352f429fb0aa37d96e1aa668f332",
"static_secret_key": "5ab3744ab56e4d0b82f9a915e07b8f05d51ec0f16ff8496bd92f4e378ca6c1fc"
},
Expand All @@ -12,7 +12,7 @@
"discovery": "https://transport.discovery.skywire.skycoin.com",
"log_store": {
"type": "file",
"location": "./local/nodeC/transport_logs"
"location": "./local/visorC/transport_logs"
}
},
"routing": {
Expand Down Expand Up @@ -46,7 +46,7 @@
"trusted_nodes": [],
"hypervisors": [],
"apps_path": "./apps",
"local_path": "./local/nodeC",
"local_path": "./local/visorC",
"log_level": "info",
"interfaces": {
"rpc": "localhost:3438"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.0",
"node": {
"visor": {
"static_public_key": "0372ee0a2b99b55906ac33b49704073ab90ab4f395d814d48d597b5b42c39e5c79",
"static_secret_key": "5092f14fe18bd7dcd34479c5d26bb3bf68b708ec74a12c4557091e82dd6e6c36"
},
Expand All @@ -12,7 +12,7 @@
"discovery": "https://transport.discovery.skywire.skycoin.com",
"log_store": {
"type": "file",
"location": "./local/nodeB/transport_logs"
"location": "./local/visorB/transport_logs"
}
},
"routing": {
Expand Down
14 changes: 7 additions & 7 deletions integration/messaging/env-vars.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This script needs to be `source`d from bash-compatible shell
# E.g. `source ./integration/generic/env-vars.sh` or `. ./integration/messaging/env-vars.sh`
export PK_A=$(jq -r ".node.static_public_key" ./integration/messaging/visorA.json)
export PK_A=$(jq -r ".visor.static_public_key" ./integration/messaging/visorA.json)
export RPC_A=$(jq -r ".interfaces.rpc" ./integration/messaging/visorA.json)
export PK_B=$(jq -r ".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/visorC.json)
export PK_B=$(jq -r ".visor.static_public_key" ./integration/intermediary-visorB.json)
export RPC_B=$(jq -r ".interfaces.rpc" ./integration/intermediary-visorB.json)
export PK_C=$(jq -r ".visor.static_public_key" ./integration/messaging/visorC.json)
export RPC_C=$(jq -r ".interfaces.rpc" ./integration/messaging/visorC.json)

export CHAT_A=http://localhost:8000/message
Expand All @@ -18,9 +18,9 @@ alias CLI_A='./skywire-cli --rpc $RPC_A'
alias CLI_B='./skywire-cli --rpc $RPC_B'
alias CLI_C='./skywire-cli --rpc $RPC_C'

alias RUN_A='./skywire-visor ./integration/messaging/visorA.json --tag NodeA'
alias RUN_B='./skywire-visor ./integration/messaging/intermediary-nodeB.json --tag NodeB'
alias RUN_C='./skywire-visor ./integration/messaging/visorC.json --tag NodeC'
alias RUN_A='./skywire-visor ./integration/messaging/visorA.json --tag VisorA'
alias RUN_B='./skywire-visor ./integration/messaging/intermediary-visorB.json --tag VisorB'
alias RUN_C='./skywire-visor ./integration/messaging/visorC.json --tag VisorC'

echo PK_A: $PK_A
echo PK_B: $PK_B
Expand Down
Loading

0 comments on commit 1f5a3cd

Please sign in to comment.