feat: 调整判断网络状态方式
This commit is contained in:
13
util/util.go
13
util/util.go
@@ -1,16 +1,12 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"autoLogin/global"
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"crypto/sha1"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Search(reg string, content string) (string, error) {
|
||||
@@ -49,12 +45,3 @@ func Sha1(content string) string {
|
||||
bs := h.Sum(nil)
|
||||
return fmt.Sprintf("%x\n", bs)
|
||||
}
|
||||
|
||||
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{
|
||||
Deadline: time.Now().Add(5 * time.Second),
|
||||
}
|
||||
return d.DialContext(ctx, "udp", global.Config.Settings.Dns+":53")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user