mirror of
https://github.com/DanielLavrushin/b4.git
synced 2026-07-09 16:00:05 +00:00
fix: update port validation logic for Socks5 and MTProto configurations
This commit is contained in:
parent
016c950e2b
commit
d1020ce38b
2 changed files with 10 additions and 2 deletions
|
|
@ -264,14 +264,14 @@ func (c *Config) checkPortCollisions(v *validator) {
|
|||
if c.System.WebServer.Port > 0 && c.System.WebServer.Port <= 65535 {
|
||||
refs = append(refs, portRef{"system.web_server.port", c.System.WebServer.Port})
|
||||
}
|
||||
if c.System.Socks5.Enabled && c.System.Socks5.Port > 0 {
|
||||
if c.System.Socks5.Enabled {
|
||||
if c.System.Socks5.Port < 1 || c.System.Socks5.Port > 65535 {
|
||||
v.add("system.socks5.port", "out_of_range", "port must be between 1 and 65535", portRangeParams)
|
||||
} else {
|
||||
refs = append(refs, portRef{"system.socks5.port", c.System.Socks5.Port})
|
||||
}
|
||||
}
|
||||
if c.System.MTProto.Enabled && c.System.MTProto.Port > 0 {
|
||||
if c.System.MTProto.Enabled {
|
||||
if c.System.MTProto.Port < 1 || c.System.MTProto.Port > 65535 {
|
||||
v.add("system.mtproto.port", "out_of_range", "port must be between 1 and 65535", portRangeParams)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -98,6 +98,14 @@ func TestValidate_PortOutOfRange(t *testing.T) {
|
|||
c.System.Socks5.Enabled = true
|
||||
c.System.Socks5.Port = 70000
|
||||
}, "system.socks5.port"},
|
||||
{"mtproto enabled with port 0", func(c *Config) {
|
||||
c.System.MTProto.Enabled = true
|
||||
c.System.MTProto.Port = 0
|
||||
}, "system.mtproto.port"},
|
||||
{"socks5 enabled with port 0", func(c *Config) {
|
||||
c.System.Socks5.Enabled = true
|
||||
c.System.Socks5.Port = 0
|
||||
}, "system.socks5.port"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue