From 7c0534df738fa7f4053da8237b60bb2d7623cb6a Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Sat, 16 Oct 2021 22:47:30 +0800 Subject: [PATCH] feat: #1 --- cmd/client.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/client.go b/cmd/client.go index b423cc6..83fd83f 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -11,6 +11,7 @@ import ( "sort" "strings" "text/tabwriter" + "time" "github.com/robfig/cron/v3" "github.com/spf13/cobra" @@ -187,7 +188,11 @@ func GetPublicIP() (string, error) { if secure { protocol = "https://" } - res, err := http.Get(protocol + host + ":" + port + "?name=" + name) + req, _ := http.NewRequest("GET", protocol+host+":"+port+"?name="+name, nil) + client := &http.Client{ + Timeout: time.Second * 10, + } + res, err := client.Do(req) if err != nil { log.Println(err) return "", err