ports初始化

This commit is contained in:
huweishan 2024-04-08 15:12:47 +08:00
parent 8df34428dd
commit 38b8f0b2aa
No known key found for this signature in database
GPG Key ID: 955238B53F458D37
1 changed files with 3 additions and 1 deletions

View File

@ -164,6 +164,7 @@ func SetGroup(g *Group) error {
}
v.IpNet = ipNet
if regexp.MustCompile(`^\d{1,5}(,\d{1,5})*$`).MatchString(v.PortStr) {
ports := []uint16{}
for _, port := range strings.Split(v.PortStr, ",") {
if port == "" {
continue
@ -172,8 +173,9 @@ func SetGroup(g *Group) error {
if err != nil {
return errors.New("端口:"+port+" 格式错误, " + err.Error())
}
v.Ports = append(v.Ports, uint16(portInt))
ports = append(ports, uint16(portInt))
}
v.Ports = ports
linkAcl = append(linkAcl, v)
} else {
return errors.New("端口: "+v.PortStr+" 格式错误,请用逗号分隔的端口列表,比如: 22,80,443")