mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-16 05:30:27 +08:00
安装时如果数据库地址填写的是公网IP,则提示会影响系统运行性能
This commit is contained in:
39
internal/web/actions/default/setup/checkLocalIP.go
Normal file
39
internal/web/actions/default/setup/checkLocalIP.go
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package setup
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"net"
|
||||
)
|
||||
|
||||
// CheckLocalIPAction 检查IP是否为局域网IP
|
||||
type CheckLocalIPAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *CheckLocalIPAction) RunPost(params struct {
|
||||
Host string
|
||||
}) {
|
||||
var ip = net.ParseIP(params.Host)
|
||||
if ip == nil {
|
||||
// 默认为true
|
||||
this.Data["isLocal"] = true
|
||||
this.Success()
|
||||
}
|
||||
|
||||
var ipObj = ip.To4()
|
||||
if ipObj == nil {
|
||||
ipObj = ip.To16()
|
||||
}
|
||||
if ipObj == nil {
|
||||
// 默认为true
|
||||
this.Data["isLocal"] = true
|
||||
this.Success()
|
||||
}
|
||||
|
||||
this.Data["isLocal"] = utils.IsLocalIP(ipObj)
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user