安装过程中节点主机地址允许填写域名

This commit is contained in:
GoEdgeLab
2023-03-10 17:00:53 +08:00
parent 8106c48342
commit e5b840a492
2 changed files with 20 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
"net"
"regexp"
"strings"
)
@@ -61,7 +62,24 @@ func (this *ValidateApiAction) RunPost(params struct {
}
if net.ParseIP(params.NewHost) == nil {
// 检查是否为域名
var domainReg = regexp.MustCompile(`^[\w-]+$`) // 这里暂不支持 unicode 域名
var digitReg = regexp.MustCompile(`^\d+$`)
var isIP = true
for _, piece := range strings.Split(params.NewHost, ".") {
if !domainReg.MatchString(piece) {
this.FailField("newHost", "请输入正确的API节点主机地址")
return
}
if !digitReg.MatchString(piece) {
isIP = false
}
}
if isIP {
this.FailField("newHost", "请输入正确的API节点主机地址")
return
}
}
params.Must.

View File

@@ -89,7 +89,7 @@
<input type="text" name="newHost" value="" ref="newHostRef" placeholder="x.x.x.x" v-model="currentHost"/>
</div>
</div>
<p class="comment">其他节点访问此API节点的主机地址可以是IP或者域名第一次安装时通常是<strong>当前服务器</strong>的公网IP地址。后期可以修改这个地址。</p>
<p class="comment">API节点IP地址或者域名。其他节点访问此API节点的主机地址可以是IP或者域名第一次安装时通常是<strong>当前服务器</strong>的公网IP地址。后期可以修改这个地址。</p>
</td>
</tr>
</tbody>