From 4d5d98cb8747d8cc9f2f6d7abfb9e7ad9b669092 Mon Sep 17 00:00:00 2001 From: Alex Yu Date: Thu, 30 May 2019 05:39:13 +0300 Subject: [PATCH] [WIP] Rename applications in skywire DONE: - chat -> skychat WIP: - therealssh -> SSH - therealproxy -> socksproxy --- Makefile | 6 ++-- README.md | 22 +++++++------- cmd/apps/{chat => skychat}/README.md | 6 ++-- cmd/apps/{chat => skychat}/chat.go | 4 +-- cmd/apps/{chat => skychat}/static.go | 0 cmd/apps/{chat => skychat}/static/index.html | 0 cmd/skywire-cli/commands/node/gen-config.go | 2 +- cmd/skywire-node/config.json | 2 +- pkg/node/node.go | 2 +- pkg/node/node_test.go | 32 ++++++++++---------- pkg/node/rpc_test.go | 4 +-- 11 files changed, 40 insertions(+), 40 deletions(-) rename cmd/apps/{chat => skychat}/README.md (87%) rename cmd/apps/{chat => skychat}/chat.go (96%) rename cmd/apps/{chat => skychat}/static.go (100%) rename cmd/apps/{chat => skychat}/static/index.html (100%) diff --git a/Makefile b/Makefile index 50433f8ef2..cd636d3379 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ dep: ## Sorts dependencies # Apps host-apps: ## Build app - ${OPTS} go build -race -o ./apps/chat.v1.0 ./cmd/apps/chat + ${OPTS} go build -race -o ./apps/skychat.v1.0 ./cmd/apps/skychat ${OPTS} go build -race -o ./apps/helloworld.v1.0 ./cmd/apps/helloworld ${OPTS} go build -race -o ./apps/therealproxy.v1.0 ./cmd/apps/therealproxy ${OPTS} go build -race -o ./apps/therealproxy-client.v1.0 ./cmd/apps/therealproxy-client @@ -114,7 +114,7 @@ release: ## Build skywire-node`, skywire-cli, manager-node, therealssh-cli and a ${OPTS} go build -o ./setup-node ./cmd/setup-node ${OPTS} go build -o ./manager-node ./cmd/manager-node ${OPTS} go build -o ./therealssh-cli ./cmd/therealssh-cli - ${OPTS} go build -o ./apps/chat.v1.0 ./cmd/apps/chat + ${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/therealproxy.v1.0 ./cmd/apps/therealproxy ${OPTS} go build -o ./apps/therealproxy-client.v1.0 ./cmd/apps/therealproxy-client @@ -135,7 +135,7 @@ docker-network: ## Create docker network ${DOCKER_NETWORK} -docker network create ${DOCKER_NETWORK} docker-apps: ## Build apps binaries for dockerized skywire-node. `go build` with ${DOCKER_OPTS} - -${DOCKER_OPTS} go build -race -o ./node/apps/chat.v1.0 ./cmd/apps/chat + -${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/therealproxy.v1.0 ./cmd/apps/therealproxy -${DOCKER_OPTS} go build -race -o ./node/apps/therealproxy-client.v1.0 ./cmd/apps/therealproxy-client diff --git a/README.md b/README.md index 14e3a2424f..840f070402 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ $ skywire-cli -h After `skywire-node` is up and running with default environment, default apps are run with the configuration specified in `skywire-config.json`. Refer to the following for usage of the default apps: -- [Chat](/cmd/apps/chat) +- [Chat](/cmd/apps/skychat) - [Hello World](/cmd/apps/helloworld) - [The Real Proxy](/cmd/apps/therealproxy) ([Client](/cmd/apps/therealproxy-client)) - [The Real SSH](/cmd/apps/therealssh) ([Client](/cmd/apps/therealssh-client)) @@ -182,14 +182,14 @@ This will: ``` ./node ├── apps # node `apps` compiled with DOCKER_OPTS -│   ├── chat.v1.0 # +│   ├── skychat.v1.0 # │   ├── helloworld.v1.0 # │   ├── therealproxy-client.v1.0 # │   ├── therealproxy.v1.0 # │   ├── therealssh-client.v1.0 # │   └── therealssh.v1.0 # ├── local # **Created inside docker** -│   ├── chat # according to "local_path" in skywire-config.json +│   ├── skychat # according to "local_path" in skywire-config.json │   ├── therealproxy # │   └── therealssh # ├── PK # contains public key of node @@ -272,7 +272,7 @@ $ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' S # 192.168.112 ``` -#### 3. Open in browser containerized `chat` application +#### 3. Open in browser containerized `skychat` application ```bash $ firefox http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01):8000 @@ -289,7 +289,7 @@ $ mkdir /tmp/SKYNODE # 2. compile `skywire-node` $ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/skywire-node ./cmd/skywire-node # 3. compile apps -$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/chat.v1.0 ./cmd/apps/chat +$ 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/therealproxy.v1.0 ./cmd/apps/therealproxy $ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/therealssh.v1.0 ./cmd/apps/therealssh @@ -300,7 +300,7 @@ $ skywire-cli node gen-config -o /tmp/SKYNODE/skywire-config.json $ tree /tmp/SKYNODE # /tmp/SKYNODE # ├── apps -# │   ├── chat.v1.0 +# │   ├── skychat.v1.0 # │   ├── helloworld.v1.0 # │   ├── therealproxy.v1.0 # │   ├── therealssh-client.v1.0 @@ -312,16 +312,16 @@ $ docker run -it -v /tmp/SKYNODE:/sky --network=SKYNET --name=SKYNODE skywire-ru # [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 -# [2019-03-15T13:55:10Z] INFO [skywire]: Starting chat.v1.0 +# [2019-03-15T13:55:10Z] INFO [skywire]: Starting skychat.v1.0 # [2019-03-15T13:55:10Z] INFO [skywire]: Starting RPC interface on 127.0.0.1:3435 # [2019-03-15T13:55:10Z] INFO [skywire]: Starting therealproxy.v1.0 # [2019-03-15T13:55:10Z] INFO [skywire]: Starting therealssh.v1.0 # [2019-03-15T13:55:10Z] INFO [skywire]: Starting packet router # [2019-03-15T13:55:10Z] INFO [router]: Starting router # [2019-03-15T13:55:10Z] INFO [trmanager]: Starting transport manager -# [2019-03-15T13:55:10Z] INFO [router]: Got new App request with type Init: {"app-name":"chat",# "app-version":"1.0","protocol-version":"0.0.1"} -# [2019-03-15T13:55:10Z] INFO [router]: Handshaked new connection with the app chat.v1.0 -# [2019-03-15T13:55:10Z] INFO [chat.v1.0]: 2019/03/15 13:55:10 Serving HTTP on :8000 +# [2019-03-15T13:55:10Z] INFO [router]: Got new App request with type Init: {"app-name":"skychat",# "app-version":"1.0","protocol-version":"0.0.1"} +# [2019-03-15T13:55:10Z] INFO [router]: Handshaked new connection with the app skychat.v1.0 +# [2019-03-15T13:55:10Z] INFO [skychat.v1.0]: 2019/03/15 13:55:10 Serving HTTP on :8000 # [2019-03-15T13:55:10Z] INFO [router]: Got new App request with type Init: {"app-name":"therealssh",# "app-version":"1.0","protocol-version":"0.0.1"} # [2019-03-15T13:55:10Z] INFO [router]: Handshaked new connection with the app therealssh.v1.0 # [2019-03-15T13:55:10Z] INFO [router]: Got new App request with type Init: {"app-name":"therealproxy",# "app-version":"1.0","protocol-version":"0.0.1"} @@ -352,7 +352,7 @@ Idea of test from Erlang classics: https://youtu.be/uKfKtXYLG78?t=120 # Setup: run skywire-nodes on host and in docker $ make run $ make docker-run -# Open in browser chat application +# Open in browser skychat application $ firefox http://$SW_NODE_B:8000 & # add transport $ ./skywire-cli add-transport $SW_NODE_B_PK diff --git a/cmd/apps/chat/README.md b/cmd/apps/skychat/README.md similarity index 87% rename from cmd/apps/chat/README.md rename to cmd/apps/skychat/README.md index 4293865ac8..66aed3b624 100644 --- a/cmd/apps/chat/README.md +++ b/cmd/apps/skychat/README.md @@ -15,7 +15,7 @@ Create 2 node config files: ```json "apps": [ { - "app": "chat", + "app": "skychat", "version": "1.0", "auto_start": true, "port": 1 @@ -28,7 +28,7 @@ Create 2 node config files: ```json "apps": [ { - "app": "chat", + "app": "skychat", "version": "1.0", "auto_start": true, "port": 1, @@ -40,7 +40,7 @@ Create 2 node config files: Compile binaries and start 2 nodes: ```bash -$ go build -o apps/chat.v1.0 ./cmd/apps/chat +$ go build -o apps/skychat.v1.0 ./cmd/apps/skychat $ ./skywire-node skywire1.json $ ./skywire-node skywire2.json ``` diff --git a/cmd/apps/chat/chat.go b/cmd/apps/skychat/chat.go similarity index 96% rename from cmd/apps/chat/chat.go rename to cmd/apps/skychat/chat.go index bc1df2936b..af73e516f0 100644 --- a/cmd/apps/chat/chat.go +++ b/cmd/apps/skychat/chat.go @@ -1,7 +1,7 @@ //go:generate esc -o static.go -prefix static static /* -chat app for skywire node +skychat app for skywire node */ package main @@ -30,7 +30,7 @@ var ( func main() { flag.Parse() - a, err := app.Setup(&app.Config{AppName: "chat", AppVersion: "1.0", ProtocolVersion: "0.0.1"}) + a, err := app.Setup(&app.Config{AppName: "skychat", AppVersion: "1.0", ProtocolVersion: "0.0.1"}) if err != nil { log.Fatal("Setup failure: ", err) } diff --git a/cmd/apps/chat/static.go b/cmd/apps/skychat/static.go similarity index 100% rename from cmd/apps/chat/static.go rename to cmd/apps/skychat/static.go diff --git a/cmd/apps/chat/static/index.html b/cmd/apps/skychat/static/index.html similarity index 100% rename from cmd/apps/chat/static/index.html rename to cmd/apps/skychat/static/index.html diff --git a/cmd/skywire-cli/commands/node/gen-config.go b/cmd/skywire-cli/commands/node/gen-config.go index b78940c4ef..f3e512443d 100644 --- a/cmd/skywire-cli/commands/node/gen-config.go +++ b/cmd/skywire-cli/commands/node/gen-config.go @@ -86,7 +86,7 @@ func defaultConfig() *node.Config { passcode := base64.StdEncoding.EncodeToString(cipher.RandByte(8)) conf.Apps = []node.AppConfig{ - {App: "chat", Version: "1.0", Port: 1, AutoStart: true, Args: []string{}}, + {App: "skychat", Version: "1.0", Port: 1, AutoStart: true, Args: []string{}}, {App: "therealssh", Version: "1.0", Port: 2, AutoStart: true, Args: []string{}}, {App: "therealproxy", Version: "1.0", Port: 3, AutoStart: true, Args: []string{"-passcode", passcode}}, } diff --git a/cmd/skywire-node/config.json b/cmd/skywire-node/config.json index 80e7745e57..402030c195 100644 --- a/cmd/skywire-node/config.json +++ b/cmd/skywire-node/config.json @@ -17,7 +17,7 @@ }, "apps": [ { - "app": "chat", + "app": "skychat", "version": "1.0", "auto_start": true, "ports": [1] diff --git a/pkg/node/node.go b/pkg/node/node.go index 13ed9996c6..3a37cb8992 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -45,7 +45,7 @@ const Version = "0.0.1" const supportedProtocolVersion = "0.0.1" -var reservedPorts = map[uint16]string{0: "router", 1: "chat", 2: "therealssh", 3: "therealproxy"} +var reservedPorts = map[uint16]string{0: "router", 1: "skychat", 2: "therealssh", 3: "therealproxy"} // AppState defines state parameters for a registered App. type AppState struct { diff --git a/pkg/node/node_test.go b/pkg/node/node_test.go index f9248631fa..1b69defe8a 100644 --- a/pkg/node/node_test.go +++ b/pkg/node/node_test.go @@ -67,10 +67,10 @@ func TestNodeStartClose(t *testing.T) { r := new(mockRouter) executer := &MockExecuter{} conf := []AppConfig{ - {App: "chat", Version: "1.0", AutoStart: true, Port: 1}, + {App: "skychat", Version: "1.0", AutoStart: true, Port: 1}, {App: "foo", Version: "1.0", AutoStart: false}, } - defer os.RemoveAll("chat") + defer os.RemoveAll("skychat") node := &Node{config: &Config{}, router: r, executer: executer, appsConf: conf, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test")} mConf := &messaging.Config{PubKey: cipher.PubKey{}, SecKey: cipher.SecKey{}, Discovery: client.NewMock()} @@ -92,51 +92,51 @@ func TestNodeStartClose(t *testing.T) { require.NoError(t, <-errCh) require.Len(t, executer.cmds, 1) - assert.Equal(t, "chat.v1.0", executer.cmds[0].Path) - assert.Equal(t, "chat/v1.0", executer.cmds[0].Dir) + assert.Equal(t, "skychat.v1.0", executer.cmds[0].Path) + assert.Equal(t, "skychat/v1.0", executer.cmds[0].Dir) } func TestNodeSpawnApp(t *testing.T) { r := new(mockRouter) executer := &MockExecuter{} - defer os.RemoveAll("chat") - apps := []AppConfig{{App: "chat", Version: "1.0", AutoStart: false, Port: 10, Args: []string{"foo"}}} + defer os.RemoveAll("skychat") + apps := []AppConfig{{App: "skychat", Version: "1.0", AutoStart: false, Port: 10, Args: []string{"foo"}}} node := &Node{router: r, executer: executer, appsConf: apps, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test")} - require.NoError(t, node.StartApp("chat")) + require.NoError(t, node.StartApp("skychat")) time.Sleep(100 * time.Millisecond) - require.NotNil(t, node.startedApps["chat"]) + require.NotNil(t, node.startedApps["skychat"]) executer.Lock() require.Len(t, executer.cmds, 1) - assert.Equal(t, "chat.v1.0", executer.cmds[0].Path) - assert.Equal(t, "chat/v1.0", executer.cmds[0].Dir) - assert.Equal(t, []string{"chat.v1.0", "foo"}, executer.cmds[0].Args) + assert.Equal(t, "skychat.v1.0", executer.cmds[0].Path) + assert.Equal(t, "skychat/v1.0", executer.cmds[0].Dir) + assert.Equal(t, []string{"skychat.v1.0", "foo"}, executer.cmds[0].Args) executer.Unlock() ports := r.Ports() require.Len(t, ports, 1) assert.Equal(t, uint16(10), ports[0]) - require.NoError(t, node.StopApp("chat")) + require.NoError(t, node.StopApp("skychat")) } func TestNodeSpawnAppValidations(t *testing.T) { conn, _ := net.Pipe() r := new(mockRouter) executer := &MockExecuter{err: errors.New("foo")} - defer os.RemoveAll("chat") + defer os.RemoveAll("skychat") node := &Node{router: r, executer: executer, - startedApps: map[string]*appBind{"chat": {conn, 10}}, + startedApps: map[string]*appBind{"skychat": {conn, 10}}, logger: logging.MustGetLogger("test")} cases := []struct { conf *AppConfig err string }{ - {&AppConfig{App: "chat", Version: "1.0", Port: 2}, "can't bind to reserved port 2"}, - {&AppConfig{App: "chat", Version: "1.0", Port: 10}, "app chat is already started"}, + {&AppConfig{App: "skychat", Version: "1.0", Port: 2}, "can't bind to reserved port 2"}, + {&AppConfig{App: "skychat", Version: "1.0", Port: 10}, "app skychat is already started"}, {&AppConfig{App: "foo", Version: "1.0", Port: 11}, "failed to run app executable: foo"}, } diff --git a/pkg/node/rpc_test.go b/pkg/node/rpc_test.go index a374cd6651..bd03e1259e 100644 --- a/pkg/node/rpc_test.go +++ b/pkg/node/rpc_test.go @@ -49,7 +49,7 @@ func TestListApps(t *testing.T) { func TestStartStopApp(t *testing.T) { router := new(mockRouter) executer := new(MockExecuter) - defer os.RemoveAll("chat") + defer os.RemoveAll("skychat") apps := []AppConfig{{App: "foo", Version: "1.0", AutoStart: false, Port: 10}} node := &Node{router: router, executer: executer, appsConf: apps, startedApps: map[string]*appBind{}, logger: logging.MustGetLogger("test")} @@ -89,7 +89,7 @@ func TestStartStopApp(t *testing.T) { func TestRPC(t *testing.T) { r := new(mockRouter) executer := new(MockExecuter) - defer os.RemoveAll("chat") + defer os.RemoveAll("skychat") pk1, _, tm1, tm2, errCh, err := transport.MockTransportManagersPair() require.NoError(t, err)