Skip to content

Commit e7598ba

Browse files
committed
Improve error message when ifconfig.co can't be contacted (#7).
1 parent 2800d37 commit e7598ba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

client_public_ip.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package main
99

1010
import (
1111
"encoding/json"
12+
"fmt"
1213
"io/ioutil"
1314
"net/http"
1415
)
@@ -20,9 +21,9 @@ type ipInfo struct {
2021

2122
// Retrieve the client machine's public IPv4 address.
2223
func getClientPublicIPv4Address() (string, error) {
23-
response, err := http.Get("http://ifconfig.co/json")
24+
response, err := http.Get("https://ifconfig.co/json")
2425
if err != nil {
25-
return "", err
26+
return "", fmt.Errorf("Unable to connect to ifconfig.co to determine your IP address: %s", err.Error())
2627
}
2728
defer response.Body.Close()
2829

0 commit comments

Comments
 (0)