Revision 986a8671 src/Ganeti/Daemon.hs

b/src/Ganeti/Daemon.hs
263 263
      Socket.SockAddrInet6 (fromIntegral port) 0 Socket.iN6ADDR_ANY 0)
264 264
defaultBindAddr _ fam = Bad $ "Unsupported address family: " ++ show fam
265 265

  
266
-- | Default hints for the resolver
267
resolveAddrHints :: Maybe Socket.AddrInfo
268
resolveAddrHints =
269
  Just Socket.defaultHints { Socket.addrFlags = [Socket.AI_NUMERICHOST,
270
                                                 Socket.AI_NUMERICSERV] }
271

  
272
-- | Resolves a numeric address.
273
resolveAddr :: Int -> String -> IO (Result (Socket.Family, Socket.SockAddr))
274
resolveAddr port str = do
275
  resolved <- Socket.getAddrInfo resolveAddrHints (Just str) (Just (show port))
276
  return $ case resolved of
277
             [] -> Bad "Invalid results from lookup?"
278
             best:_ -> Ok (Socket.addrFamily best, Socket.addrAddress best)
279

  
280 266
-- | Based on the options, compute the socket address to use for the
281 267
-- daemon.
282 268
parseAddress :: DaemonOptions      -- ^ Command line options

Also available in: Unified diff