Skip to content

Commit

Permalink
also check status code
Browse files Browse the repository at this point in the history
  • Loading branch information
muhamadazmy committed Apr 22, 2022
1 parent d95584a commit 3e9b510
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/network/yggdrasil/public_peerlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package yggdrasil

import (
"encoding/json"
"fmt"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -128,6 +129,10 @@ func FetchPubYggPeerList() (Peers, error) {
return nil, err
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("invalid status code: %s", resp.Status)
}

if err := json.NewDecoder(resp.Body).Decode(&pl); err != nil {
return nil, err
}
Expand Down

0 comments on commit 3e9b510

Please sign in to comment.