summaryrefslogtreecommitdiff
path: root/internal/configuration/deprecation.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2024-09-20 11:11:53 +1000
committerGitHub <noreply@github.com>2024-09-20 11:11:53 +1000
commitc0d4dd9c9499b7e9b0f83c47396aa6a7da3424db (patch)
tree2d5ca23021aacac96d656b680eb57cab00b1617e /internal/configuration/deprecation.go
parent346acdcf43f715473874c7033421df04f7232e63 (diff)
refactor: linting (#7863)
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Diffstat (limited to 'internal/configuration/deprecation.go')
-rw-r--r--internal/configuration/deprecation.go14
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)
}
}