diff options
Diffstat (limited to 'internal/configuration/deprecation.go')
| -rw-r--r-- | internal/configuration/deprecation.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/internal/configuration/deprecation.go b/internal/configuration/deprecation.go index 71f813301..9df309d5b 100644 --- a/internal/configuration/deprecation.go +++ b/internal/configuration/deprecation.go @@ -450,7 +450,7 @@ var deprecationsMKM = []MultiKeyMappedDeprecation{ }, } -func getHostPort(hostKey, portKey, hostFallback string, portFallback int, keys map[string]any) (host string, port int, err error) { +func getHostPort(hostKey, portKey, hostFallback string, portFallback uint16, keys map[string]any) (host string, port uint16, err error) { var ( ok bool v any @@ -462,12 +462,20 @@ func getHostPort(hostKey, portKey, hostFallback string, portFallback int, keys m if v, ok = keys[portKey]; ok { switch value := v.(type) { - case int: + case uint16: port = value + case int: + if value >= 0 && value <= 65535 { + port = uint16(value) + } case string: - if port, err = strconv.Atoi(value); err != nil { + var p uint64 + + if p, err = strconv.ParseUint(value, 10, 16); err != nil { return "", 0, fmt.Errorf("error occurred converting the port from a string: %w", err) } + + port = uint16(p) } } |
