fix: gracefully fail on invalid port number (#16721)

This commit is contained in:
cskh 2023-03-21 22:29:21 -04:00 committed by GitHub
parent 8a5fec715d
commit 3a4835e258
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -455,6 +455,14 @@ func (b *builder) build() (rt RuntimeConfig, err error) {
sidecarMaxPort := b.portVal("ports.sidecar_max_port", c.Ports.SidecarMaxPort) sidecarMaxPort := b.portVal("ports.sidecar_max_port", c.Ports.SidecarMaxPort)
exposeMinPort := b.portVal("ports.expose_min_port", c.Ports.ExposeMinPort) exposeMinPort := b.portVal("ports.expose_min_port", c.Ports.ExposeMinPort)
exposeMaxPort := b.portVal("ports.expose_max_port", c.Ports.ExposeMaxPort) exposeMaxPort := b.portVal("ports.expose_max_port", c.Ports.ExposeMaxPort)
if serverPort <= 0 {
return RuntimeConfig{}, fmt.Errorf(
"server-port must be greater than zero")
}
if serfPortLAN <= 0 {
return RuntimeConfig{}, fmt.Errorf(
"serf-lan-port must be greater than zero")
}
if proxyMaxPort < proxyMinPort { if proxyMaxPort < proxyMinPort {
return RuntimeConfig{}, fmt.Errorf( return RuntimeConfig{}, fmt.Errorf(
"proxy_min_port must be less than proxy_max_port. To disable, set both to zero.") "proxy_min_port must be less than proxy_max_port. To disable, set both to zero.")