mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	添加端口时校验端口范围
This commit is contained in:
		@@ -12,6 +12,7 @@ import (
 | 
			
		||||
	"github.com/iwind/TeaGo/actions"
 | 
			
		||||
	"github.com/iwind/TeaGo/maps"
 | 
			
		||||
	"github.com/iwind/TeaGo/types"
 | 
			
		||||
	"regexp"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type IndexAction struct {
 | 
			
		||||
@@ -87,7 +88,23 @@ func (this *IndexAction) RunPost(params struct {
 | 
			
		||||
		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
 | 
			
		||||
	var sslPolicyId = int64(0)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user