From c43be52f8db9b37062c69cc4e9e9ee491a8f34b3 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Sat, 24 Jul 2021 15:31:05 -0500 Subject: [PATCH 01/12] skybian defaults from --- cmd/apps/skychat/chat.go | 4 +- cmd/skywire-cli/commands/visor/gen-config.go | 38 ++++++++++++++---- cmd/skywire-visor/commands/root.go | 4 +- pkg/skyenv/values.go | 42 ++++++++++++++++---- pkg/visor/hypervisorconfig/config.go | 2 +- pkg/visor/visorconfig/config.go | 26 ++++++++++++ 6 files changed, 96 insertions(+), 20 deletions(-) diff --git a/cmd/apps/skychat/chat.go b/cmd/apps/skychat/chat.go index 1ff04fb7e..e1aba8fc2 100644 --- a/cmd/apps/skychat/chat.go +++ b/cmd/apps/skychat/chat.go @@ -4,19 +4,19 @@ skychat app for skywire visor package main import ( - "embed" "encoding/json" "flag" "fmt" - "io/fs" "net" "net/http" "os" "sync" "time" + "embed" "github.com/skycoin/dmsg/buildinfo" "github.com/skycoin/dmsg/cipher" + "io/fs" "github.com/skycoin/skywire/internal/netutil" "github.com/skycoin/skywire/pkg/app" diff --git a/cmd/skywire-cli/commands/visor/gen-config.go b/cmd/skywire-cli/commands/visor/gen-config.go index 265f60eb6..c378ee09c 100644 --- a/cmd/skywire-cli/commands/visor/gen-config.go +++ b/cmd/skywire-cli/commands/visor/gen-config.go @@ -26,17 +26,19 @@ var ( replace bool testEnv bool packageConfig bool + skybianConfig bool hypervisor bool hypervisorPKs string ) func init() { - genConfigCmd.Flags().Var(&sk, "sk", "if unspecified, a random key pair will be generated.") + genConfigCmd.Flags().Var(&sk, "sk", "if unspecified, a random key pair will be generated.\n") genConfigCmd.Flags().StringVarP(&output, "output", "o", "skywire-config.json", "path of output config file.") - genConfigCmd.Flags().BoolVarP(&replace, "replace", "r", false, "whether to allow rewrite of a file that already exists (this retains the keys).") - genConfigCmd.Flags().BoolVarP(&packageConfig, "package", "p", false, "use defaults for package-based installations") - genConfigCmd.Flags().BoolVarP(&testEnv, "testenv", "t", false, "whether to use production or test deployment service.") - genConfigCmd.Flags().BoolVar(&hypervisor, "is-hypervisor", false, "whether to generate config to run this visor as a hypervisor.") + genConfigCmd.Flags().BoolVarP(&replace, "replace", "r", false, "rewrite existing config (retains keys).") + genConfigCmd.Flags().BoolVarP(&packageConfig, "package", "p", false, "use defaults for package-based installations in /opt/skywire") + genConfigCmd.Flags().BoolVarP(&skybianConfig, "skybian", "s", false, "use defaults paths found in skybian\n writes config to /etc/skywire-config.json") + genConfigCmd.Flags().BoolVarP(&testEnv, "testenv", "t", false, "use test deployment service.") + genConfigCmd.Flags().BoolVarP(&hypervisor, "is-hypervisor", "i", false, "generate a hypervisor configuration.") genConfigCmd.Flags().StringVar(&hypervisorPKs, "hypervisor-pks", "", "public keys of hypervisors that should be added to this visor") } @@ -53,6 +55,25 @@ var genConfigCmd = &cobra.Command{ mLog := logging.NewMasterLogger() mLog.SetLevel(logrus.InfoLevel) + //Fail on -pst combination + if (packageConfig && skybianConfig) || (packageConfig && testEnv) || (skybianConfig && testEnv) { + logger.Fatal("Failed to create config: use of mutually exclusive flags") + } + + //set replace flag & output for package and skybian configs + if packageConfig { + replace = true + if hypervisor { + output = "/opt/skywire/skywire.json" + } else { + output = "/opt/skywire/skywire-visor.json" + } + } + if skybianConfig { + replace = true + output = "/etc/skywire-config.json" + } + // Read in old config (if any) and obtain old secret key. // Otherwise, we generate a new random secret key. var sk cipher.SecKey @@ -65,9 +86,11 @@ var genConfigCmd = &cobra.Command{ // Determine config type to generate. var genConf func(log *logging.MasterLogger, confPath string, sk *cipher.SecKey, hypervisor bool) (*visorconfig.V1, error) - // to be improved later + // default paths for different installations if packageConfig { genConf = visorconfig.MakePackageConfig + } else if skybianConfig { + genConf = visorconfig.MakeSkybianConfig } else if testEnv { genConf = visorconfig.MakeTestConfig } else { @@ -89,7 +112,6 @@ var genConfigCmd = &cobra.Command{ } conf.Hypervisors = append(conf.Hypervisors, cipher.PubKey(keyParsed)) } - } // Save config to file. @@ -116,7 +138,7 @@ func readOldConfig(log *logging.MasterLogger, confPath string, replace bool) (*v } if !replace { - logger.Fatal("Config file already exists. Specify the 'replace,r' flag to replace this.") + logger.Fatal("Config file already exists. Specify the 'replace, r' flag to replace this.") } conf, err := visorconfig.Parse(log, confPath, raw) diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index f85a4c74c..f03ff065c 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -2,10 +2,8 @@ package commands import ( "context" - "embed" "fmt" "io" - "io/fs" "io/ioutil" "net/http" _ "net/http/pprof" // nolint:gosec // https://golang.org/doc/diagnostics.html#profiling @@ -15,12 +13,14 @@ import ( "syscall" "time" + "embed" "github.com/pkg/profile" "github.com/skycoin/dmsg/buildinfo" "github.com/skycoin/dmsg/cmdutil" "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" "github.com/toqueteos/webbrowser" + "io/fs" "github.com/skycoin/skywire/pkg/restart" "github.com/skycoin/skywire/pkg/syslog" diff --git a/pkg/skyenv/values.go b/pkg/skyenv/values.go index 2e59b647b..11c293767 100644 --- a/pkg/skyenv/values.go +++ b/pkg/skyenv/values.go @@ -59,8 +59,9 @@ const ( const ( DmsgPtyPort uint16 = 22 - DefaultDmsgPtyCLINet = "unix" - DefaultDmsgPtyCLIAddr = "/tmp/dmsgpty.sock" + DefaultDmsgPtyCLINet = "unix" + DefaultDmsgPtyCLIAddr = "/tmp/dmsgpty.sock" + DefaultDmsgPtyWhitelist = DefaultSkywirePath + "/dmsgpty/whitelist.json" ) // Default STCP constants. @@ -103,13 +104,43 @@ const ( AppDiscUpdateInterval = time.Minute DefaultAppBinPath = DefaultSkywirePath + "/apps" DefaultLogLevel = "info" - PackageAppBinPath = PackageSkywirePath + "/apps" +) + +// Package defaults - installation path: /opt/skywire +const ( + PackageAppBinPath = PackageSkywirePath + "/apps" + PackageLocalPath = PackageSkywirePath + "/local" + PackageDmsgPtyWhiteList = PackageSkywirePath + "/dmsgpty/whitelist.json" + PackageDmsgPtyCLIAddr = PackageSkywirePath + "/dmsgpty/cli.sock" + PackageTpLogStore = PackageSkywirePath + "/transport_logs" + PackageDBPath = PackageSkywirePath + "/users.db" + PackageEnableTLS = false + PackageTLSKey = PackageSkywirePath + "/ssl/key.pem" + PackageTLSCert = PackageSkywirePath + "/ssl/cert.pem" +) + +// Default routing constants +const ( + DefaultTpLogStore = DefaultSkywirePath + "/transport_logs" +) + +// Skybian defaults - github.com/skycoin/skybian/ +//these should really be imported +const ( + SkybianAppBinPath = "/usr/bin/apps" + SkybianDmsgPtyWhiteList = "/var/skywire-visor/dsmgpty/whitelist.json" + SkybianDmsgPtyCLIAddr = "/run/skywire-visor/dmsgpty/cli.sock" + SkybianLocalPath = "/var/skywire-visor/apps" + SkybianTpLogStore = "/var/skywire-visor/transports" + SkybianEnableTLS = false + SkybianDBPath = "/var/skywire-visor/users.db" + SkybianTLSKey = "/var/skywire-visor/ssl/key.pem" + SkybianTLSCert = "/var/skywire-visor/ssl/cert.pem" ) // Default local constants const ( DefaultLocalPath = DefaultSkywirePath + "/local" - PackageLocalPath = PackageSkywirePath + "/local" ) // Default hypervisor constants @@ -119,9 +150,6 @@ const ( DefaultEnableTLS = false DefaultTLSKey = DefaultSkywirePath + "/ssl/key.pem" DefaultTLSCert = DefaultSkywirePath + "/ssl/cert.pem" - PackageEnableTLS = true - PackageTLSKey = PackageSkywirePath + "/ssl/key.pem" - PackageTLSCert = PackageSkywirePath + "/ssl/cert.pem" ) // MustPK unmarshals string PK to cipher.PubKey. It panics if unmarshaling fails. diff --git a/pkg/visor/hypervisorconfig/config.go b/pkg/visor/hypervisorconfig/config.go index 637e815a8..706f2a162 100644 --- a/pkg/visor/hypervisorconfig/config.go +++ b/pkg/visor/hypervisorconfig/config.go @@ -3,7 +3,6 @@ package hypervisorconfig import ( "encoding/hex" "encoding/json" - "io/fs" "log" "net/http" "os" @@ -11,6 +10,7 @@ import ( "time" "github.com/skycoin/dmsg/cipher" + "io/fs" "github.com/skycoin/skywire/pkg/skyenv" "github.com/skycoin/skywire/pkg/util/pathutil" diff --git a/pkg/visor/visorconfig/config.go b/pkg/visor/visorconfig/config.go index dbdb8ebe6..848216f31 100644 --- a/pkg/visor/visorconfig/config.go +++ b/pkg/visor/visorconfig/config.go @@ -166,6 +166,32 @@ func MakePackageConfig(log *logging.MasterLogger, confPath string, sk *cipher.Se conf.Hypervisor.EnableTLS = skyenv.PackageEnableTLS conf.Hypervisor.TLSKeyFile = skyenv.PackageTLSKey conf.Hypervisor.TLSCertFile = skyenv.PackageTLSCert + conf.Hypervisor.DBPath = skyenv.PackageDBPath + } + return conf, nil +} + +// MakeSkybianConfig acts like MakeDefaultConfig but uses default paths, etc. as found in skybian / produced by skyimager +func MakeSkybianConfig(log *logging.MasterLogger, confPath string, sk *cipher.SecKey, hypervisor bool) (*V1, error) { + conf, err := MakeDefaultConfig(log, confPath, sk, hypervisor) + if err != nil { + return nil, err + } + + conf.Dmsgpty = &V1Dmsgpty{ + Port: skyenv.DmsgPtyPort, + CLINet: skyenv.DefaultDmsgPtyCLINet, + CLIAddr: skyenv.SkybianDmsgPtyCLIAddr, + } + conf.LocalPath = skyenv.SkybianLocalPath + conf.Launcher.BinPath = skyenv.SkybianAppBinPath + + if conf.Hypervisor != nil { + conf.Hypervisor.EnableAuth = skyenv.DefaultEnableAuth + conf.Hypervisor.EnableTLS = skyenv.SkybianEnableTLS + conf.Hypervisor.TLSKeyFile = skyenv.SkybianTLSKey + conf.Hypervisor.TLSCertFile = skyenv.SkybianTLSCert + conf.Hypervisor.DBPath = skyenv.SkybianDBPath } return conf, nil } From c2dd8e05085894ce7dfefe03a5edb993d2d1a419 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Sun, 25 Jul 2021 08:41:36 -0500 Subject: [PATCH 02/12] fix make check errors --- cmd/apps/skychat/chat.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/apps/skychat/chat.go b/cmd/apps/skychat/chat.go index e1aba8fc2..eb2836207 100644 --- a/cmd/apps/skychat/chat.go +++ b/cmd/apps/skychat/chat.go @@ -14,9 +14,10 @@ import ( "time" "embed" + "io/fs" + "github.com/skycoin/dmsg/buildinfo" "github.com/skycoin/dmsg/cipher" - "io/fs" "github.com/skycoin/skywire/internal/netutil" "github.com/skycoin/skywire/pkg/app" From 5dc110fdaf986991accac68cd8aacfc0658891b4 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Sun, 25 Jul 2021 08:43:18 -0500 Subject: [PATCH 03/12] fix make check errors --- cmd/skywire-visor/commands/root.go | 3 ++- pkg/visor/hypervisorconfig/config.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index f03ff065c..a3dfc251e 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -14,13 +14,14 @@ import ( "time" "embed" + "io/fs" + "github.com/pkg/profile" "github.com/skycoin/dmsg/buildinfo" "github.com/skycoin/dmsg/cmdutil" "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" "github.com/toqueteos/webbrowser" - "io/fs" "github.com/skycoin/skywire/pkg/restart" "github.com/skycoin/skywire/pkg/syslog" diff --git a/pkg/visor/hypervisorconfig/config.go b/pkg/visor/hypervisorconfig/config.go index 706f2a162..1b165cc33 100644 --- a/pkg/visor/hypervisorconfig/config.go +++ b/pkg/visor/hypervisorconfig/config.go @@ -9,9 +9,10 @@ import ( "path/filepath" "time" - "github.com/skycoin/dmsg/cipher" "io/fs" + "github.com/skycoin/dmsg/cipher" + "github.com/skycoin/skywire/pkg/skyenv" "github.com/skycoin/skywire/pkg/util/pathutil" ) From 52c9d6e38c3aedc0900012274e40da5a372ec8e2 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Sun, 25 Jul 2021 08:58:43 -0500 Subject: [PATCH 04/12] update documentation --- cmd/skywire-cli/README.md | 43 ++++++++++++++++++++++++++----------- cmd/skywire-visor/README.md | 8 +++---- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/cmd/skywire-cli/README.md b/cmd/skywire-cli/README.md index 9eae0666e..644c3d2aa 100644 --- a/cmd/skywire-cli/README.md +++ b/cmd/skywire-cli/README.md @@ -334,12 +334,15 @@ Usage: Flags: -h, --help help for gen-config --hypervisor-pks string public keys of hypervisors that should be added to this visor - --is-hypervisor whether to generate config to run this visor as a hypervisor. + -i, --is-hypervisor generate a hypervisor configuration. -o, --output string path of output config file. (default "skywire-config.json") - -p, --package use defaults for package-based installations - -r, --replace whether to allow rewrite of a file that already exists (this retains the keys). - --sk cipher.SecKey if unspecified, a random key pair will be generated. (default 0000000000000000000000000000000000000000000000000000000000000000) - -t, --testenv whether to use production or test deployment service. + -p, --package use defaults for package-based installations in /opt/skywire + -r, --replace rewrite existing config (retains keys). + --sk cipher.SecKey if unspecified, a random key pair will be generated. + (default 0000000000000000000000000000000000000000000000000000000000000000) + -s, --skybian use defaults paths found in skybian + writes config to /etc/skywire-config.json + -t, --testenv use test deployment service. Global Flags: --rpc string RPC server address (default "localhost:3435") @@ -438,9 +441,27 @@ $ skywire-cli visor gen-config } ``` -The default configuration is for a visor only. To generate a configuration which provides the hypervisor web interface, the --is-hypervisor flag can be passed. +The default configuration is for a visor only. To generate a configuration which provides the hypervisor web interface, the -i or --is-hypervisor flag should be specified. ``` -$ skywire-cli visor gen-config --is-hypervisor +$ skywire-cli visor gen-config -i +``` + +##### Example hypervisor configuration for skybian +``` +$ skywire-cli visor gen-config -is +``` +##### Example visor configuration for skybian + +It is the typical arrangement to set a visor to use a remote hypervisor if a local instance is not started. + +Determine the hypervisor public key by running the following command on the remote machine + +``` +_pubkey=$(cat /opt/skywire/skywire.json | grep pk\") _pubkey=${_pubkey#*: } ; echo $_pubkey +``` +substitute the hypervisor public key in the following command: +``` +$ skywire-cli visor gen-config --hypervisor-pks -s ``` ##### Example hypervisor configuration for package based installation @@ -448,8 +469,7 @@ $ skywire-cli visor gen-config --is-hypervisor This assumes the skywire installation is at /opt/skywire with binaries and apps in their own subdirectories. ``` -$ cd /opt/skywire -$ skywire-cli visor gen-config --is-hypervisor -pro skywire.json +$ skywire-cli visor gen-config -ip [2021-06-24T09:09:39-05:00] INFO [visor:config]: Flushing config to file. config_version="v1.0.0" filepath="/opt/skywire/skywire.json" [2021-06-24T09:09:39-05:00] INFO [visor:config]: Flushing config to file. config_version="v1.0.0" filepath="/opt/skywire/skywire.json" [2021-06-24T09:09:39-05:00] INFO [skywire-cli]: Updated file '/opt/skywire/skywire.json' to: { @@ -572,13 +592,12 @@ When running a visor with or without a hypervisor on the same machine, it's wise Copy the `skywire.json` config file from the previous example to `skywire-visor.json`; then paste the public key from the above command output into the following command ``` -$ cd /opt/skywire -$ skywire-cli visor gen-config --hypervisor-pks -pro skywire-visor.json +$ skywire-cli visor gen-config --hypervisor-pks -p ``` The configuration is written (or rewritten) -The configuration files may be specified in corresponding systemd service files or init / startup scripts to start either a visor or hypervisor instance +The configuration files should be specified in corresponding systemd service files or init / startup scripts to start either a visor or hypervisor instance starting the hypervisor intance ``` diff --git a/cmd/skywire-visor/README.md b/cmd/skywire-visor/README.md index 13f27cb90..be4af355c 100644 --- a/cmd/skywire-visor/README.md +++ b/cmd/skywire-visor/README.md @@ -94,16 +94,14 @@ The configuration file is generated in the following way for a visor with local hypervisor: ``` -$ cd /opt/skywire -$ skywire-cli visor gen-config --is-hypervisor -pro skywire.json +$ skywire-cli visor gen-config -ip ``` for visor with remote hypervisor; first copy the existing configuration file to keep the same keys. ``` -$ cd /opt/skywire -# cp skywire.json skywire-visor.json -# skywire-cli visor gen-config --hypervisor-pks -pro skywire-visor.json +# cp /opt/skywire/skywire.json /opt/skywire/skywire-visor.json +# skywire-cli visor gen-config --hypervisor-pks -p ``` These two configuration files can be referenced in systemd service files or init scripts to start skywire with either a local or remote hypervisor. From 5a8b7f11bf8a699eb5c03bc2f4fc3a140bc8ea57 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Sun, 25 Jul 2021 09:04:12 -0500 Subject: [PATCH 05/12] update readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0d1a9db3c..7f06d6b0d 100644 --- a/README.md +++ b/README.md @@ -34,17 +34,17 @@ Skywire can be statically built. For instructions check [the docs](docs/static-b ### Expose hypervisorUI -In order to expose the hypervisor UI, generate a config file with `--is-hypervisor` flag: +In order to expose the hypervisor UI, generate a config file with `--is-hypervisor` or `-i` flag: ```bash -$ skywire-cli visor gen-config --is-hypervisor +$ skywire-cli visor gen-config -i ``` Docker container will create config automatically for you, should you want to run it manually, you can do: ```bash $ docker run --rm -v :/opt/skywire \ - skycoin/skywire:test skywire-cli gen-config --is-hypervisor + skycoin/skywire:test skywire-cli gen-config -i ``` After starting up the visor, the UI will be exposed by default on `localhost:8000`. From 4a2f994666caa3f4998cee36ae69e1e6e82e80d3 Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Wed, 4 Aug 2021 17:48:31 -0500 Subject: [PATCH 06/12] replace must be specified explicitly --- cmd/skywire-cli/commands/visor/gen-config.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmd/skywire-cli/commands/visor/gen-config.go b/cmd/skywire-cli/commands/visor/gen-config.go index c378ee09c..7d847b23f 100644 --- a/cmd/skywire-cli/commands/visor/gen-config.go +++ b/cmd/skywire-cli/commands/visor/gen-config.go @@ -60,9 +60,8 @@ var genConfigCmd = &cobra.Command{ logger.Fatal("Failed to create config: use of mutually exclusive flags") } - //set replace flag & output for package and skybian configs + //set output for package and skybian configs if packageConfig { - replace = true if hypervisor { output = "/opt/skywire/skywire.json" } else { @@ -70,7 +69,6 @@ var genConfigCmd = &cobra.Command{ } } if skybianConfig { - replace = true output = "/etc/skywire-config.json" } From e8c7669b18030c60e8c7cc24ca43d7bd506458d4 Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Wed, 4 Aug 2021 17:58:29 -0500 Subject: [PATCH 07/12] remove comment --- pkg/skyenv/values.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/skyenv/values.go b/pkg/skyenv/values.go index 11c293767..9a3c3beba 100644 --- a/pkg/skyenv/values.go +++ b/pkg/skyenv/values.go @@ -106,7 +106,7 @@ const ( DefaultLogLevel = "info" ) -// Package defaults - installation path: /opt/skywire +// Package defaults const ( PackageAppBinPath = PackageSkywirePath + "/apps" PackageLocalPath = PackageSkywirePath + "/local" @@ -124,8 +124,7 @@ const ( DefaultTpLogStore = DefaultSkywirePath + "/transport_logs" ) -// Skybian defaults - github.com/skycoin/skybian/ -//these should really be imported +// Skybian defaults const ( SkybianAppBinPath = "/usr/bin/apps" SkybianDmsgPtyWhiteList = "/var/skywire-visor/dsmgpty/whitelist.json" From ec71bdb295d0f3d5e16a169827645e19d90da09d Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Wed, 4 Aug 2021 18:13:35 -0500 Subject: [PATCH 08/12] revise documentation --- cmd/skywire-cli/README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/skywire-cli/README.md b/cmd/skywire-cli/README.md index 644c3d2aa..dadbbce8d 100644 --- a/cmd/skywire-cli/README.md +++ b/cmd/skywire-cli/README.md @@ -441,32 +441,32 @@ $ skywire-cli visor gen-config } ``` -The default configuration is for a visor only. To generate a configuration which provides the hypervisor web interface, the -i or --is-hypervisor flag should be specified. +The default configuration is for a visor only. To generate a configuration which provides the hypervisor web interface, the `-i` or `--is-hypervisor` flag should be specified. ``` $ skywire-cli visor gen-config -i ``` ##### Example hypervisor configuration for skybian ``` -$ skywire-cli visor gen-config -is +$ skywire-cli visor gen-config -irs ``` ##### Example visor configuration for skybian It is the typical arrangement to set a visor to use a remote hypervisor if a local instance is not started. -Determine the hypervisor public key by running the following command on the remote machine +Determine the hypervisor public key by running the following command on the machine running the hypervisor ``` -_pubkey=$(cat /opt/skywire/skywire.json | grep pk\") _pubkey=${_pubkey#*: } ; echo $_pubkey +$ skywire-cli visor pk ``` substitute the hypervisor public key in the following command: ``` -$ skywire-cli visor gen-config --hypervisor-pks -s +$ skywire-cli visor gen-config --hypervisor-pks -rs ``` ##### Example hypervisor configuration for package based installation -This assumes the skywire installation is at /opt/skywire with binaries and apps in their own subdirectories. +This assumes the skywire installation is at `/opt/skywire` with binaries and apps in their own subdirectories. ``` $ skywire-cli visor gen-config -ip @@ -581,10 +581,10 @@ The configuration is written (or rewritten) It is the typical arrangement to set a visor to use a remote hypervisor if a local instance is not started. -Determine the hypervisor public key by running the following command on the remote machine +Determine the hypervisor public key by running the following command on the machine running the hypervisor ``` -_pubkey=$(cat /opt/skywire/skywire.json | grep pk\") _pubkey=${_pubkey#*: } ; echo $_pubkey +$ skywire-cli visor pk ``` When running a visor with or without a hypervisor on the same machine, it's wise to keep the same keys for the other config file. @@ -592,7 +592,7 @@ When running a visor with or without a hypervisor on the same machine, it's wise Copy the `skywire.json` config file from the previous example to `skywire-visor.json`; then paste the public key from the above command output into the following command ``` -$ skywire-cli visor gen-config --hypervisor-pks -p +$ skywire-cli visor gen-config --hypervisor-pks -pr ``` The configuration is written (or rewritten) From b019c377fbe44d4ef85c2b2ecf21061040d0e218 Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Wed, 4 Aug 2021 18:25:47 -0500 Subject: [PATCH 09/12] remove dmsgpty whitelist --- pkg/skyenv/values.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/skyenv/values.go b/pkg/skyenv/values.go index 9a3c3beba..80cced696 100644 --- a/pkg/skyenv/values.go +++ b/pkg/skyenv/values.go @@ -61,7 +61,6 @@ const ( DefaultDmsgPtyCLINet = "unix" DefaultDmsgPtyCLIAddr = "/tmp/dmsgpty.sock" - DefaultDmsgPtyWhitelist = DefaultSkywirePath + "/dmsgpty/whitelist.json" ) // Default STCP constants. @@ -92,7 +91,7 @@ const ( // RPC constants. const ( - DefaultRPCAddr = "localhost:3435" + DefaultRPCAddr = "localhost:3435" DefaultDmsgPtyCLIAddr = "/tmp/dmsgpty.sock" DefaultRPCTimeout = 20 * time.Second TransportRPCTimeout = 1 * time.Minute UpdateRPCTimeout = 6 * time.Hour // update requires huge timeout From efc4b09536a023dca82ff707221b25e2e9d665b8 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Thu, 5 Aug 2021 18:50:28 -0500 Subject: [PATCH 10/12] fix accidental paste in previous edit --- pkg/skyenv/values.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/skyenv/values.go b/pkg/skyenv/values.go index 80cced696..d875b79e6 100644 --- a/pkg/skyenv/values.go +++ b/pkg/skyenv/values.go @@ -91,7 +91,7 @@ const ( // RPC constants. const ( - DefaultRPCAddr = "localhost:3435" DefaultDmsgPtyCLIAddr = "/tmp/dmsgpty.sock" + DefaultRPCAddr = "localhost:3435" DefaultRPCTimeout = 20 * time.Second TransportRPCTimeout = 1 * time.Minute UpdateRPCTimeout = 6 * time.Hour // update requires huge timeout From a4f6875fa37e3abb025faa0c261ec70eaebb4d31 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Fri, 6 Aug 2021 09:26:34 -0500 Subject: [PATCH 11/12] fix goimports error --- cmd/apps/skychat/chat.go | 1 - cmd/skywire-visor/commands/root.go | 1 - pkg/skyenv/values.go | 4 ++-- pkg/visor/hypervisorconfig/config.go | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/apps/skychat/chat.go b/cmd/apps/skychat/chat.go index eb2836207..f05efb9fb 100644 --- a/cmd/apps/skychat/chat.go +++ b/cmd/apps/skychat/chat.go @@ -15,7 +15,6 @@ import ( "embed" "io/fs" - "github.com/skycoin/dmsg/buildinfo" "github.com/skycoin/dmsg/cipher" diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index a3dfc251e..ec8339b76 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -15,7 +15,6 @@ import ( "embed" "io/fs" - "github.com/pkg/profile" "github.com/skycoin/dmsg/buildinfo" "github.com/skycoin/dmsg/cmdutil" diff --git a/pkg/skyenv/values.go b/pkg/skyenv/values.go index d875b79e6..ccc9a2f35 100644 --- a/pkg/skyenv/values.go +++ b/pkg/skyenv/values.go @@ -59,8 +59,8 @@ const ( const ( DmsgPtyPort uint16 = 22 - DefaultDmsgPtyCLINet = "unix" - DefaultDmsgPtyCLIAddr = "/tmp/dmsgpty.sock" + DefaultDmsgPtyCLINet = "unix" + DefaultDmsgPtyCLIAddr = "/tmp/dmsgpty.sock" ) // Default STCP constants. diff --git a/pkg/visor/hypervisorconfig/config.go b/pkg/visor/hypervisorconfig/config.go index 1b165cc33..5fdd5ac99 100644 --- a/pkg/visor/hypervisorconfig/config.go +++ b/pkg/visor/hypervisorconfig/config.go @@ -10,7 +10,6 @@ import ( "time" "io/fs" - "github.com/skycoin/dmsg/cipher" "github.com/skycoin/skywire/pkg/skyenv" From 588ad2d0bd299f9e3e6f4c52d3367e1fb1b01dbe Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Fri, 6 Aug 2021 16:08:32 -0500 Subject: [PATCH 12/12] fix errors caused by make format --- cmd/apps/skychat/chat.go | 1 + cmd/skywire-visor/commands/root.go | 4 ++-- pkg/visor/hypervisorconfig/config.go | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/apps/skychat/chat.go b/cmd/apps/skychat/chat.go index f05efb9fb..eb2836207 100644 --- a/cmd/apps/skychat/chat.go +++ b/cmd/apps/skychat/chat.go @@ -15,6 +15,7 @@ import ( "embed" "io/fs" + "github.com/skycoin/dmsg/buildinfo" "github.com/skycoin/dmsg/cipher" diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index ec8339b76..f85a4c74c 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -2,8 +2,10 @@ package commands import ( "context" + "embed" "fmt" "io" + "io/fs" "io/ioutil" "net/http" _ "net/http/pprof" // nolint:gosec // https://golang.org/doc/diagnostics.html#profiling @@ -13,8 +15,6 @@ import ( "syscall" "time" - "embed" - "io/fs" "github.com/pkg/profile" "github.com/skycoin/dmsg/buildinfo" "github.com/skycoin/dmsg/cmdutil" diff --git a/pkg/visor/hypervisorconfig/config.go b/pkg/visor/hypervisorconfig/config.go index 5fdd5ac99..1b165cc33 100644 --- a/pkg/visor/hypervisorconfig/config.go +++ b/pkg/visor/hypervisorconfig/config.go @@ -10,6 +10,7 @@ import ( "time" "io/fs" + "github.com/skycoin/dmsg/cipher" "github.com/skycoin/skywire/pkg/skyenv"