@@ -65,9 +65,16 @@ instance Semigroup CommonOptions where
6565 (re1 <|> re2)
6666 (ra1 <|> ra2)
6767
68+ -- | The control socket the client connects to when neither @--control-address@
69+ -- nor @KES_AGENT_CONTROL_PATH@ is supplied. Applied as the final fallback in
70+ -- 'mkControlClientOptions', consistent with how the other option defaults are
71+ -- resolved at the point of use.
72+ defaultControlSocketPath :: FilePath
73+ defaultControlSocketPath = " /tmp/kes-agent-control.socket"
74+
6875defCommonOptions :: CommonOptions =
6976 CommonOptions
70- { optControlPath = Just " /tmp/kes-agent-control.socket "
77+ { optControlPath = Nothing
7178 , optVerbosity = Just 0
7279 , optRetryDelay = Nothing
7380 , optRetryExponential = Nothing
@@ -373,7 +380,7 @@ formatReason RecvErrorUnknown = "unknown error"
373380
374381mkControlClientOptions :: CommonOptions -> IOManager -> IO (ControlClientOptions IO Socket SockAddr )
375382mkControlClientOptions opts ioManager = do
376- controlPath <- maybe ( error " No control address " ) return (optControlPath opts)
383+ let controlPath = fromMaybe defaultControlSocketPath (optControlPath opts)
377384
378385 let retryDelay = fromMaybe 1000 $ optRetryDelay opts
379386 let retryExponential = fromMaybe False $ optRetryExponential opts
@@ -522,7 +529,7 @@ runGetInfo opt' = withIOManager $ \ioManager -> do
522529 let cPutStrLn = hcPutStrLn cmode stdout
523530 cPutStrLn (bold defaultColor) $ printf " --- Agent ---"
524531 printf " Agent version: %s\n " $ fromMaybe " <unknown>" (agentInfoProgramVersion info)
525- printf " Connected via: %s\n " $ fromMaybe " <unknown> " (optControlPath opt' )
532+ printf " Connected via: %s\n " $ fromMaybe defaultControlSocketPath (optControlPath opt)
526533 printf " Current time: %s\n " $ show (agentInfoCurrentTime info)
527534 printf " Current KES period: %u\n " (unKESPeriod $ agentInfoCurrentKESPeriod info)
528535 printf " Current KES period started: %s\n " $
0 commit comments