限制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"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/goccy/go-json"
|
"github.com/goccy/go-json"
|
||||||
)
|
)
|
||||||
|
@ -45,10 +46,13 @@ func (a *Ip) GetMsg() string {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// fmt.Println("请求体:", string(json_data))
|
// fmt.Println("请求体:", string(json_data))
|
||||||
|
client := &http.Client{
|
||||||
resp, err := http.DefaultClient.Do(req)
|
Timeout: 5 * time.Second, // 设置超时时间为5秒
|
||||||
|
}
|
||||||
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("err:", err)
|
fmt.Println("err:", err)
|
||||||
|
return "连接超时!"
|
||||||
} else {
|
} else {
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
|
Loading…
Reference in a new issue