Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto-peering visors to the hypervisor (skybian) #1309

Merged
merged 22 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 65 additions & 55 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- `autoConn` and `isPublic` flag for `skywire-cli` [#1309](https://github.com/skycoin/skywire/pull/1319)
- add error packet to routes to propagate route errors [#1181](https://github.com/skycoin/skywire/issues/1181)
- add `skywire-cli chvpk` to get list of connected hypervisors [#1306](https://github.com/skycoin/skywire/issues/1306)
- add pong packet to send as a response to ping to calculate latency [#1261](https://github.com/skycoin/skywire/issues/1261)
- port of the autopeering system from skybian to the skywire source code. [#1309](https://github.com/skycoin/skywire/pull/1309)
- `-l --hvip` and `-m --autopeer` flags for `skywire-visor` ; connect to a hypervisor by ip address. [#1309](https://github.com/skycoin/skywire/pull/1309)
- `skywire-cli visor pk -w` flag ; http endpoint for visor public key [#1309](https://github.com/skycoin/skywire/pull/1309)
- `-y --autoconn` and `-z --ispublic` flags for `skywire-cli config gen` [#1319](https://github.com/skycoin/skywire/pull/1319)
- error packet to routes to propagate route errors [#1181](https://github.com/skycoin/skywire/issues/1181)
- `skywire-cli chvpk` subcommand to list remote hypervisor(s) a visor is currently connected to [#1306](https://github.com/skycoin/skywire/issues/1306)
- pong packet to send as a response to ping to calculate latency [#1261](https://github.com/skycoin/skywire/issues/1261)

### Changed

Expand All @@ -27,6 +30,42 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## 1.0.0

### Added

- `skywire-cli hv` subcommands for opening the various UIs or printing links to them (HVUI, VPNUI, DMSGPTYUI) [#1270](https://github.com/skycoin/skywire/pull/1270)
- added `add-rhv` and `disable-rhv` flags to `skywire-visor` for adding remote hypervisor PK and disable remote hypervisor PK(s) on config file [#1113](https://github.com/skycoin/skywire/pull/1113)
- shorthand flags for commands [#1151](https://github.com/skycoin/skywire/pull/1151)
- blue & white color scheme with coloredcobra [#1151](https://github.com/skycoin/skywire/pull/1151)
- ascii art text modal of program name to help menus [#1151](https://github.com/skycoin/skywire/pull/1151)
- `--all` flag to skywire-cli & visor to show extra flags [#1151](https://github.com/skycoin/skywire/pull/1151)
- `skywire-cli config gen -n --stdout` write config to stdout [#1151](https://github.com/skycoin/skywire/pull/1151)
- `skywire-cli config gen -w, --hide` dont print the config to the terminal [#1151](https://github.com/skycoin/skywire/pull/1151)
- `skywire-cli config gen --print` parse test ; read config from file & print [#1151](https://github.com/skycoin/skywire/pull/1151)
- `skywire-cli config gen -a, --url` services conf (default "conf.skywire.skycoin.com") [#1151](https://github.com/skycoin/skywire/pull/1151)
- fetch service from endpoint [#1151](https://github.com/skycoin/skywire/pull/1151)
- `skywire-cli visor app` app settings command [#1132](https://github.com/skycoin/skywire/pull/1132)
- `skywire-cli visor route` view and set rules command [#1132](https://github.com/skycoin/skywire/pull/1132)
- `skywire-cli visor tp` view and set transports command [#1132](https://github.com/skycoin/skywire/pull/1132)
- `skywire-cli visor vpn` vpn interface command [#1132](https://github.com/skycoin/skywire/pull/1132)
- root permissions detection
- error on different version config / visor
- display update command on config version error
- support for piping config generated by skywire-cli to skywire-visor via stdin [#1147](https://github.com/skycoin/skywire/pull/1147)
- support for detecting skywire version when `go run`
- `run-vpnsrv` makefile directive [#1147](https://github.com/skycoin/skywire/pull/1147)
- `run-source-test` makefile directive [#1147](https://github.com/skycoin/skywire/pull/1147)
- `run-vpnsrv-test` makefile directive [#1147](https://github.com/skycoin/skywire/pull/1147)
- `run-source-dmsghttp` makefile directive [#1147](https://github.com/skycoin/skywire/pull/1147)
- `run-source-dmsghttp-test` makefile directive [#1147](https://github.com/skycoin/skywire/pull/1147)
- `run-vpnsrv-dmsghttp` makefile directive [#1147](https://github.com/skycoin/skywire/pull/1147)
- `run-vpnsrv -dmsghttp-test` makefile directive [#1147](https://github.com/skycoin/skywire/pull/1147)
- `install-system-linux` and `install-system-linux-systray` makefile directives [#1180](https://github.com/skycoin/skywire/pull/1180)
- `skywire-cli dmsgpty list` to view of connected remote visor to hypervisor [#1250](https://github.com/skycoin/skywire/pull/1250)
- `skywire-cli dmsgpty start <pk>` to connect through dmsgpty to remote visor [#1250](https://github.com/skycoin/skywire/pull/1250)
- `make win-installer-latest` to create installer for latest version of released, not pre-release.
- `trace` log level is added
- `--log-level` flag to generate and update config by `skywire-cli`

### Changed
- remove dsmghttp migration to skywire-visor starting
- only support current version of config
Expand All @@ -40,55 +79,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- remove config path from V1 struct
- remove all instance of the visor writing to the config file except via api
- remove path to dmsghttp-config.json from config
- revise versioning
- revise versioning
- move to skyenv
- remove transports cache from visor initialization and check them before make route
- `run-source` makefile directive write config to stdout & read config from stdin
- fixed skywire-visor uses skywire-config.json (default config name) without needing to specify
- `make win-installer` need new argument `CUSTOM_VERSION` to get make installer for this version, use for pre-releases
- changed the log levels of most of the logs making info level clutter free

### Added
- added `add-rhv` and `disable-rhv` flags to `skywire-visor` for adding remote hypervisor PK and disable remote hypervisor PK(s) on config file
- shorthand flags for commands
- blue & white color scheme with coloredcobra
- ascii art text modal of program name to help menus
- `--all` flag to skywire-cli & visor to show extra flags
- `skywire-cli config gen -n --stdout` write config to stdout
- `skywire-cli config gen -w, --hide` dont print the config to the terminal
- `skywire-cli config gen --print` parse test ; read config from file & print
- `skywire-cli config gen -a, --url` services conf (default "conf.skywire.skycoin.com")
- fetch service from endpoint
- `skywire-cli visor app` app settings command
- `skywire-cli visor route` view and set rules command
- `skywire-cli visor tp` view and set transports command
- `skywire-cli visor vpn` vpn interface command
- root permissions detection
- error on different version config / visor
- display update command on config version error
- support for piping config generated by skywire-cli to skywire-visor via stdin
- support for detecting skywire version when `go run`
- `run-vpnsrv` makefile directive
- `run-source-test` makefile directive
- `run-vpnsrv-test` makefile directive
- `run-source-dmsghttp` makefile directive
- `run-source-dmsghttp-test` makefile directive
- `run-vpnsrv-dmsghttp` makefile directive
- `run-vpnsrv -dmsghttp-test` makefile directive
- `install-system-linux` and `install-system-linux-systray` makefile directives
- `skywire-cli dmsgpty list` to view of connected remote visor to hypervisor
- `skywire-cli dmsgpty start <pk>` to connect through dmsgpty to remote visor
- `make win-installer-latest` to create installer for latest version of released, not pre-release.
- `trace` log level is added
- `--log-level` flag to generate and update config by `skywire-cli`
### Removed

## 0.6.0
- inbuilt updater ; instead use packages and the system package manger for installation and updates [#1251](https://github.com/skycoin/skywire/pull/1251)

### Changed
## 0.6.0

- detecting OS in runtime removed
- skybian flag `-s` removed from `skywire-cli config gen`
- migrate updating logic to debian package model

### Added

Expand All @@ -110,8 +114,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- added `skywire-cli visor vpn-ui` and `skywire-cli visor vpn-url` commands
- added dsmghttp migration to skywire-visor starting
- added network monitor PKs to skyenv

### Changed

- detecting OS in runtime removed
- skybian flag `-s` removed from `skywire-cli config gen`
- migrate updating logic to debian package model

## 0.5.0

### Added

- added persistent_transports field to the config and UI
- added stun_servers field to the config
- added is_public field to root section
- added public_autoconnect field to transport section
- added transport_setup_nodes field to transport section
- added MinHops field to V1Routing section of config
- added `skywire-cli config` subcommand
- added connection_duration field to `/api/visor/{pk}/apps/vpn-client/connections`

### Changed

- config updated to `v1.1.0`
Expand All @@ -128,18 +150,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- replaced port field to dmsg_port in config
- updated visor health status checks, no longer querying multiple external services endpoints.


### Added

- added persistent_transports field to the config and UI
- added stun_servers field to the config
- added is_public field to root section
- added public_autoconnect field to transport section
- added transport_setup_nodes field to transport section
- added MinHops field to V1Routing section of config
- added `skywire-cli config` subcommand
- added connection_duration field to `/api/visor/{pk}/apps/vpn-client/connections`

## 0.2.1 - 2020.04.07

### Changed
Expand Down
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -334,43 +334,43 @@ prepare-systray: prepare

## Run skywire from source, without compiling binaries - requires skywire cloned
run-source: prepare
go run ./cmd/skywire-cli/skywire-cli.go config gen -in | go run ./cmd/skywire-visor/skywire-visor.go -nb || true
go run ./cmd/skywire-cli/skywire-cli.go config gen -in | sudo go run ./cmd/skywire-visor/skywire-visor.go -n || true

## Run skywire from source, with vpn server enabled
run-systray: prepare-systray
go run -tags systray ./cmd/skywire-cli/skywire-cli.go config gen -ni | go run -tags systray ./cmd/skywire-visor/skywire-visor.go -nb || true
go run -tags systray ./cmd/skywire-cli/skywire-cli.go config gen -ni | sudo go run -tags systray ./cmd/skywire-visor/skywire-visor.go -n || true

## Run skywire from source, without compiling binaries - requires skywire cloned
run-vpnsrv: prepare
go run ./cmd/skywire-cli/skywire-cli.go config gen -in --servevpn | go run ./cmd/skywire-visor/skywire-visor.go -nb || true
go run ./cmd/skywire-cli/skywire-cli.go config gen -in --servevpn | sudo go run ./cmd/skywire-visor/skywire-visor.go -n || true

## Run skywire from source with test endpoints
run-source-test: prepare
go run ./cmd/skywire-cli/skywire-cli.go config gen -nit | go run ./cmd/skywire-visor/skywire-visor.go -nb || true
go run ./cmd/skywire-cli/skywire-cli.go config gen -nit | sudo go run ./cmd/skywire-visor/skywire-visor.go -n || true

## Run skywire from source, with vpn server enabled
run-vpnsrv-test: prepare
go run ./cmd/skywire-cli/skywire-cli.go config gen -nit --servevpn | go run ./cmd/skywire-visor/skywire-visor.go -nb || true
go run ./cmd/skywire-cli/skywire-cli.go config gen -nit --servevpn | sudo go run ./cmd/skywire-visor/skywire-visor.go -n || true

## Run skywire from source, with vpn server enabled
run-systray-test: prepare-systray
go run -tags systray ./cmd/skywire-cli/skywire-cli.go config gen -nit | go run -tags systray ./cmd/skywire-visor/skywire-visor.go -nb || true
go run -tags systray ./cmd/skywire-cli/skywire-cli.go config gen -nit | sudo go run -tags systray ./cmd/skywire-visor/skywire-visor.go -nb || true

## Run skywire from source with dmsghttp config
run-source-dmsghttp: prepare
go run ./cmd/skywire-cli/skywire-cli.go config gen -din | go run ./cmd/skywire-visor/skywire-visor.go -nb || true
go run ./cmd/skywire-cli/skywire-cli.go config gen -din | sudo go run ./cmd/skywire-visor/skywire-visor.go -nb || true

## Run skywire from source with dmsghttp config and vpn server
run-vpnsrv-dmsghttp: prepare
go run ./cmd/skywire-cli/skywire-cli.go config gen -din --servevpn | go run ./cmd/skywire-visor/skywire-visor.go -nb || true
go run ./cmd/skywire-cli/skywire-cli.go config gen -din --servevpn | sudo go run ./cmd/skywire-visor/skywire-visor.go -nb || true

## Run skywire from source with dmsghttp config and test endpoints
run-source-dmsghttp-test: prepare
go run ./cmd/skywire-cli/skywire-cli.go config gen -dint | go run ./cmd/skywire-visor/skywire-visor.go -nb || true
go run ./cmd/skywire-cli/skywire-cli.go config gen -dint | sudo go run ./cmd/skywire-visor/skywire-visor.go -nb || true

## Run skywire from source with dmsghttp config, vpn server, and test endpoints
run-vpnsrv-dmsghttp-test: prepare
go run ./cmd/skywire-cli/skywire-cli.go config gen -dint --servevpn | go run ./cmd/skywire-visor/skywire-visor.go -nb || true
go run ./cmd/skywire-cli/skywire-cli.go config gen -dint --servevpn | sudo go run ./cmd/skywire-visor/skywire-visor.go -nb || true

lint-ui: ## Lint the UI code
cd $(MANAGER_UI_DIR) && npm run lint
Expand Down
43 changes: 43 additions & 0 deletions cmd/skywire-cli/commands/hv/hvpk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package clihv

import (
"fmt"
"net"
"os"
"strings"

"github.com/spf13/cobra"

"github.com/skycoin/skywire-utilities/pkg/netutil"
"github.com/skycoin/skywire/pkg/visor"
)

func init() {
if os.Getenv("SKYBIAN") == "true" {
RootCmd.AddCommand(pkCmd)
}
localIPs, err = netutil.DefaultNetworkInterfaceIPs()
if err != nil {
logger.WithError(err).Fatalln("Could not determine network interface IP address")
}
if len(localIPs) == 0 {
jdknives marked this conversation as resolved.
Show resolved Hide resolved
localIPs = append(localIPs, net.ParseIP("192.168.0.1"))
}
var s string
if idx := strings.LastIndex(localIPs[0].String(), "."); idx != -1 {
s = localIPs[0].String()[:idx]
}
pkCmd.Flags().StringVarP(&ipAddr, "ip", "i", s+".2:7998", "ip:port to query")
}
0pcom marked this conversation as resolved.
Show resolved Hide resolved

var pkCmd = &cobra.Command{
Use: "pk",
Short: "Fetch Hypervisor Public Key",
Run: func(_ *cobra.Command, _ []string) {
s, err := visor.FetchHvPk(ipAddr)
if err != nil {
logger.WithError(err).Fatalln("failed to fetch hypervisor public key")
}
fmt.Printf("%s\n", s)
},
}
15 changes: 9 additions & 6 deletions cmd/skywire-cli/commands/hv/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import (
)

var (
logger = logging.MustGetLogger("skywire-cli")
rpcAddr string
path string
pk string
url string
pkg bool
logger = logging.MustGetLogger("skywire-cli")
rpcAddr string
path string
pk string
url string
pkg bool
ipAddr string
localIPs []net.IP
err error
)

// RootCmd contains commands that interact with the skywire-visor
Expand Down
20 changes: 14 additions & 6 deletions cmd/skywire-cli/commands/visor/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package clivisor
import (
"fmt"
"log"
"net/http"
"os"
"unicode/utf8"

"github.com/spf13/cobra"

Expand All @@ -14,16 +14,19 @@ import (
var path string
var pkg bool
var web bool
var webPort string
var pk string

func init() {
RootCmd.AddCommand(pkCmd)
pkCmd.Flags().StringVarP(&path, "input", "i", "", "path of input config file.")
pkCmd.Flags().BoolVarP(&pkg, "pkg", "p", false, "read from /opt/skywire/skywire.json")
pkCmd.Flags().BoolVarP(&web, "http", "w", false, "format as http response")
pkCmd.Flags().BoolVarP(&web, "http", "w", false, "serve public key via http")
pkCmd.Flags().StringVarP(&webPort, "prt", "x", "7998", "serve public key via http")
RootCmd.AddCommand(hvpkCmd)
hvpkCmd.Flags().StringVarP(&path, "input", "i", "", "path of input config file.")
hvpkCmd.Flags().BoolVarP(&pkg, "pkg", "p", false, "read from /opt/skywire/skywire.json")
hvpkCmd.Flags().BoolVarP(&web, "http", "w", false, "format as http response")
hvpkCmd.Flags().BoolVarP(&web, "http", "w", false, "serve public key via http")
RootCmd.AddCommand(chvpkCmd)
RootCmd.AddCommand(summaryCmd)
RootCmd.AddCommand(buildInfoCmd)
Expand All @@ -48,10 +51,11 @@ var pkCmd = &cobra.Command{
if err != nil {
logger.Fatal("Failed to connect:", err)
}
pk = overview.PubKey.String()
if web {
rc := utf8.RuneCountInString(overview.PubKey.String())
header := fmt.Sprintf("HTTP/1.0 200 OK\r\nContent-Length: %d\r\n", rc)
fmt.Println(header)
http.HandleFunc("/", srvpk)
logger.Info("\nServing public key " + pk + " on port " + webPort)
http.ListenAndServe(":"+webPort, nil) //nolint
}
fmt.Println(overview.PubKey)
}
Expand Down Expand Up @@ -124,3 +128,7 @@ var buildInfoCmd = &cobra.Command{
}
},
}

func srvpk(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w, pk) //nolint
}
Loading