mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 12:20:28 +08:00
检测本地数据库时,主机地址增加尝试localhost、172.20.0.2
This commit is contained in:
@@ -26,10 +26,11 @@ func (this *DetectDBAction) RunPost(params struct{}) {
|
||||
var localPassword = ""
|
||||
|
||||
// 本地的3306端口是否可以连接
|
||||
conn, err := net.DialTimeout("tcp", "127.0.0.1:3306", 3*time.Second)
|
||||
if err == nil {
|
||||
for _, tryingHost := range []string{"127.0.0.1", "localhost", "172.20.0.2"} {
|
||||
conn, dialErr := net.DialTimeout("tcp", tryingHost+":3306", 3*time.Second)
|
||||
if dialErr == nil {
|
||||
_ = conn.Close()
|
||||
localHost = "127.0.0.1"
|
||||
localHost = tryingHost
|
||||
localPort = "3306"
|
||||
|
||||
var username = "root"
|
||||
@@ -61,6 +62,9 @@ func (this *DetectDBAction) RunPost(params struct{}) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
this.Data["localDB"] = maps.Map{
|
||||
|
||||
Reference in New Issue
Block a user