限制ip查询时间
This commit is contained in:
parent
5def1cd668
commit
cc2d768474
1 changed files with 6 additions and 2 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
)
|
||||
|
@ -45,10 +46,13 @@ func (a *Ip) GetMsg() string {
|
|||
// }
|
||||
// }
|
||||
// fmt.Println("请求体:", string(json_data))
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
client := &http.Client{
|
||||
Timeout: 5 * time.Second, // 设置超时时间为5秒
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
fmt.Println("err:", err)
|
||||
return "连接超时!"
|
||||
} else {
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
|
|
Loading…
Reference in a new issue