Commit 199b241c authored by Michele Tartara's avatar Michele Tartara

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
...@@ -42,6 +42,7 @@ import Ganeti.Confd.Utils ...@@ -42,6 +42,7 @@ import Ganeti.Confd.Utils
import qualified Ganeti.Constants as C import qualified Ganeti.Constants as C
import Ganeti.Hash import Ganeti.Hash
import Ganeti.Ssconf import Ganeti.Ssconf
import Ganeti.Utils
-- | Builds a properly initialized ConfdClient. -- | Builds a properly initialized ConfdClient.
-- The parameters (an IP address and the port number for the Confd client -- 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 ...@@ -117,9 +118,11 @@ queryOneServer semaphore answer crType cQuery hmac (host, port) = do
let signedMsg = let signedMsg =
signMessage hmac timestamp (J.encodeStrict request) signMessage hmac timestamp (J.encodeStrict request)
completeMsg = C.confdMagicFourcc ++ J.encodeStrict signedMsg completeMsg = C.confdMagicFourcc ++ J.encodeStrict signedMsg
s <- S.socket S.AF_INET S.Datagram S.defaultProtocol addr <- resolveAddr (fromIntegral port) host
hostAddr <- S.inet_addr host (af_family, sockaddr) <-
_ <- S.sendTo s completeMsg $ S.SockAddrInet port hostAddr 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 replyMsg <- S.recv s C.maxUdpDataSize
parsedReply <- parsedReply <-
if C.confdMagicFourcc `isPrefixOf` replyMsg if C.confdMagicFourcc `isPrefixOf` replyMsg
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment