From ad133cb4bbc2f765ddd875e207b2e831063f1bb3 Mon Sep 17 00:00:00 2001 From: Anders Pitman Date: Thu, 23 Dec 2021 14:10:18 -0700 Subject: [PATCH] Use TakingNames.io to get public IP Keepin it in the family --- boringproxy.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/boringproxy.go b/boringproxy.go index 82f653a..dd9e847 100644 --- a/boringproxy.go +++ b/boringproxy.go @@ -39,10 +39,6 @@ type Server struct { httpListener *PassthroughListener } -type IpResponse struct { - Ip string `json:"ip"` -} - func checkPublicAddress(host string, port int) error { ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) @@ -94,20 +90,14 @@ func checkPublicAddress(host string, port int) error { } func getPublicIp() (string, error) { - resp, err := http.Get("https://api.ipify.org?format=json") + resp, err := http.Get("https://takingnames.io/my-ip") if err != nil { return "", err } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) - var ipRes *IpResponse - err = json.Unmarshal([]byte(body), &ipRes) - if err != nil { - return "", err - } - - return ipRes.Ip, nil + return string(body), nil } func Listen() {