mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
当HTTP和HTTPS端口冲突时提示用户
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"regexp"
|
||||
@@ -30,7 +31,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
if !isOk {
|
||||
return
|
||||
}
|
||||
httpConfig := &serverconfigs.HTTPProtocolConfig{}
|
||||
var httpConfig = &serverconfigs.HTTPProtocolConfig{}
|
||||
if len(server.HttpJSON) > 0 {
|
||||
err := json.Unmarshal(server.HttpJSON, httpConfig)
|
||||
if err != nil {
|
||||
@@ -40,6 +41,26 @@ func (this *IndexAction) RunGet(params struct {
|
||||
} else {
|
||||
httpConfig.IsOn = true
|
||||
}
|
||||
_ = httpConfig.Init()
|
||||
var httpPorts = httpConfig.AllPorts()
|
||||
|
||||
// 检查http和https端口冲突
|
||||
var conflictingPorts = []int{}
|
||||
if len(server.HttpsJSON) > 0 {
|
||||
var httpsConfig = &serverconfigs.HTTPSProtocolConfig{}
|
||||
err := json.Unmarshal(server.HttpsJSON, httpsConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
_ = httpsConfig.Init()
|
||||
for _, port := range httpsConfig.AllPorts() {
|
||||
if lists.ContainsInt(httpPorts, port) {
|
||||
conflictingPorts = append(conflictingPorts, port)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Data["conflictingPorts"] = conflictingPorts
|
||||
|
||||
this.Data["serverType"] = server.Type
|
||||
this.Data["httpConfig"] = maps.Map{
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"regexp"
|
||||
@@ -42,6 +43,27 @@ func (this *IndexAction) RunGet(params struct {
|
||||
httpsConfig.IsOn = true
|
||||
}
|
||||
|
||||
_ = httpsConfig.Init()
|
||||
var httpsPorts = httpsConfig.AllPorts()
|
||||
|
||||
// 检查http和https端口冲突
|
||||
var conflictingPorts = []int{}
|
||||
if len(server.HttpJSON) > 0 {
|
||||
var httpConfig = &serverconfigs.HTTPProtocolConfig{}
|
||||
err := json.Unmarshal(server.HttpJSON, httpConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
_ = httpConfig.Init()
|
||||
for _, port := range httpConfig.AllPorts() {
|
||||
if lists.ContainsInt(httpsPorts, port) {
|
||||
conflictingPorts = append(conflictingPorts, port)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Data["conflictingPorts"] = conflictingPorts
|
||||
|
||||
var sslPolicy *sslconfigs.SSLPolicy
|
||||
if httpsConfig.SSLPolicyRef != nil && httpsConfig.SSLPolicyRef.SSLPolicyId > 0 {
|
||||
sslPolicyConfigResp, err := this.RPC().SSLPolicyRPC().FindEnabledSSLPolicyConfig(this.AdminContext(), &pb.FindEnabledSSLPolicyConfigRequest{
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<td>
|
||||
<span class="red" v-if="httpConfig.isOn && (httpConfig.addresses == null || httpConfig.addresses.length == 0)">还没有添加端口绑定,会导致HTTP服务无法访问。</span>
|
||||
<network-addresses-box :v-server-type="serverType" :v-addresses="httpConfig.addresses" :v-protocol="'http'"></network-addresses-box>
|
||||
<p class="comment"><span v-if="conflictingPorts.length > 0" class="red">配置错误:<span v-for="(port, index) in conflictingPorts">{{port}}<span v-if="index != conflictingPorts.length - 1">、</span></span><span v-if="conflictingPorts.length > 1">等</span>端口同HTTPS设置的端口冲突,请删除HTTP或HTTPS中的相关端口。</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<td>
|
||||
<span class="red" v-if="httpsConfig.isOn && (httpsConfig.addresses == null || httpsConfig.addresses.length == 0)">还没有添加端口绑定,会导致HTTPS服务无法访问。</span>
|
||||
<network-addresses-box :v-server-type="serverType" :v-addresses="httpsConfig.addresses" :v-protocol="'https'"></network-addresses-box>
|
||||
<p class="comment"><span v-if="conflictingPorts.length > 0" class="red">配置错误:<span v-for="(port, index) in conflictingPorts">{{port}}<span v-if="index != conflictingPorts.length - 1">、</span></span><span v-if="conflictingPorts.length > 1">等</span>端口同HTTP设置的端口冲突,请删除HTTP或HTTPS中的相关端口。</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user