diff --git a/cmd/skywire-cli/commands/config/gen.go b/cmd/skywire-cli/commands/config/gen.go index 47985fe9bf..0635419b11 100644 --- a/cmd/skywire-cli/commands/config/gen.go +++ b/cmd/skywire-cli/commands/config/gen.go @@ -496,25 +496,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 @@ -580,11 +581,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 aa6c856552..5300048ca0 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