build fix from https://bugzilla.redhat.com/show_bug.cgi?id=1853122 1.0.0
authorJens Petersen
Mon, 12 Sep 2022 12:50:37 -0400
branch1.0.0
changeset 15883 9d4ba1912e71
parent 15882 acfa0869b579
child 15884 c96220666d93
build fix from https://bugzilla.redhat.com/show_bug.cgi?id=1853122
gameServer/Actions.hs
gameServer/CMakeLists.txt
gameServer/ClientIO.hs
gameServer/CoreTypes.hs
gameServer/OfficialServer/checker.hs
gameServer/Utils.hs
gameServer/hedgewars-server.cabal
gameServer/hedgewars-server.hs
--- a/gameServer/Actions.hs	Mon Sep 12 10:44:55 2022 -0400
+++ b/gameServer/Actions.hs	Mon Sep 12 12:50:37 2022 -0400
@@ -709,7 +709,7 @@
         args <- gets (runArgs . serverInfo)
         io $ do
             noticeM "Core" "Closing listening socket"
-            sClose sock
+            close sock
             noticeM "Core" "Spawning new server"
             _ <- createProcess (proc "./hedgewars-server" args)
             return ()
--- a/gameServer/CMakeLists.txt	Mon Sep 12 10:44:55 2022 -0400
+++ b/gameServer/CMakeLists.txt	Mon Sep 12 12:50:37 2022 -0400
@@ -9,7 +9,8 @@
 check_haskell_package_exists(containers "Data.Map" size 1)
 check_haskell_package_exists(vector "Data.Vector" length 1)
 check_haskell_package_exists(bytestring "Data.ByteString" pack 1)
-check_haskell_package_exists(network "Network.BSD" getHostName 0)
+check_haskell_package_exists(network "Network.Socket" defaultHints 0)
+check_haskell_package_exists(network-bsd "Network.BSD" getHostName 0)
 check_haskell_package_exists(time "Data.Time" getCurrentTime 0)
 check_haskell_package_exists(mtl "Control.Monad.State" fix 1)
 check_haskell_package_exists(sandi "Codec.Binary.Base64" encode 1)
--- a/gameServer/ClientIO.hs	Mon Sep 12 10:44:55 2022 -0400
+++ b/gameServer/ClientIO.hs	Mon Sep 12 12:50:37 2022 -0400
@@ -23,7 +23,7 @@
 import Control.Monad.State
 import Control.Concurrent.Chan
 import Control.Concurrent
-import Network
+import Network.Socket hiding (recv)
 import Network.Socket.ByteString
 import qualified Data.ByteString.Char8 as B
 ----------------
@@ -90,7 +90,7 @@
             sendAll s $ B.unlines answer `B.snoc` '\n'
 
     if isQuit answer then
-        sClose s
+        close s
         else
         clientSendLoop s tId chan ci
 
--- a/gameServer/CoreTypes.hs	Mon Sep 12 10:44:55 2022 -0400
+++ b/gameServer/CoreTypes.hs	Mon Sep 12 12:50:37 2022 -0400
@@ -23,7 +23,7 @@
 import Data.Word
 import qualified Data.Map as Map
 import Data.Time
-import Network
+import Network.Socket
 import Data.Function
 import Data.ByteString.Char8 as B
 import Data.Unique
--- a/gameServer/OfficialServer/checker.hs	Mon Sep 12 10:44:55 2022 -0400
+++ b/gameServer/OfficialServer/checker.hs	Mon Sep 12 12:50:37 2022 -0400
@@ -28,8 +28,7 @@
 import Control.Monad.State
 import Control.Concurrent.Chan
 import Control.Concurrent
-import Network
-import Network.BSD
+import Network.BSD hiding (recv)
 import Network.Socket hiding (recv, sClose)
 import Network.Socket.ByteString
 import qualified Data.ByteString.Char8 as B
@@ -207,7 +206,7 @@
 
     Exception.bracket
         setupConnection
-        (\s -> noticeM "Core" "Shutting down" >> sClose s)
+        (\s -> noticeM "Core" "Shutting down" >> close s)
         (session login password (d ++ "/.hedgewars") exeFullname dataPrefix)
     where
         setupConnection = do
--- a/gameServer/Utils.hs	Mon Sep 12 10:44:55 2022 -0400
+++ b/gameServer/Utils.hs	Mon Sep 12 12:50:37 2022 -0400
@@ -41,11 +41,7 @@
 
 
 sockAddr2String :: SockAddr -> IO B.ByteString
-sockAddr2String (SockAddrInet _ hostAddr) = liftM B.pack $ inet_ntoa hostAddr
-sockAddr2String (SockAddrInet6 _ _ (a, b, c, d) _) =
-    return $ B.pack $ (foldr1 (.)
-        $ List.intersperse (':':)
-        $ concatMap (\n -> (\(a0, a1) -> [showHex a0, showHex a1]) $ divMod n 65536) [a, b, c, d]) []
+sockAddr2String = liftM (B.pack . fromJust . fst) . getNameInfo [] True False
 
 maybeRead :: Read a => String -> Maybe a
 maybeRead s = case reads s of
--- a/gameServer/hedgewars-server.cabal	Mon Sep 12 10:44:55 2022 -0400
+++ b/gameServer/hedgewars-server.cabal	Mon Sep 12 12:50:37 2022 -0400
@@ -57,7 +57,8 @@
     containers,
     vector,
     bytestring,
-    network >= 2.3 && < 3.0,
+    network >= 2.3,
+    network-bsd,
     mtl >= 2,
     sandi,
     hslogger,
--- a/gameServer/hedgewars-server.hs	Mon Sep 12 10:44:55 2022 -0400
+++ b/gameServer/hedgewars-server.hs	Mon Sep 12 12:50:37 2022 -0400
@@ -50,10 +50,11 @@
     proto <- getProtocolNumber "tcp"
     E.bracket
         (socket AF_INET Stream proto)
-        sClose
+        close
         (\sock -> do
             setSocketOption sock ReuseAddr 1
-            bindSocket sock (SockAddrInet (listenPort si) iNADDR_ANY)
+            iNADDR_ANY <- addrAddress . head <$> getAddrInfo Nothing (Just "0") (Just (show (listenPort si)))
+            bind sock iNADDR_ANY
             listen sock maxListenQueue
             startServer si{serverSocket = Just sock}
         )