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

@@ -2,13 +2,16 @@ package Util
import (
"Mmx/Global"
"context"
"crypto/md5"
"crypto/sha1"
"errors"
"fmt"
"io"
"net"
"os"
"regexp"
"time"
)
func Search(reg string, content string) (string, error) {
@@ -57,3 +60,12 @@ func ErrHandler(err error) {
os.Exit(1)
}
}
func NetDailEr() func(ctx context.Context, network, address string) (net.Conn, error) {
return func(ctx context.Context, network, address string) (net.Conn, error) {
d := net.Dialer{
Timeout: 20 * time.Second,
}
return d.DialContext(ctx, "udp", "1.2.4.8:53")
}
}