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

fix issue fetching data from hardcoded server #1666

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 23 additions & 22 deletions cmd/skywire-cli/commands/config/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/skywire-cli/commands/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
disableApps string
isBestProtocol bool
serviceConfURL string
services *visorconfig.Services
services visorconfig.Services
isForce bool
isHide bool
isAll bool
Expand Down
Loading