From 81de42dbe89434f5e8fde5171ab843b91ab43cd9 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Wed, 25 Sep 2024 14:49:26 -0500 Subject: [PATCH] fix services-config.json file path for skywire cli config gen ; update conf template --- Makefile | 2 + cmd/skywire-cli/commands/config/gen.go | 412 ++++++++++++++---------- cmd/skywire-cli/commands/config/root.go | 2 + 3 files changed, 240 insertions(+), 176 deletions(-) diff --git a/Makefile b/Makefile index 42830c67cc..b23cd04b03 100644 --- a/Makefile +++ b/Makefile @@ -129,6 +129,8 @@ build-merged-windows: clean-windows install-system-linux: build ## Install apps and binaries over those provided by the linux package - linux package must be installed first! sudo echo "sudo cache" sudo install -Dm755 $(BUILD_PATH)skywire /opt/skywire/bin/ + sudo install -Dm644 services-config.json /opt/skywire/ + sudo install -Dm644 dmsghttp-config.json /opt/skywire/ install-generate: ## Installs required execs for go generate. diff --git a/cmd/skywire-cli/commands/config/gen.go b/cmd/skywire-cli/commands/config/gen.go index c1967b7915..371430cf00 100644 --- a/cmd/skywire-cli/commands/config/gen.go +++ b/cmd/skywire-cli/commands/config/gen.go @@ -71,7 +71,7 @@ func init() { genConfigCmd.Flags().SortFlags = false RootCmd.AddCommand(genConfigCmd, genKeysCmd, checkPKCmd) - genConfigCmd.Flags().StringVarP(&serviceConfURL, "url", "a", scriptExecArray(fmt.Sprintf("${SVCCONFADDR[@]-%s}", serviceConfURL)), "services conf url\n\r") + genConfigCmd.Flags().StringVarP(&serviceConfURL, "url", "a", scriptExecArray(fmt.Sprintf("${SVCCONFADDR[@]-%s}", serviceConfURL)), "services conf url\033[0m\n\r") gHiddenFlags = append(gHiddenFlags, "url") genConfigCmd.Flags().StringVar(&logLevel, "loglvl", scriptExecString("${LOGLVL:-info}"), "level of logging in config\033[0m") gHiddenFlags = append(gHiddenFlags, "loglvl") @@ -91,39 +91,39 @@ func init() { genConfigCmd.Flags().StringVarP(&disableApps, "disableapps", "g", "", "comma separated list of apps to disable\033[0m") gHiddenFlags = append(gHiddenFlags, "disableapps") genConfigCmd.Flags().BoolVarP(&isHypervisor, "ishv", "i", scriptExecBool("${ISHYPERVISOR:-false}"), "local hypervisor configuration\033[0m") - msg = "list of public keys to add as hypervisor" + msg = "list of public keys to add as hypervisor\033[0m" if scriptExecArray("${HYPERVISORPKS[@]}") != "" { msg += "\n\r" } genConfigCmd.Flags().StringVarP(&hypervisorPKs, "hvpks", "j", scriptExecArray("${HYPERVISORPKS[@]}"), msg) - msg = "add dmsgpty whitelist PKs" + msg = "add dmsgpty whitelist PKs\033[0m" if scriptExecArray("${DMSGPTYPKS[@]}") != "" { msg += "\n\r" } genConfigCmd.Flags().StringVar(&dmsgptyWlPKs, "dmsgpty", scriptExecArray("${DMSGPTYPKS[@]}"), msg) - msg = "add survey whitelist PKs" + msg = "add survey whitelist PKs\033[0m" if scriptExecArray("${SURVEYPKS[@]}") != "" { msg += "\n\r" } genConfigCmd.Flags().StringVar(&surveyWhitelistPKs, "survey", scriptExecArray("${SURVEYPKS[@]}"), msg) gHiddenFlags = append(gHiddenFlags, "survey") - msg = "add route setup node PKs" + msg = "add route setup node PKs\033[0m" if scriptExecArray("${ROUTESETUPPKS[@]}") != "" { msg += "\n\r" } genConfigCmd.Flags().StringVar(&routeSetupNodes, "routesetup", scriptExecArray("${ROUTESETUPPKS[@]}"), msg) gHiddenFlags = append(gHiddenFlags, "routesetup") - msg = "add transport setup node PKs" - if scriptExecArray("${ROUTESETUPPKS[@]}") != "" { + msg = "add transport setup node PKs\033[0m" + if scriptExecArray("${TPSETUPPKS[@]}") != "" { msg += "\n\r" } - genConfigCmd.Flags().StringVar(&transportSetupPKs, "tpsetup", scriptExecArray("${ROUTESETUPPKS[@]}"), msg) + genConfigCmd.Flags().StringVar(&transportSetupPKs, "tpsetup", scriptExecArray("${TPSETUPPKS[@]}"), msg) gHiddenFlags = append(gHiddenFlags, "tpsetup") genConfigCmd.Flags().StringVarP(&selectedOS, "os", "k", visorconfig.OS, "(linux / mac / win) paths\033[0m") gHiddenFlags = append(gHiddenFlags, "os") - genConfigCmd.Flags().BoolVarP(&isDisplayNodeIP, "publicip", "l", scriptExecBool("${DISPLAYNODEIP:-false}"), "allow display node ip in services\033[0m") + genConfigCmd.Flags().BoolVarP(&isDisplayNodeIP, "publicip", "l", scriptExecBool("${DISPLAYNODEIP:-false}"), "display visor ip in service discovery\033[0m") gHiddenFlags = append(gHiddenFlags, "publicip") genConfigCmd.Flags().BoolVarP(&addExampleApps, "example-apps", "m", false, "add example apps to the config\033[0m") gHiddenFlags = append(gHiddenFlags, "example-apps") @@ -131,7 +131,7 @@ func init() { gHiddenFlags = append(gHiddenFlags, "stdout") genConfigCmd.Flags().BoolVarP(&isSquash, "squash", "N", false, "output config without whitespace or newlines\033[0m") gHiddenFlags = append(gHiddenFlags, "squash") - genConfigCmd.Flags().BoolVarP(&isEnvs, "envs", "q", false, "show the environmental variable settings") + genConfigCmd.Flags().BoolVarP(&isEnvs, "envs", "q", false, "show the environmental variable settings\033[0m") msg = "output config" if scriptExecString("${OUTPUT}") == "" { msg += ": " + visorconfig.ConfigName @@ -152,11 +152,11 @@ func init() { genConfigCmd.Flags().BoolVarP(&isUsrEnv, "user", "u", scriptExecBool("${USRENV:-false}"), "use paths for user space: "+homepath+"\033[0m") } - genConfigCmd.Flags().BoolVarP(&isRegen, "regen", "r", false, "re-generate existing config & retain keys") + genConfigCmd.Flags().BoolVarP(&isRegen, "regen", "r", false, "re-generate existing config & retain keys\033[0m") if scriptExecString("${SK:-0000000000000000000000000000000000000000000000000000000000000000}") != "0000000000000000000000000000000000000000000000000000000000000000" { sk.Set(scriptExecString("${SK:-0000000000000000000000000000000000000000000000000000000000000000}")) //nolint } - genConfigCmd.Flags().VarP(&sk, "sk", "s", "a random key is generated if unspecified\n\r") + genConfigCmd.Flags().VarP(&sk, "sk", "s", "a random key is generated if unspecified\033[0m\n\r") gHiddenFlags = append(gHiddenFlags, "sk") genConfigCmd.Flags().BoolVarP(&isTestEnv, "testenv", "t", scriptExecBool("${TESTENV:-false}"), "use test deployment\033[0m") gHiddenFlags = append(gHiddenFlags, "testenv") @@ -174,44 +174,44 @@ func init() { gHiddenFlags = append(gHiddenFlags, "stcpr") genConfigCmd.Flags().IntVar(&sudphPort, "sudph", scriptExecInt("${SUDPHPORT:-0}"), "set udp transport listening port - 0 for random\033[0m") gHiddenFlags = append(gHiddenFlags, "sudph") - genConfigCmd.Flags().StringVar(&binPath, "binpath", scriptExecString("${BINPATH}"), "set bin_path for visor vative apps\033[0m") + genConfigCmd.Flags().StringVar(&binPath, "binpath", scriptExecString("${BINPATH}"), "set bin_path for visor native apps\033[0m") gHiddenFlags = append(gHiddenFlags, "binpath") - genConfigCmd.Flags().StringVar(&addSkysocksClientSrv, "proxyclientpk", scriptExecString("${PROXYCLIENTPK}"), "set server public key for proxy client") + genConfigCmd.Flags().StringVar(&addSkysocksClientSrv, "proxyclientpk", scriptExecString("${PROXYCLIENTPK}"), "set server public key for proxy client\033[0m") gHiddenFlags = append(gHiddenFlags, "proxyclientpk") - genConfigCmd.Flags().BoolVar(&enableProxyClientAutostart, "startproxyclient", scriptExecBool("${STARTPROXYCLIENT:-false}"), "autostart proxy client") + genConfigCmd.Flags().BoolVar(&enableProxyClientAutostart, "startproxyclient", scriptExecBool("${STARTPROXYCLIENT:-false}"), "autostart proxy client\033[0m") gHiddenFlags = append(gHiddenFlags, "startproxyclient") - genConfigCmd.Flags().BoolVar(&disableProxyServerAutostart, "noproxyserver", scriptExecBool("${NOPROXYSERVER:-false}"), "disable autostart of proxy server") + genConfigCmd.Flags().BoolVar(&disableProxyServerAutostart, "noproxyserver", scriptExecBool("${NOPROXYSERVER:-false}"), "disable autostart of proxy server\033[0m") gHiddenFlags = append(gHiddenFlags, "noproxyserver") - genConfigCmd.Flags().StringVar(&proxyServerPass, "proxyserverpass", scriptExecString("${PROXYSEVERPASS}"), "set proxy server password") + genConfigCmd.Flags().StringVar(&proxyServerPass, "proxyserverpass", scriptExecString("${PROXYSEVERPASS}"), "set proxy server password\033[0m") gHiddenFlags = append(gHiddenFlags, "proxyserverpass") - genConfigCmd.Flags().StringVar(&proxyClientPass, "proxyclientpass", scriptExecString("${PROXYCLIENTPASS}"), "password for the proxy client to access the server (if needed)") + genConfigCmd.Flags().StringVar(&proxyClientPass, "proxyclientpass", scriptExecString("${PROXYCLIENTPASS}"), "password for the proxy client to access the server (if needed)\033[0m") gHiddenFlags = append(gHiddenFlags, "proxyclientpass") // TODO: Password for accessing proxy client // TODO: VPN client killswitch should be handled as boolean, not string - genConfigCmd.Flags().StringVar(&setVPNClientKillswitch, "killsw", scriptExecString("${VPNKS}"), "vpn client killswitch") + genConfigCmd.Flags().StringVar(&setVPNClientKillswitch, "killsw", scriptExecString("${VPNKS}"), "vpn client killswitch\033[0m") gHiddenFlags = append(gHiddenFlags, "killsw") - genConfigCmd.Flags().StringVar(&addVPNClientSrv, "addvpn", scriptExecString("${ADDVPNPK}"), "set vpn server public key for vpn client") + genConfigCmd.Flags().StringVar(&addVPNClientSrv, "addvpn", scriptExecString("${ADDVPNPK}"), "set vpn server public key for vpn client\033[0m") gHiddenFlags = append(gHiddenFlags, "addvpn") - genConfigCmd.Flags().StringVar(&addVPNClientPasscode, "vpnpass", scriptExecString("${VPNCLIENTPASS}"), "password for vpn client to access the vpn server (if needed)") + genConfigCmd.Flags().StringVar(&addVPNClientPasscode, "vpnpass", scriptExecString("${VPNCLIENTPASS}"), "password for vpn client to access the vpn server (if needed)\033[0m") gHiddenFlags = append(gHiddenFlags, "vpnpass") - genConfigCmd.Flags().StringVar(&addVPNServerPasscode, "vpnserverpass", scriptExecString("${VPNSEVERPASS}"), "set password to the vpn server") + genConfigCmd.Flags().StringVar(&addVPNServerPasscode, "vpnserverpass", scriptExecString("${VPNSEVERPASS}"), "set password to the vpn server\033[0m") gHiddenFlags = append(gHiddenFlags, "vpnserverpass") - genConfigCmd.Flags().StringVar(&setVPNServerSecure, "secure", scriptExecString("${VPNSEVERSECURE}"), "change secure mode status of vpn server") + genConfigCmd.Flags().StringVar(&setVPNServerSecure, "secure", scriptExecString("${VPNSEVERSECURE}"), "change secure mode status of vpn server\033[0m") gHiddenFlags = append(gHiddenFlags, "secure") - genConfigCmd.Flags().StringVar(&setVPNServerNetIfc, "netifc", scriptExecString("${VPNSEVERNETIFC}"), "VPN Server network interface (detected: "+getInterfaceNames()+")") + genConfigCmd.Flags().StringVar(&setVPNServerNetIfc, "netifc", scriptExecString("${VPNSEVERNETIFC}"), "VPN Server network interface (detected: "+getInterfaceNames()+")\033[0m") gHiddenFlags = append(gHiddenFlags, "netifc") - genConfigCmd.Flags().BoolVar(&noFetch, "nofetch", false, "do not fetch the services from the service conf url") + genConfigCmd.Flags().BoolVar(&noFetch, "nofetch", false, "do not fetch the services from the service conf url\033[0m") gHiddenFlags = append(gHiddenFlags, "nofetch") //TODO: visorconfig.SvcConfName genConfigCmd.Flags().StringVarP(&configServicePath, "svcconf", "S", scriptExecString(fmt.Sprintf("${SVCCONF:-%s}", visorconfig.SERVICESName)), "fallback service configuration file\033[0m") gHiddenFlags = append(gHiddenFlags, "svcconf") - genConfigCmd.Flags().BoolVar(&noDefaults, "nodefaults", false, "do not use hardcoded defaults for production / test services") + genConfigCmd.Flags().BoolVar(&noDefaults, "nodefaults", false, "do not use hardcoded defaults for services\033[0m") gHiddenFlags = append(gHiddenFlags, "nodefaults") - genConfigCmd.Flags().BoolVar(&snConfig, "sn", false, "generate config for route setup-node") + genConfigCmd.Flags().BoolVar(&snConfig, "sn", false, "generate config for route setup node\033[0m") gHiddenFlags = append(gHiddenFlags, "sn") genConfigCmd.Flags().StringVar(&ver, "version", scriptExecString("${VERSION}"), "custom version testing override\033[0m") gHiddenFlags = append(gHiddenFlags, "version") - genConfigCmd.Flags().BoolVar(&isAll, "all", false, "show all flags") + genConfigCmd.Flags().BoolVar(&isAll, "all", false, "show all flags\033[0m") //show all flags on help if os.Getenv("UNHIDEFLAGS") != "1" { @@ -378,12 +378,14 @@ var genConfigCmd = &cobra.Command{ } } } + if isPkgEnv && configServicePath == visorconfig.SERVICESName { + configServicePath = visorconfig.SkywirePath + "/" + visorconfig.SERVICESName + } }, Run: func(_ *cobra.Command, _ []string) { log := logger wasStdout := isStdout - var body []byte var err error // enable errors from service conf fetch from the combination of these flags if isStdout && isHide { @@ -397,94 +399,75 @@ var genConfigCmd = &cobra.Command{ } if !noFetch && !isDmsgHTTP { - // create an http client to fetch the services - client := http.Client{ - Timeout: time.Second * 15, // Timeout after 15 seconds - } + client := http.Client{Timeout: 15 * time.Second} if serviceConfURL == "" { serviceConfURL = "http://" } if !isStdout { log.Infof("Fetching service endpoints from %s", serviceConfURL) } - // Make the HTTP GET request - res, err := client.Get(fmt.Sprint(serviceConfURL)) + res, err := client.Get(serviceConfURL) if err != nil { - //silence errors for stdout if !isStdout { - log.WithError(err).Error("Failed to fetch servers\n") + log.WithError(err).Error("Failed to fetch servers") log.Warn("Falling back on services-config.json") } - body, err = os.ReadFile(configServicePath) + body, err := os.ReadFile(configServicePath) if err != nil { if !isStdout { - log.WithError(err).Error("Failed to read config service from file\n") + log.WithError(err).Error("Failed to read config service from file") log.Warn("Falling back on hardcoded servers") } - } else { - //fill in services struct with the response - err = json.Unmarshal(body, &servicesConfig) - if err != nil { - if !isStdout { - log.WithError(err).Error("Failed to unmarshal services-config.json file\n") - } - } else { - services = servicesConfig.Prod - if isTestEnv { - services = servicesConfig.Test - } + return + } + if err := json.Unmarshal(body, &servicesConfig); err != nil { + if !isStdout { + log.WithError(err).Error("Failed to unmarshal services-config.json file") + log.Warn("Falling back on hardcoded servers") } - + return } - } else { - //nil error on service conf fetch - if res.Body != nil { - defer res.Body.Close() //nolint + services = servicesConfig.Prod + if isTestEnv { + services = servicesConfig.Test } - body, err = io.ReadAll(res.Body) + } else { + defer res.Body.Close() //nolint + body, err := io.ReadAll(res.Body) if err != nil { - log.WithError(err).Error("Failed to read http response\n") + log.WithError(err).Error("Failed to read HTTP response") + return } - //fill in services struct with the response - err = json.Unmarshal(body, &services) - if err != nil { + if err := json.Unmarshal(body, &services); err != nil { if !isStdout { - log.WithError(err).Error("Failed to unmarshal json response to services struct\n") + log.WithError(err).Error("Failed to unmarshal JSON response to services struct") log.Warn("Falling back on hardcoded servers") } - } else { - if !isStdout { - log.Infof("Fetched service endpoints from '%s'", serviceConfURL) - } + return + } else if !isStdout { + log.Infof("Fetched service endpoints from '%s'", serviceConfURL) } } } else { - if isPkgEnv { - if configServicePath == visorconfig.SERVICESName { - configServicePath = visorconfig.SkywirePath + "/" + visorconfig.SERVICESName - } - } - body, err = os.ReadFile(configServicePath) + body, err := os.ReadFile(configServicePath) if err != nil { if !isStdout { - log.WithError(err).Error("Failed to read config service from file\n") + log.WithError(err).Error("Failed to read config service from file") log.Warn("Falling back on hardcoded servers") } - } else { - //fill in services struct with the response - err = json.Unmarshal(body, &servicesConfig) - if err != nil { - if !isStdout { - log.WithError(err).Error("Failed to unmarshal json response to services struct\n") - log.Warn("Falling back on hardcoded servers") - } - } - services = servicesConfig.Prod - if isTestEnv { - services = servicesConfig.Test + return + } + if err := json.Unmarshal(body, &servicesConfig); err != nil { + if !isStdout { + log.WithError(err).Error("Failed to unmarshal services-config.json file") + log.Warn("Falling back on hardcoded servers") } + return + } + services = servicesConfig.Prod + if isTestEnv { + services = servicesConfig.Test } - } // reset the state of isStdout @@ -1030,69 +1013,95 @@ const envfileLinux = `# # Uncomment to change default value ######################################################################### -#-- Other Visors will automatically establish transports to this visor -# requires port forwarding or public ip -#VISORISPUBLIC=true +### Installation path ################################################### -#-- Autostart vpn server for this visor -#VPNSERVER=true +#-- Default config paths for the installer or package (system paths) +#PKGENV=true + +#-- Default config paths for the current userspace +#USRENV=true + +#-- fallback service conf path +#SVCCONF="services-config.json" + +#-- dmsghttp config path +#DMSGCONF="dmsghttp-config.json" + +#-- Output path of the config file +#OUTPUT='./skywire-config.json' + +#-- Set app bin_path +#BINPATH='./apps' + +### Deployment ########################################################## + +#-- Set custom service conf URLs +#SVCCONFADDR=('') #-- Use test deployment #TESTENV=true +#-- Use dmsghttp to connect to the production deployment ; overrides BESTPROTO=true +#DMSGHTTP=true + +#-- Number of dmsg serverts to connect to (0 unlimits) +#MINDMSGSESS=8 + #-- Automatically determine the best protocol (dmsg or http) # based on location to connect to the deployment servers #BESTPROTO=true -#-- Set custom service conf URLs -#SVCCONFADDR=('') +### Transports ########################################################## -#-- fallback service conf path -#SVCCONF="services-config.json" +#-- Other Visors will automatically establish transports to this visor +# requires port forwarding or public ip +#VISORISPUBLIC=true -#-- Set visor runtime log level. -# Default is info ; uncomment for debug logging -#LOGLVL=debug +#-- Disable auto-transports to public visors from this visor +#DISABLEPUBLICAUTOCONN=true -#-- dmsghttp config path -#DMSGCONF="dmsghttp-config.json" +#-- Add transport setup public keys +#TPSETUPPKS('') -#-- Use dmsghttp to connect to the production deployment -#DMSGHTTP=true +### Ports ############################################################### -#-- Number of dmsg serverts to connect to (0 unlimits) -#MINDMSGSESS=8 +#- set port for UDP connections / SUDPH transports +#SUDPHPORT=0 -#-- Start the hypervisor interface for this visor -#ISHYPERVISOR=true +#- set port for TCP connections / STCPR or STCP transports +#STCPRPORT=0 -#-- Output path of the config file -#OUTPUT='./skywire-config.json' +### Routing ############################################################# -#-- Display the node ip in the service discovery -# for any public services this visor is running -#DISPLAYNODEIP=true +#-- Add route setup-node public keys +#ROUTESETUPPKS('') + +### Remote Access ####################################################### #-- Set remote hypervisor public keys #HYPERVISORPKS=('') -#-- Default config paths for the installer or package (system paths) -#PKGENV=true +#-- Grant access to pseudoterminal (pty) for public keys +#DMSGPTYPKS('') -#-- Default config paths for the current userspace -#USRENV=true +### Survey Access ####################################################### -#-- Set secret key -#SK='' +#-- Grant access for survey collection to these public keys +#SURVEYPKS('') -#-- Disable auto-transports to public visors -#DISABLEPUBLICAUTOCONN=true +### Hypervisor UI ####################################################### -#-- Custom config version override -#VERSION='' +#-- Start the hypervisor interface for this visor +#ISHYPERVISOR=true -#-- Set app bin_path -#BINPATH='./apps' +### Apps ################################################################ + +#-- Display the node ip in the service discovery +# for any public services this visor is running +#DISPLAYNODEIP=true + +#-- Autostart vpn server for this visor +#VPNSERVER=true #-- Set server public key for proxy client to connect to #PROXYCLIENTPK='' @@ -1106,7 +1115,8 @@ const envfileLinux = `# #-- Set a password for the proxy server #PROXYSEVERPASS='' -#-- Password for the proxy client to access the server (if password is set for the server) +#-- Password for the proxy client to access the server +# (if password is set for the server) #PROXYCLIENTPASS='' #-- Set VPN client killswitch @@ -1115,7 +1125,8 @@ const envfileLinux = `# #-- Set vpn server public key for the vpn client to use #ADDVPNPK='' -#-- Password for vpn client to access the server (if password is set forthe server) +#-- Password for vpn client to access the server +# (if password is set for the server) #VPNCLIENTPASS='' #-- Set password to the vpn server @@ -1124,13 +1135,25 @@ const envfileLinux = `# #-- Change secure mode status of vpn server #VPNSEVERSECURE='' -#-- Set VPN Server network interface +#-- Set VPN Server network interface - i.e. eth0 #VPNSEVERNETIFC='' +### Miscellaneous ####################################################### + +#-- Set secret key +#SK='' + +#-- Custom config version override +#VERSION='' + +#-- Set visor runtime log level. +# Default is info ; uncomment for debug logging +#LOGLVL=debug ` + const envfileWindows = `# -# C:\ProgramData\skywire.ps1 +# C:\ProgramData\skywire.conf # ######################################################################### # SKYWIRE CONFIG TEMPLATE @@ -1138,79 +1161,104 @@ const envfileWindows = `# # Uncomment to change default value ######################################################################### -#-- Other Visors will automatically establish transports to this visor -# requires port forwarding or public ip -#$VISORISPUBLIC=true +### Installation path ################################################### -#-- Autostart vpn server for this visor -#$VPNSERVER=true +#-- Default config paths for the installer or package (system paths) +#$PKGENV=$true + +#-- Default config paths for the current userspace +#$USRENV=$true + +#-- fallback service conf path +#$SVCCONF="services-config.json" + +#-- dmsghttp config path +#$DMSGCONF="dmsghttp-config.json" + +#-- Output path of the config file +#$OUTPUT='C:\\ProgramData\\skywire-config.json' + +#-- Set app bin_path +#$BINPATH='C:\\ProgramData\\apps' + +### Deployment ########################################################## + +#-- Set custom service conf URLs +#$SVCCONFADDR=@('') #-- Use test deployment -#$TESTENV=true +#$TESTENV=$true + +#-- Use dmsghttp to connect to the production deployment ; overrides BESTPROTO=$true +#$DMSGHTTP=$true + +#-- Number of dmsg servers to connect to (0 unlimits) +#$MINDMSGSESS=8 #-- Automatically determine the best protocol (dmsg or http) # based on location to connect to the deployment servers -#$BESTPROTO=true +#$BESTPROTO=$true -#-- Set custom service conf URLs -#$SVCCONFADDR= @('') +### Transports ########################################################## -#-- fallback service conf path -#$SVCCONF='services-config.json' +#-- Other Visors will automatically establish transports to this visor +# requires port forwarding or public IP +#$VISORISPUBLIC=$true -#-- Set visor runtime log level. -# Default is info ; uncomment for debug logging -#$LOGLVL=debug +#-- Disable auto-transports to public visors from this visor +#$DISABLEPUBLICAUTOCONN=$true -#-- dmsghttp config path -#$DMSGCONF='dmsghttp-config.json' +#-- Add transport setup public keys +#$TPSETUPPKS=@('') -#-- Use dmsghttp to connect to the production deployment -#$DMSGHTTP=true +### Ports ############################################################### -#-- Number of dmsg serverts to connect to (0 unlimits) -#$MINDMSGSESS=8 +#- set port for UDP connections / SUDPH transports +#$SUDPHPORT=0 -#-- Start the hypervisor interface for this visor -#$ISHYPERVISOR=true +#- set port for TCP connections / STCPR or STCP transports +#$STCPRPORT=0 -#-- Output path of the config file -#$OUTPUT='./skywire-config.json' +### Routing ############################################################# -#-- Display the node ip in the service discovery -# for any public services this visor is running -#$DISPLAYNODEIP=true +#-- Add route setup-node public keys +#$ROUTESETUPPKS=@('') + +### Remote Access ####################################################### #-- Set remote hypervisor public keys -#$HYPERVISORPKS= @('') -#$HYPERVISORPKS= @('','') +#$HYPERVISORPKS=@('') -#-- Default config paths for the installer or package (system paths) -#$PKGENV=true +#-- Grant access to pseudoterminal (pty) for public keys +#$DMSGPTYPKS=@('') -#-- Default config paths for the current userspace -#$USRENV=true +### Survey Access ####################################################### -#-- Set secret key -#$SK='' +#-- Grant access for survey collection to these public keys +#$SURVEYPKS=@('') -#-- Disable auto-transports to public visors -#$DISABLEPUBLICAUTOCONN=true +### Hypervisor UI ####################################################### -#-- Custom config version override -#$VERSION='' +#-- Start the hypervisor interface for this visor +#$ISHYPERVISOR=$true -#-- Set app bin_path -#$BINPATH='./apps' +### Apps ################################################################ + +#-- Display the node IP in the service discovery +# for any public services this visor is running +#$DISPLAYNODEIP=$true + +#-- Autostart VPN server for this visor +#$VPNSERVER=$true #-- Set server public key for proxy client to connect to #$PROXYCLIENTPK='' #-- Enable autostart of the proxy client -#$STARTPROXYCLIENT=true +#$STARTPROXYCLIENT=$true #-- Disable autostart of proxy server -#$NOPROXYSERVER=true +#$NOPROXYSERVER=$true #-- Set a password for the proxy server #$PROXYSEVERPASS='' @@ -1219,20 +1267,32 @@ const envfileWindows = `# #$PROXYCLIENTPASS='' #-- Set VPN client killswitch -#$VPNKS=true +#$VPNKS=$true -#-- Set vpn server public key for the vpn client to use +#-- Set VPN server public key for the VPN client to use #$ADDVPNPK='' -#-- Password for vpn client to access the server (if password is set forthe server) +#-- Password for VPN client to access the server (if password is set for the server) #$VPNCLIENTPASS='' -#-- Set password to the vpn server +#-- Set password to the VPN server #$VPNSEVERPASS='' -#-- Change secure mode status of vpn server +#-- Change secure mode status of VPN server #$VPNSEVERSECURE='' -#-- Set VPN Server network interface +#-- Set VPN Server network interface, e.g., 'Ethernet' #$VPNSEVERNETIFC='' + +### Miscellaneous ####################################################### + +#-- Set secret key +#$SK='' + +#-- Custom config version override +#$VERSION='' + +#-- Set visor runtime log level. +# Default is info ; uncomment for debug logging +#$LOGLVL='debug' ` diff --git a/cmd/skywire-cli/commands/config/root.go b/cmd/skywire-cli/commands/config/root.go index dc3dc00c98..6274b3d948 100644 --- a/cmd/skywire-cli/commands/config/root.go +++ b/cmd/skywire-cli/commands/config/root.go @@ -10,6 +10,7 @@ import ( "github.com/skycoin/dmsg/pkg/disc" "github.com/spf13/cobra" + "github.com/skycoin/skywire" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/visor/visorconfig" @@ -23,6 +24,7 @@ var ( Test: visorconfig.DmsgHTTPServersData{DMSGServers: []*disc.Entry{}}, Prod: visorconfig.DmsgHTTPServersData{DMSGServers: []*disc.Entry{}}, } + emdeddedSvcConf = skywire.Prod path string noFetch bool noDefaults bool