diff --git a/cmd/skywire-cli/commands/config/gen.go b/cmd/skywire-cli/commands/config/gen.go index 9bf3f9de9..eff13423a 100644 --- a/cmd/skywire-cli/commands/config/gen.go +++ b/cmd/skywire-cli/commands/config/gen.go @@ -497,25 +497,26 @@ var genConfigCmd = &cobra.Command{ log.WithError(err).Error("Failed to fetch servers\n") log.Warn("Falling back on hardcoded servers") } - } - if res.Body != nil { - defer res.Body.Close() //nolint - } - body, err := io.ReadAll(res.Body) - if err != nil { - log.WithError(err).Fatal("Failed to read response\n") - } - //fill in services struct with the response - err = json.Unmarshal(body, &services) - if err != nil { - log.WithError(err).Fatal("Failed to unmarshal json response\n") - } - if !isStdout { - log.Infof("Fetched service endpoints from '%s'", serviceConfURL) - } + } else { + if res.Body != nil { + defer res.Body.Close() //nolint + } + body, err := io.ReadAll(res.Body) + if err != nil { + log.WithError(err).Fatal("Failed to read response\n") + } + //fill in services struct with the response + err = json.Unmarshal(body, &services) + if err != nil { + log.WithError(err).Fatal("Failed to unmarshal json response\n") + } + if !isStdout { + log.Infof("Fetched service endpoints from '%s'", serviceConfURL) + } - // reset the state of isStdout - isStdout = wasStdout + // reset the state of isStdout + isStdout = wasStdout + } } // Read in old config and obtain old secret key or generate a new random secret key @@ -581,11 +582,11 @@ var genConfigCmd = &cobra.Command{ conf.Common.PK = pk dnsServer := utilenv.DNSServer - if services != nil { - if services.DNSServer != "" { - dnsServer = services.DNSServer - } + + if services.DNSServer != "" { + dnsServer = services.DNSServer } + if isDmsgHTTP { dmsghttpConfig := visorconfig.DMSGHTTPName // TODO diff --git a/cmd/skywire-cli/commands/config/root.go b/cmd/skywire-cli/commands/config/root.go index aa6c85655..5300048ca 100644 --- a/cmd/skywire-cli/commands/config/root.go +++ b/cmd/skywire-cli/commands/config/root.go @@ -50,7 +50,7 @@ var ( disableApps string isBestProtocol bool serviceConfURL string - services *visorconfig.Services + services visorconfig.Services isForce bool isHide bool isAll bool