Skip to content
Snippets Groups Projects
Commit 199b241c authored by Michele Tartara's avatar Michele Tartara
Browse files

Make HS ConfD client IPv6 compatible


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: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 986a8671
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment