packages feed

lambdabot-core 5.1.0.4 → 5.2

raw patch · 3 files changed

+52/−6 lines, 3 filesdep +network-bsddep ~dependent-sumdep ~haskelinedep ~network

Dependencies added: network-bsd

Dependency ranges changed: dependent-sum, haskeline, network, regex-tdfa

Files

lambdabot-core.cabal view
@@ -1,5 +1,5 @@ name:                   lambdabot-core-version:                5.1.0.4+version:                5.2  license:                GPL license-file:           LICENSE@@ -19,7 +19,7 @@  build-type:             Simple cabal-version:          >= 1.8-tested-with:            GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.1+tested-with:            GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5  extra-source-files:     AUTHORS.md                         COMMENTARY.md@@ -53,6 +53,7 @@                         Lambdabot.Plugin.Core                         Lambdabot.State                         Lambdabot.Util+                        Lambdabot.Util.Network    other-modules:        Paths_lambdabot_core                         Lambdabot.Config.Core@@ -71,7 +72,7 @@                         bytestring              >= 0.9,                         containers              >= 0.4,                         dependent-map           == 0.2.*,-                        dependent-sum           >= 0.3 && < 0.5,+                        dependent-sum           >= 0.3 && < 0.6,                         dependent-sum-template  >= 0.0.0.1,                         directory               >= 1.1,                         edit-distance           >= 0.2,@@ -82,8 +83,8 @@                         lifted-base             >= 0.2,                         monad-control           >= 1.0,                         mtl                     >= 2,-                        network                 >= 2.3.0.13,-                        time                    >= 1.4,+                        network                 >= 2.7 && < 3.2,+                        network-bsd             >= 2.8 && < 2.9,                         parsec                  >= 3,                         prim-uniq               == 0.1.*,                         random                  >= 1,@@ -94,6 +95,7 @@                         split                   >= 0.2,                         syb                     >= 0.3,                         template-haskell        >= 2.7,+                        time                    >= 1.4,                         transformers            >= 0.2,                         transformers-base       >= 0.4,                         utf8-string             >= 0.3,
src/Lambdabot/Main.hs view
@@ -36,7 +36,7 @@ import System.Log.Formatter import qualified System.Log.Logger as L import System.Log.Handler.Simple-import Network (withSocketsDo)+import Network.Socket (withSocketsDo)  lambdabotVersion :: Version lambdabotVersion = version
+ src/Lambdabot/Util/Network.hs view
@@ -0,0 +1,44 @@+{-# LANGUAGE CPP #-}++module Lambdabot.Util.Network (+    connectTo',+) where++import Network.Socket+import Network.BSD+import System.IO+import Control.Exception++-- |This is essentially a reimplementation of the former Network.connectTo+--  function, except that we don't do the service name lookup.++-- Code originally from the network package.+connectTo' :: HostName -> PortNumber -> IO Handle+connectTo' host port = do+    proto <- getProtocolNumber "tcp"+    let hints = defaultHints { addrFlags = [AI_ADDRCONFIG]+                             , addrProtocol = proto+                             , addrSocketType = Stream }+    addrs <- getAddrInfo (Just hints) (Just host) (Just (show port))+    firstSuccessful $ map tryToConnect addrs+  where+    tryToConnect addr =+      bracketOnError+          (socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr))+          (close)  -- only done if there's an error+          (\sock -> do+            connect sock (addrAddress addr)+            socketToHandle sock ReadWriteMode+          )+    firstSuccessful = go []+      where+        go :: [IOException] -> [IO a] -> IO a+        go []      [] = ioError . userError $ "host name `" ++ show host +++                        "` could not be resolved"+        go l@(_:_) [] = ioError . userError $ "could not connect to host `" +++                        show host+        go acc     (act:followingActs) = do+            er <- try act+            case er of+                Left err -> go (err:acc) followingActs+                Right r  -> return r