mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-12 19:30:26 +08:00
添加端口时校验端口范围
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
"github.com/iwind/TeaGo/types"
|
||||||
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IndexAction struct {
|
type IndexAction struct {
|
||||||
@@ -76,6 +78,24 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
this.Fail("端口地址解析失败:" + err.Error())
|
this.Fail("端口地址解析失败:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查端口地址是否正确
|
||||||
|
for _, addr := range addresses {
|
||||||
|
err = addr.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("绑定端口校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if regexp.MustCompile(`^\d+$`).MatchString(addr.PortRange) {
|
||||||
|
port := types.Int(addr.PortRange)
|
||||||
|
if port > 65535 {
|
||||||
|
this.Fail("绑定的端口地址不能大于65535")
|
||||||
|
}
|
||||||
|
if port == 443 {
|
||||||
|
this.Fail("端口443通常是HTTPS的端口,不能用在HTTP上")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
server, _, isOk := serverutils.FindServer(this.Parent(), params.ServerId)
|
server, _, isOk := serverutils.FindServer(this.Parent(), params.ServerId)
|
||||||
if !isOk {
|
if !isOk {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IndexAction struct {
|
type IndexAction struct {
|
||||||
@@ -87,7 +88,23 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
this.Fail("端口地址解析失败:" + err.Error())
|
this.Fail("端口地址解析失败:" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 校验addresses
|
// 检查端口地址是否正确
|
||||||
|
for _, addr := range addresses {
|
||||||
|
err = addr.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("绑定端口校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if regexp.MustCompile(`^\d+$`).MatchString(addr.PortRange) {
|
||||||
|
port := types.Int(addr.PortRange)
|
||||||
|
if port > 65535 {
|
||||||
|
this.Fail("绑定的端口地址不能大于65535")
|
||||||
|
}
|
||||||
|
if port == 80 {
|
||||||
|
this.Fail("端口80通常是HTTP的端口,不能用在HTTPS上")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 校验SSL
|
// 校验SSL
|
||||||
var sslPolicyId = int64(0)
|
var sslPolicyId = int64(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user