diff --git a/CHANGELOG.md b/CHANGELOG.md index d00df87..debfd87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for sensu-run +## 0.5.0.1 -- 2018-04-30 + +* Relax upper version bound for network and fix a warning + ## 0.5.0 -- 2018-04-20 * Add support for HTTPS (#18) diff --git a/sensu-run.cabal b/sensu-run.cabal index abdfa8d..50e984b 100644 --- a/sensu-run.cabal +++ b/sensu-run.cabal @@ -1,5 +1,5 @@ name: sensu-run -version: 0.5.0 +version: 0.5.0.1 synopsis: A tool to send command execution results to Sensu description: @sensu-run@ is a command line tool to send command execution results to Sensu @@ -34,7 +34,7 @@ executable sensu-run , http-client-tls < 0.4 , http-types >= 0.9.1 && < 0.13 , lens >= 4.15 && < 4.17 - , network >= 2.2.3 && < 2.7 + , network >= 2.2.3 && < 2.8 , optparse-applicative >= 0.12 && < 0.15 , process >= 1.4 && < 1.7 , temporary >= 1.1 && < 1.4 diff --git a/sensu-run.hs b/sensu-run.hs index 2629425..f1937cc 100644 --- a/sensu-run.hs +++ b/sensu-run.hs @@ -123,16 +123,23 @@ sendToClientSocketInput -> BL8.ByteString -- ^ Payload -> IO () sendToClientSocketInput port payload = bracket open close $ \sock -> do - localhost <- inet_addr "127.0.0.1" - connect sock $ SockAddrInet port localhost - Socket.sendAll sock payload - `catch` \(ioe :: IOException) -> do - hPutStrLn stderr $ - "Failed to write results to localhost:" ++ show port - ++ " (" ++ show ioe ++ ")" - exitFailure + info <- getAddrInfo (Just hints) (Just "127.0.0.1") (Just $ show port) + case info of + [] -> ioError $ userError "sendToClientSocketInput: failed to get AddrInfo" + localhost:_ -> do + connect sock $ addrAddress localhost + Socket.sendAll sock payload + `catch` \(ioe :: IOException) -> do + hPutStrLn stderr $ + "Failed to write results to localhost:" ++ show port + ++ " (" ++ show ioe ++ ")" + exitFailure where open = socket AF_INET Stream defaultProtocol + hints = defaultHints + { addrFamily = AF_INET + , addrSocketType = Stream + } sendToSensuServer :: NonEmpty String -- ^ Sensu server base URLs