Skip to content

Commit

Permalink
Merge branch 'release/v0.5.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitsutoshi Aoe committed Apr 30, 2018
2 parents 5ab6d1b + 20879ee commit 69cb5b9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions sensu-run.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
23 changes: 15 additions & 8 deletions sensu-run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 69cb5b9

Please sign in to comment.