mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 17:30:29 +08:00
启用服务HTTP/HTTPS设置时如果没有设置端口,则自动添加80/443
This commit is contained in:
@@ -72,12 +72,22 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
// 记录日志
|
// 记录日志
|
||||||
defer this.CreateLog(oplogs.LevelInfo, "修改服务 %d 的HTTP设置", params.ServerId)
|
defer this.CreateLog(oplogs.LevelInfo, "修改服务 %d 的HTTP设置", params.ServerId)
|
||||||
|
|
||||||
addresses := []*serverconfigs.NetworkAddressConfig{}
|
var addresses = []*serverconfigs.NetworkAddressConfig{}
|
||||||
err := json.Unmarshal([]byte(params.Addresses), &addresses)
|
err := json.Unmarshal([]byte(params.Addresses), &addresses)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Fail("端口地址解析失败:" + err.Error())
|
this.Fail("端口地址解析失败:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果启用HTTP时没有填写端口,则默认为80
|
||||||
|
if params.IsOn && len(addresses) == 0 {
|
||||||
|
addresses = []*serverconfigs.NetworkAddressConfig{
|
||||||
|
{
|
||||||
|
Protocol: serverconfigs.ProtocolHTTP,
|
||||||
|
PortRange: "80",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 检查端口地址是否正确
|
// 检查端口地址是否正确
|
||||||
for _, addr := range addresses {
|
for _, addr := range addresses {
|
||||||
err = addr.Init()
|
err = addr.Init()
|
||||||
@@ -100,7 +110,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
if !isOk {
|
if !isOk {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
httpConfig := &serverconfigs.HTTPProtocolConfig{}
|
var httpConfig = &serverconfigs.HTTPProtocolConfig{}
|
||||||
if len(server.HttpJSON) > 0 {
|
if len(server.HttpJSON) > 0 {
|
||||||
err = json.Unmarshal(server.HttpJSON, httpConfig)
|
err = json.Unmarshal(server.HttpJSON, httpConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -82,12 +82,22 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
// 记录日志
|
// 记录日志
|
||||||
defer this.CreateLog(oplogs.LevelInfo, "修改服务 %d 的HTTPS设置", params.ServerId)
|
defer this.CreateLog(oplogs.LevelInfo, "修改服务 %d 的HTTPS设置", params.ServerId)
|
||||||
|
|
||||||
addresses := []*serverconfigs.NetworkAddressConfig{}
|
var addresses = []*serverconfigs.NetworkAddressConfig{}
|
||||||
err := json.Unmarshal([]byte(params.Addresses), &addresses)
|
err := json.Unmarshal([]byte(params.Addresses), &addresses)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Fail("端口地址解析失败:" + err.Error())
|
this.Fail("端口地址解析失败:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果启用HTTPS时没有填写端口,则默认为443
|
||||||
|
if params.IsOn && len(addresses) == 0 {
|
||||||
|
addresses = []*serverconfigs.NetworkAddressConfig{
|
||||||
|
{
|
||||||
|
Protocol: serverconfigs.ProtocolHTTPS,
|
||||||
|
PortRange: "443",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 检查端口地址是否正确
|
// 检查端口地址是否正确
|
||||||
for _, addr := range addresses {
|
for _, addr := range addresses {
|
||||||
err = addr.Init()
|
err = addr.Init()
|
||||||
@@ -177,7 +187,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
if !isOk {
|
if !isOk {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
httpsConfig := &serverconfigs.HTTPSProtocolConfig{}
|
var httpsConfig = &serverconfigs.HTTPSProtocolConfig{}
|
||||||
if len(server.HttpsJSON) > 0 {
|
if len(server.HttpsJSON) > 0 {
|
||||||
err = json.Unmarshal(server.HttpsJSON, httpsConfig)
|
err = json.Unmarshal(server.HttpsJSON, httpsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -718,7 +718,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
|||||||
<td class="title">选择证书</td>
|
<td class="title">选择证书</td>
|
||||||
<td>
|
<td>
|
||||||
<div v-if="policy.certs != null && policy.certs.length > 0">
|
<div v-if="policy.certs != null && policy.certs.length > 0">
|
||||||
<div class="ui label small" v-for="(cert, index) in policy.certs">
|
<div class="ui label small basic" v-for="(cert, index) in policy.certs" style="margin-top: 0.2em">
|
||||||
{{cert.name}} / {{cert.dnsNames}} / 有效至{{formatTime(cert.timeEndAt)}} <a href="" title="删除" @click.prevent="removeCert(index)"><i class="icon remove"></i></a>
|
{{cert.name}} / {{cert.dnsNames}} / 有效至{{formatTime(cert.timeEndAt)}} <a href="" title="删除" @click.prevent="removeCert(index)"><i class="icon remove"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
|
|||||||
@@ -2597,7 +2597,7 @@ Vue.component("ssl-config-box", {
|
|||||||
<td class="title">选择证书</td>
|
<td class="title">选择证书</td>
|
||||||
<td>
|
<td>
|
||||||
<div v-if="policy.certs != null && policy.certs.length > 0">
|
<div v-if="policy.certs != null && policy.certs.length > 0">
|
||||||
<div class="ui label small" v-for="(cert, index) in policy.certs">
|
<div class="ui label small basic" v-for="(cert, index) in policy.certs" style="margin-top: 0.2em">
|
||||||
{{cert.name}} / {{cert.dnsNames}} / 有效至{{formatTime(cert.timeEndAt)}} <a href="" title="删除" @click.prevent="removeCert(index)"><i class="icon remove"></i></a>
|
{{cert.name}} / {{cert.dnsNames}} / 有效至{{formatTime(cert.timeEndAt)}} <a href="" title="删除" @click.prevent="removeCert(index)"><i class="icon remove"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ Vue.component("ssl-config-box", {
|
|||||||
<td class="title">选择证书</td>
|
<td class="title">选择证书</td>
|
||||||
<td>
|
<td>
|
||||||
<div v-if="policy.certs != null && policy.certs.length > 0">
|
<div v-if="policy.certs != null && policy.certs.length > 0">
|
||||||
<div class="ui label small" v-for="(cert, index) in policy.certs">
|
<div class="ui label small basic" v-for="(cert, index) in policy.certs" style="margin-top: 0.2em">
|
||||||
{{cert.name}} / {{cert.dnsNames}} / 有效至{{formatTime(cert.timeEndAt)}} <a href="" title="删除" @click.prevent="removeCert(index)"><i class="icon remove"></i></a>
|
{{cert.name}} / {{cert.dnsNames}} / 有效至{{formatTime(cert.timeEndAt)}} <a href="" title="删除" @click.prevent="removeCert(index)"><i class="icon remove"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user