fix: avoid panic by handling getOutboundIP() error

This commit is contained in:
makeavish 2022-02-22 17:49:02 +05:30
parent 05c79b7119
commit 56c9ea5430

View File

@ -61,6 +61,10 @@ func getOutboundIP() string {
ip := []byte("NA") ip := []byte("NA")
resp, err := http.Get("https://api.ipify.org?format=text") resp, err := http.Get("https://api.ipify.org?format=text")
if err != nil {
return ""
}
defer resp.Body.Close() defer resp.Body.Close()
if err == nil { if err == nil {
ipBody, err := ioutil.ReadAll(resp.Body) ipBody, err := ioutil.ReadAll(resp.Body)