runtime: reject out-of-range HA_METRICS_PORT values

This commit is contained in:
2026-09-15 22:27:20 +03:00
parent 319104641b
commit 9fda48f589
+3 -1
View File
@@ -86,7 +86,9 @@ lookupPort = do
m <- lookupEnv "HA_METRICS_PORT" m <- lookupEnv "HA_METRICS_PORT"
case m of case m of
Nothing -> pure 8124 Nothing -> pure 8124
Just s -> maybe (fail ("HA_METRICS_PORT is not a number: " <> s)) pure (readMaybe s) Just s -> case readMaybe s of
Just p | p >= 1 && p <= 65535 -> pure p
_ -> fail ("HA_METRICS_PORT must be a port in 1..65535: " <> s)
defaultMain :: IO () defaultMain :: IO ()
defaultMain = withSocketsDo $ do defaultMain = withSocketsDo $ do