mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-11 10:10:28 +08:00
优化代码/自动去除域名中的http://和https://等,防止误填
This commit is contained in:
@@ -132,13 +132,6 @@ func (this *ClusterHelper) createSettingMenu(cluster *pb.NodeCluster, info *pb.F
|
|||||||
"isActive": false,
|
"isActive": false,
|
||||||
})
|
})
|
||||||
|
|
||||||
items = append(items, maps.Map{
|
|
||||||
"name": "健康检查",
|
|
||||||
"url": "/clusters/cluster/settings/health?clusterId=" + clusterId,
|
|
||||||
"isActive": selectedItem == "health",
|
|
||||||
"isOn": info != nil && info.HealthCheckIsOn,
|
|
||||||
})
|
|
||||||
|
|
||||||
items = append(items, maps.Map{
|
items = append(items, maps.Map{
|
||||||
"name": "DNS设置",
|
"name": "DNS设置",
|
||||||
"url": "/clusters/cluster/settings/dns?clusterId=" + clusterId,
|
"url": "/clusters/cluster/settings/dns?clusterId=" + clusterId,
|
||||||
@@ -146,6 +139,13 @@ func (this *ClusterHelper) createSettingMenu(cluster *pb.NodeCluster, info *pb.F
|
|||||||
"isOn": cluster.DnsDomainId > 0 || len(cluster.DnsName) > 0,
|
"isOn": cluster.DnsDomainId > 0 || len(cluster.DnsName) > 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
items = append(items, maps.Map{
|
||||||
|
"name": "健康检查",
|
||||||
|
"url": "/clusters/cluster/settings/health?clusterId=" + clusterId,
|
||||||
|
"isActive": selectedItem == "health",
|
||||||
|
"isOn": info != nil && info.HealthCheckIsOn,
|
||||||
|
})
|
||||||
|
|
||||||
items = append(items, maps.Map{
|
items = append(items, maps.Map{
|
||||||
"name": "DDoS防护",
|
"name": "DDoS防护",
|
||||||
"url": "/clusters/cluster/settings/ddos-protection?clusterId=" + clusterId,
|
"url": "/clusters/cluster/settings/ddos-protection?clusterId=" + clusterId,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -29,11 +30,25 @@ func (this *AddServerNamePopupAction) RunPost(params struct {
|
|||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
if params.Mode == "single" {
|
if params.Mode == "single" {
|
||||||
|
var serverName = params.ServerName
|
||||||
|
|
||||||
|
// 去除空格
|
||||||
|
serverName = regexp.MustCompile(`\s+`).ReplaceAllString(serverName, "")
|
||||||
|
|
||||||
|
// 处理URL
|
||||||
|
if regexp.MustCompile(`^(?i)(http|https|ftp)://`).MatchString(serverName) {
|
||||||
|
u, err := url.Parse(serverName)
|
||||||
|
if err == nil && len(u.Host) > 0 {
|
||||||
|
serverName = u.Host
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
params.Must.
|
params.Must.
|
||||||
Field("serverName", params.ServerName).
|
Field("serverName", serverName).
|
||||||
Require("请输入域名")
|
Require("请输入域名")
|
||||||
|
|
||||||
this.Data["serverName"] = maps.Map{
|
this.Data["serverName"] = maps.Map{
|
||||||
"name": params.ServerName,
|
"name": serverName,
|
||||||
"type": "full",
|
"type": "full",
|
||||||
}
|
}
|
||||||
} else if params.Mode == "multiple" {
|
} else if params.Mode == "multiple" {
|
||||||
@@ -41,14 +56,23 @@ func (this *AddServerNamePopupAction) RunPost(params struct {
|
|||||||
this.FailField("serverNames", "请输入至少域名")
|
this.FailField("serverNames", "请输入至少域名")
|
||||||
}
|
}
|
||||||
|
|
||||||
serverNames := []string{}
|
var serverNames = []string{}
|
||||||
for _, line := range strings.Split(params.ServerNames, "\n") {
|
for _, line := range strings.Split(params.ServerNames, "\n") {
|
||||||
line := strings.TrimSpace(line)
|
var serverName = strings.TrimSpace(line)
|
||||||
line = regexp.MustCompile(`\s+`).ReplaceAllString(line, "")
|
serverName = regexp.MustCompile(`\s+`).ReplaceAllString(serverName, "")
|
||||||
if len(line) == 0 {
|
if len(serverName) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
serverNames = append(serverNames, line)
|
|
||||||
|
// 处理URL
|
||||||
|
if regexp.MustCompile(`^(?i)(http|https|ftp)://`).MatchString(serverName) {
|
||||||
|
u, err := url.Parse(serverName)
|
||||||
|
if err == nil && len(u.Host) > 0 {
|
||||||
|
serverName = u.Host
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serverNames = append(serverNames, serverName)
|
||||||
}
|
}
|
||||||
this.Data["serverName"] = maps.Map{
|
this.Data["serverName"] = maps.Map{
|
||||||
"name": "",
|
"name": "",
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ func (this *IndexAction) Init() {
|
|||||||
this.Nav("", "", "purge")
|
this.Nav("", "", "purge")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct{}) {
|
func (this *IndexAction) RunGet(params struct {
|
||||||
|
KeyType string
|
||||||
|
}) {
|
||||||
// 初始化菜单数据
|
// 初始化菜单数据
|
||||||
err := InitMenu(this.Parent())
|
err := InitMenu(this.Parent())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -29,6 +31,8 @@ func (this *IndexAction) RunGet(params struct{}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.Data["keyType"] = params.KeyType
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ Vue.component("plan-bandwidth-ranges", {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
if (v1.minMB == v2.minMB) {
|
if (v1.minMB == v2.minMB) {
|
||||||
|
if (v2.maxMB == 0 || v1.maxMB < v2.maxMB) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ Vue.component("reverse-proxy-box", {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-show="family == null || family == 'http'">
|
<tr v-show="family == null || family == 'http'">
|
||||||
<td>回源主机名不包含端口</td>
|
<td>回源主机名移除端口</td>
|
||||||
<td><checkbox v-model="reverseProxyConfig.requestHostExcludingPort"></checkbox>
|
<td><checkbox v-model="reverseProxyConfig.requestHostExcludingPort"></checkbox>
|
||||||
<p class="comment">选中后表示移除回源主机名中的端口部分。</p>
|
<p class="comment">选中后表示移除回源主机名中的端口部分。</p>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -45,6 +45,13 @@
|
|||||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tbody v-show="moreOptionsVisible">
|
<tbody v-show="moreOptionsVisible">
|
||||||
|
<tr>
|
||||||
|
<td>允许通过CNAME访问网站服务</td>
|
||||||
|
<td>
|
||||||
|
<checkbox name="cnameAsDomain" v-model="cnameAsDomain"></checkbox>
|
||||||
|
<p class="comment">选中后,表示允许使用CNAME直接访问网站服务;如果取消选中,则表示CNAME只作为DNS解析记录使用。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>记录TTL</td>
|
<td>记录TTL</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -54,13 +61,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<p class="comment">每个DNS服务商或者账号的TTL限制各有不同,请注意取值范围。0表示使用默认。</p>
|
<p class="comment">每个DNS服务商或者账号的TTL限制各有不同,请注意取值范围。0表示使用默认。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>允许通过CNAME访问网站服务</td>
|
|
||||||
<td>
|
|
||||||
<checkbox name="cnameAsDomain" v-model="cnameAsDomain"></checkbox>
|
|
||||||
<p class="comment">选中后,表示允许使用CNAME直接访问网站服务;如果取消选中,则表示CNAME只作为DNS解析记录使用。</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>是否同步节点DNS状态</td>
|
<td>是否同步节点DNS状态</td>
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
<td class="title">单个域名 *</td>
|
<td class="title">单个域名 *</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="serverName" ref="focus" maxlength="1024" v-model="serverName.name"/>
|
<input type="text" name="serverName" ref="focus" maxlength="1024" v-model="serverName.name"/>
|
||||||
<p class="comment">请输入单个域名。</p>
|
<p class="comment">请输入单个域名,域名中<strong>不能</strong>包含<code-label>http</code-label>或<code-label>https</code-label>。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="mode == 'multiple'">
|
<tr v-if="mode == 'multiple'">
|
||||||
<td class="title">多个域名 *</td>
|
<td class="title">多个域名 *</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea name="serverNames" ref="serverNames" v-model="multipleServerNames"></textarea>
|
<textarea name="serverNames" ref="serverNames" v-model="multipleServerNames"></textarea>
|
||||||
<p class="comment">每行一个域名。</p>
|
<p class="comment">每行一个域名,域名中<strong>不能</strong>包含<code-label>http</code-label>或<code-label>https</code-label>。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ Tea.context(function () {
|
|||||||
|
|
||||||
this.success = function () {
|
this.success = function () {
|
||||||
this.isOk = true
|
this.isOk = true
|
||||||
let f = NotifyReloadSuccess("任务提交成功")
|
let that = this
|
||||||
f()
|
teaweb.success("任务提交成功", function () {
|
||||||
|
window.location = window.location.pathname + "?keyType=" + that.keyType
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fail = function (resp) {
|
this.fail = function (resp) {
|
||||||
@@ -39,5 +41,7 @@ Tea.context(function () {
|
|||||||
/**
|
/**
|
||||||
* 操作类型
|
* 操作类型
|
||||||
*/
|
*/
|
||||||
|
if (this.keyType == null || this.keyType.length == 0) {
|
||||||
this.keyType = "key" // key | prefix
|
this.keyType = "key" // key | prefix
|
||||||
|
}
|
||||||
})
|
})
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
<td class="color-border">缓存文件句柄缓存</td>
|
<td class="color-border">缓存文件句柄缓存</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="fileOpenFileCacheMax" maxlength="6" value="0" style="width: 10em"/>
|
<input type="text" name="fileOpenFileCacheMax" maxlength="6" value="0" style="width: 10em"/>
|
||||||
<p class="comment">保持缓存文件句柄,提升缓存文件打开速度,建议数量不超过缓存文件数量的10%。</p>
|
<p class="comment">保持在内存中的缓存文件句柄的数量,提升缓存文件打开速度,建议数量不超过缓存文件数量的十分之一。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-show="teaIsPlus">
|
<tr v-show="teaIsPlus">
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
<td class="color-border">缓存文件句柄缓存</td>
|
<td class="color-border">缓存文件句柄缓存</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="fileOpenFileCacheMax" v-model="fileOpenFileCacheMax" maxlength="6" value="0" style="width: 10em"/>
|
<input type="text" name="fileOpenFileCacheMax" v-model="fileOpenFileCacheMax" maxlength="6" value="0" style="width: 10em"/>
|
||||||
<p class="comment">保持缓存文件句柄,提升缓存文件打开速度,建议数量是缓存文件数量的10%。</p>
|
<p class="comment">保持在内存中的缓存文件句柄的数量,提升缓存文件打开速度,建议数量不超过缓存文件数量的十分之一。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-show="teaIsPlus">
|
<tr v-show="teaIsPlus">
|
||||||
|
|||||||
Reference in New Issue
Block a user