Skip to content

Commit

Permalink
Merge branch 'feature/v0.4.0' of github.com:skycoin/skywire into feat…
Browse files Browse the repository at this point in the history
…ure/vpn-improvements
  • Loading branch information
Darkren committed Sep 28, 2020
2 parents 06d9033 + 427d6a7 commit da7a697
Show file tree
Hide file tree
Showing 90 changed files with 2,484 additions and 1,497 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/apps/
/skywire/
/local*
/transport_logs

pkg/visor/apps/
pkg/visor/bar/
Expand Down
19 changes: 0 additions & 19 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,6 @@ builds:
- CGO_ENABLED=0
main: ./cmd/skywire-cli/
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}}
- id: hypervisor
binary: hypervisor
goos:
- linux
- darwin
goarch:
- amd64
- 386
- arm64
- arm
goarm:
- 7
ignore:
- goos: darwin
goarch: 386
env:
- CGO_ENABLED=0
main: ./cmd/hypervisor/
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}}
- id: skychat
binary: apps/skychat
goos:
Expand Down
17 changes: 7 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ generate: ## Generate mocks and config README's

clean: ## Clean project: remove created binaries and apps
-rm -rf ./apps
-rm -f ./skywire-visor ./skywire-cli ./setup-node ./hypervisor
-rm -f ./skywire-visor ./skywire-cli ./setup-node

install: ## Install `skywire-visor`, `skywire-cli`, `setup-node`, `hypervisor`
${OPTS} go install ${BUILD_OPTS} ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node ./cmd/hypervisor
install: ## Install `skywire-visor`, `skywire-cli`, `setup-node`
${OPTS} go install ${BUILD_OPTS} ./cmd/skywire-visor ./cmd/skywire-cli ./cmd/setup-node

rerun: stop
${OPTS} go build -race -o ./skywire-visor ./cmd/skywire-visor
Expand All @@ -97,7 +97,6 @@ vendorcheck: ## Run vendorcheck
GO111MODULE=off vendorcheck ./internal/...
GO111MODULE=off vendorcheck ./pkg/...
GO111MODULE=off vendorcheck ./cmd/apps/...
GO111MODULE=off vendorcheck ./cmd/hypervisor/...
GO111MODULE=off vendorcheck ./cmd/setup-node/...
GO111MODULE=off vendorcheck ./cmd/skywire-cli/...
GO111MODULE=off vendorcheck ./cmd/skywire-visor/...
Expand Down Expand Up @@ -143,17 +142,15 @@ host-apps: ## Build app
${OPTS} go build ${BUILD_OPTS} -o ./apps/vpn-client ./cmd/apps/vpn-client

# Bin
bin: ## Build `skywire-visor`, `skywire-cli`, `hypervisor`
bin: ## Build `skywire-visor`, `skywire-cli`
${OPTS} go build ${BUILD_OPTS} -o ./skywire-visor ./cmd/skywire-visor
${OPTS} go build ${BUILD_OPTS} -o ./skywire-cli ./cmd/skywire-cli
${OPTS} go build ${BUILD_OPTS} -o ./setup-node ./cmd/setup-node
${OPTS} go build ${BUILD_OPTS} -o ./hypervisor ./cmd/hypervisor

release: ## Build `skywire-visor`, `skywire-cli`, `hypervisor` and apps without -race flag
release: ## Build `skywire-visor`, `skywire-cli` and apps without -race flag
${OPTS} go build ${BUILD_OPTS} -o ./skywire-visor ./cmd/skywire-visor
${OPTS} go build ${BUILD_OPTS} -o ./skywire-cli ./cmd/skywire-cli
${OPTS} go build ${BUILD_OPTS} -o ./setup-node ./cmd/setup-node
${OPTS} go build ${BUILD_OPTS} -o ./hypervisor ./cmd/hypervisor
${OPTS} go build ${BUILD_OPTS} -o ./apps/skychat ./cmd/apps/skychat
${OPTS} go build ${BUILD_OPTS} -o ./apps/helloworld ./cmd/apps/helloworld
${OPTS} go build ${BUILD_OPTS} -o ./apps/skysocks ./cmd/apps/skysocks
Expand Down Expand Up @@ -189,7 +186,7 @@ build-ui: ## Builds the UI
cd $(MANAGER_UI_DIR) && npm run build
mkdir -p ${PWD}/bin
${OPTS} GOBIN=${PWD}/bin go get github.com/rakyll/statik
${PWD}/bin/statik -src=$(MANAGER_UI_DIR)/dist -dest ./cmd/hypervisor -f
${PWD}/bin/statik -src=$(MANAGER_UI_DIR)/dist -dest ./cmd/skywire-visor -f

# Dockerized skywire-visor
docker-image: ## Build docker image `skywire-runner`
Expand All @@ -208,7 +205,7 @@ docker-apps: ## Build apps binaries for dockerized skywire-visor. `go build` wit
-${DOCKER_OPTS} go build -race -o ./visor/apps/skysocks ./cmd/apps/skysocks
-${DOCKER_OPTS} go build -race -o ./visor/apps/skysocks-client ./cmd/apps/skysocks-client

docker-bin: ## Build `skywire-visor`, `skywire-cli`, `hypervisor`. `go build` with ${DOCKER_OPTS}
docker-bin: ## Build `skywire-visor`, `skywire-cli`. `go build` with ${DOCKER_OPTS}
${DOCKER_OPTS} go build -race -o ./visor/skywire-visor ./cmd/skywire-visor

docker-volume: dep docker-apps docker-bin bin ## Prepare docker volume for dockerized skywire-visor
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ cd skywire
# Build.
$ make build # installs all dependencies, build binaries and skywire apps

# Install skywire-visor, skywire-cli, hypervisor and app CLI execs.
# Install skywire-visor, skywire-cli and app CLI execs.
$ make install
```

Expand All @@ -54,7 +54,7 @@ $ skywire-cli visor gen-config
Additional options are displayed when `skywire-cli visor gen-config -h` is run.

If you are trying to test features from the develop branch,
you should use the `-t ` flag when generating config files for either `skywire-visor` or `hypervisor`.
you should use the `-t ` flag when generating config files for `skywire-visor`.

We will cover certain fields of the configuration file below.

Expand Down Expand Up @@ -85,7 +85,7 @@ In the above example, we have two other visors running on localhost (that we wis

#### `hypervisor` setup

Every node can be controlled by one or more hypervisors. The hypervisor allows to control and configure multiple visors.
Every node can be controlled by one or more hypervisors. The hypervisor allows controlling and configuring multiple visors.
In order to allow a hypervisor to access a visor,
the address and PubKey of the hypervisor needs to be configured first on the visor. Here is an example configuration:

Expand Down Expand Up @@ -121,19 +121,19 @@ $ skywire-cli -h

### Run `hypervisor`

In order to run the hypervisor, generate a hypervisor config file with
In order to run the visor UI, generate a visor config file with `--hypervisor` flag

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

Then you can start a hypervisor with:
Then visor will start visor UI when it is run:

```bash
$ hypervisor
$ skywire-visor
```

You can open up the hypervisor UI on `localhost:8000`.
You can open up the visor UI on `localhost:8000`.

### Windows

Expand Down
2 changes: 0 additions & 2 deletions ci_scripts/run-pkg-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ 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/hypervisor -run TestNewVisor >> ./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 TestDmsgDiscovery >> ./logs/pkg/TestDmsgDiscovery.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
Expand Down
2 changes: 1 addition & 1 deletion cmd/apps/skychat/static.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 41 additions & 2 deletions cmd/apps/vpn-client/vpn-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/skycoin/skywire/internal/vpn"
"github.com/skycoin/skywire/pkg/app"
"github.com/skycoin/skywire/pkg/app/appevent"
"github.com/skycoin/skywire/pkg/app/appnet"
"github.com/skycoin/skywire/pkg/routing"
"github.com/skycoin/skywire/pkg/skyenv"
Expand Down Expand Up @@ -46,7 +47,7 @@ func main() {
flag.Parse()

if *serverPKStr == "" {
// TODO: fix args passage for Windows
// TODO(darkrengarius): fix args passage for Windows
//*serverPKStr = "03e9019b3caa021dbee1c23e6295c6034ab4623aec50802fcfdd19764568e2958d"
log.Fatalln("VPN server pub key is missing")
}
Expand All @@ -70,7 +71,25 @@ func main() {
}
}

appClient := app.NewClient(nil)
var directIPsCh = make(chan net.IP, 100)

eventSub := appevent.NewSubscriber()

eventSub.OnTCPDial(func(data appevent.TCPDialData) {
ip, ok, err := vpn.ParseIP(data.RemoteAddr)
if err != nil {
log.WithError(err).Errorf("Failed to parse IP %s", data.RemoteAddr)
return
}
if !ok {
log.Errorf("Failed to parse IP %s", data.RemoteAddr)
return
}

directIPsCh <- ip
})

appClient := app.NewClient(eventSub)
defer appClient.Close()

log.Infof("Connecting to VPN server %s", serverPK.String())
Expand Down Expand Up @@ -106,6 +125,26 @@ func main() {
vpnClient.Close()
}()

var directRoutesDone bool
for !directRoutesDone {
select {
case ip := <-directIPsCh:
if err := vpnClient.AddDirectRoute(ip); err != nil {
log.WithError(err).Errorf("Failed to setup direct route to %s", ip.String())
}
default:
directRoutesDone = true
}
}

go func() {
for ip := range directIPsCh {
if err := vpnClient.AddDirectRoute(ip); err != nil {
log.WithError(err).Errorf("Failed to setup direct route to %s", ip.String())
}
}
}()

if err := vpnClient.Serve(); err != nil {
log.WithError(err).Fatalln("Error serving VPN")
}
Expand Down
31 changes: 0 additions & 31 deletions cmd/hypervisor/README.md

This file was deleted.

89 changes: 0 additions & 89 deletions cmd/hypervisor/commands/gen-config.go

This file was deleted.

Loading

0 comments on commit da7a697

Please sign in to comment.