LGTM, thanks
On Tue, May 14, 2013 at 6:28 PM, Michele Tartara <[email protected]>wrote: > The Haskell ConfD client was assuming internet addresses to be IPv4. This > patch modifies the client so that it is able to automatically detect the > protocol it should use by analyzing the address it is told to connect to. > > Signed-off-by: Michele Tartara <[email protected]> > --- > src/Ganeti/Confd/Client.hs | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/src/Ganeti/Confd/Client.hs b/src/Ganeti/Confd/Client.hs > index d7a5ea0..8bd7613 100644 > --- a/src/Ganeti/Confd/Client.hs > +++ b/src/Ganeti/Confd/Client.hs > @@ -42,6 +42,7 @@ import Ganeti.Confd.Utils > import qualified Ganeti.Constants as C > import Ganeti.Hash > import Ganeti.Ssconf > +import Ganeti.Utils > > -- | Builds a properly initialized ConfdClient. > -- The parameters (an IP address and the port number for the Confd client > @@ -117,9 +118,11 @@ queryOneServer semaphore answer crType cQuery hmac > (host, port) = do > let signedMsg = > signMessage hmac timestamp (J.encodeStrict request) > completeMsg = C.confdMagicFourcc ++ J.encodeStrict signedMsg > - s <- S.socket S.AF_INET S.Datagram S.defaultProtocol > - hostAddr <- S.inet_addr host > - _ <- S.sendTo s completeMsg $ S.SockAddrInet port hostAddr > + addr <- resolveAddr (fromIntegral port) host > + (af_family, sockaddr) <- > + exitIfBad "Unable to resolve the IP address" addr > + s <- S.socket af_family S.Datagram S.defaultProtocol > + _ <- S.sendTo s completeMsg sockaddr > replyMsg <- S.recv s C.maxUdpDataSize > parsedReply <- > if C.confdMagicFourcc `isPrefixOf` replyMsg > -- > 1.7.10.4 > >
