mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-07-01 12:32:09 +00:00
refactor: use math.MaxUint16
when checking port
Some checks are pending
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
Some checks are pending
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
This commit is contained in:
parent
e272c160b1
commit
f86219f4de
2 changed files with 5 additions and 3 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"math"
|
||||||
|
|
||||||
"x-ui/util/common"
|
"x-ui/util/common"
|
||||||
)
|
)
|
||||||
|
@ -78,11 +79,11 @@ func (s *AllSetting) CheckValid() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.WebPort <= 0 || s.WebPort > 65535 {
|
if s.WebPort <= 0 || s.WebPort > math.MaxUint16 {
|
||||||
return common.NewError("web port is not a valid port:", s.WebPort)
|
return common.NewError("web port is not a valid port:", s.WebPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.SubPort <= 0 || s.SubPort > 65535 {
|
if s.SubPort <= 0 || s.SubPort > math.MaxUint16 {
|
||||||
return common.NewError("Sub port is not a valid port:", s.SubPort)
|
return common.NewError("Sub port is not a valid port:", s.SubPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
"math"
|
||||||
|
|
||||||
"x-ui/logger"
|
"x-ui/logger"
|
||||||
"x-ui/util/common"
|
"x-ui/util/common"
|
||||||
|
@ -32,7 +33,7 @@ type XrayAPI struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *XrayAPI) Init(apiPort int) error {
|
func (x *XrayAPI) Init(apiPort int) error {
|
||||||
if apiPort <= 0 {
|
if apiPort <= 0 || apiPort > math.MaxUint16 {
|
||||||
return fmt.Errorf("invalid Xray API port: %d", apiPort)
|
return fmt.Errorf("invalid Xray API port: %d", apiPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue