refactor:使用指定DNS彻底解决DNS缓存导致的问题

This commit is contained in:
Mmx
2021-05-07 14:06:53 +08:00
parent 393f60786a
commit 89e3197e33
5 changed files with 35 additions and 23 deletions

View File

@@ -1,9 +1,12 @@
package Request
import (
"Mmx/Util"
"io/ioutil"
"log"
"net"
"net/http"
"time"
)
func Get(Url string, Query map[string]string) (string, error) {
@@ -20,7 +23,17 @@ func Get(Url string, Query map[string]string) (string, error) {
}
req.URL.RawQuery = q.Encode()
}
resp, err := (&http.Client{}).Do(req)
resp, err := (&http.Client{
Transport: &http.Transport{
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
Resolver: &net.Resolver{
PreferGo: true,
Dial: Util.NetDailEr(),
},
}).DialContext,
},
}).Do(req)
if err != nil {
log.Println(err)
return "", err