mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-11 17:00:32 +08:00
修改源站时校验端口号
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
@@ -144,7 +145,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
Field("addr", params.Addr).
|
Field("addr", params.Addr).
|
||||||
Require("请输入源站地址")
|
Require("请输入源站地址")
|
||||||
|
|
||||||
addr := params.Addr
|
var addr = params.Addr
|
||||||
|
|
||||||
// 是否是完整的地址
|
// 是否是完整的地址
|
||||||
if (params.Protocol == "http" || params.Protocol == "https") && regexp.MustCompile(`^(http|https)://`).MatchString(addr) {
|
if (params.Protocol == "http" || params.Protocol == "https") && regexp.MustCompile(`^(http|https)://`).MatchString(addr) {
|
||||||
@@ -169,9 +170,23 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
var host = addr[:portIndex]
|
var host = addr[:portIndex]
|
||||||
var port = addr[portIndex+1:]
|
var port = addr[portIndex+1:]
|
||||||
|
// 检查端口号
|
||||||
if port == "0" {
|
if port == "0" {
|
||||||
this.Fail("端口号不能为0")
|
this.Fail("端口号不能为0")
|
||||||
}
|
}
|
||||||
|
if !configutils.HasVariables(port) {
|
||||||
|
// 必须是整数
|
||||||
|
if !regexp.MustCompile(`^\d+$`).MatchString(port) {
|
||||||
|
this.Fail("端口号只能为整数")
|
||||||
|
}
|
||||||
|
var portInt = types.Int(port)
|
||||||
|
if portInt == 0 {
|
||||||
|
this.Fail("端口号不能为0")
|
||||||
|
}
|
||||||
|
if portInt > 65535 {
|
||||||
|
this.Fail("端口号不能大于65535")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
connTimeoutJSON, err := (&shared.TimeDuration{
|
connTimeoutJSON, err := (&shared.TimeDuration{
|
||||||
Count: int64(params.ConnTimeout),
|
Count: int64(params.ConnTimeout),
|
||||||
|
|||||||
Reference in New Issue
Block a user