Skip to content

Commit

Permalink
[WIP] Rename applications in skywire
Browse files Browse the repository at this point in the history
DONE:

- chat -> skychat

WIP:

- therealssh -> SSH
- therealproxy -> socksproxy
  • Loading branch information
ayuryshev committed May 30, 2019
1 parent b917300 commit 4d5d98c
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cmd/apps/chat/README.md → cmd/apps/skychat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Create 2 node config files:
```json
"apps": [
{
"app": "chat",
"app": "skychat",
"version": "1.0",
"auto_start": true,
"port": 1
Expand All @@ -28,7 +28,7 @@ Create 2 node config files:
```json
"apps": [
{
"app": "chat",
"app": "skychat",
"version": "1.0",
"auto_start": true,
"port": 1,
Expand All @@ -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
```
Expand Down
4 changes: 2 additions & 2 deletions cmd/apps/chat/chat.go → cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/skywire-cli/commands/node/gen-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/skywire-node/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"apps": [
{
"app": "chat",
"app": "skychat",
"version": "1.0",
"auto_start": true,
"ports": [1]
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
32 changes: 16 additions & 16 deletions pkg/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand All @@ -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"},
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/node/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4d5d98c

Please sign in to comment.