From 497f5cbff8440ecbfb697051950b505b353f6ddf Mon Sep 17 00:00:00 2001 From: Michele Tartara <mtartara@google.com> Date: Mon, 17 Dec 2012 14:51:11 +0000 Subject: [PATCH] Rename the Confd utils parseMessage function to parseRequest With the upcoming implementation of the Haskell Confd client, requests will no longer be the only kind of message to be parsed, therefore the parsing function for requests is being renamed to be more specific, and to better fit with the upcoming parseReply. Signed-off-by: Michele Tartara <mtartara@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- htest/Test/Ganeti/Confd/Utils.hs | 4 ++-- htools/Ganeti/Confd/Server.hs | 2 +- htools/Ganeti/Confd/Utils.hs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htest/Test/Ganeti/Confd/Utils.hs b/htest/Test/Ganeti/Confd/Utils.hs index 38b9dc37b..8c1590e01 100644 --- a/htest/Test/Ganeti/Confd/Utils.hs +++ b/htest/Test/Ganeti/Confd/Utils.hs @@ -59,8 +59,8 @@ prop_req_sign key (NonNegative timestamp) (Positive bad_delta) good_timestamp = timestamp + if pm then good_delta else (-good_delta) bad_delta' = fromIntegral C.confdMaxClockSkew + bad_delta bad_timestamp = timestamp + if pm then bad_delta' else (-bad_delta') - ts_ok = Confd.Utils.parseMessage key signed good_timestamp - ts_bad = Confd.Utils.parseMessage key signed bad_timestamp + ts_ok = Confd.Utils.parseRequest key signed good_timestamp + ts_bad = Confd.Utils.parseRequest key signed bad_timestamp in printTestCase "Failed to parse good message" (ts_ok ==? BasicTypes.Ok (encoded, crq)) .&&. printTestCase ("Managed to deserialise message with bad\ diff --git a/htools/Ganeti/Confd/Server.hs b/htools/Ganeti/Confd/Server.hs index 4ca0014c7..a7e52a17a 100644 --- a/htools/Ganeti/Confd/Server.hs +++ b/htools/Ganeti/Confd/Server.hs @@ -459,7 +459,7 @@ onInotify inotify path cref mstate _ = responder :: CRef -> S.Socket -> HashKey -> String -> S.SockAddr -> IO () responder cfgref socket hmac msg peer = do ctime <- getCurrentTime - case parseMessage hmac msg ctime of + case parseRequest hmac msg ctime of Ok (origmsg, rq) -> do logDebug $ "Processing request: " ++ rStripSpace origmsg mcfg <- readIORef cfgref diff --git a/htools/Ganeti/Confd/Utils.hs b/htools/Ganeti/Confd/Utils.hs index 28fba0653..d19c9cfd6 100644 --- a/htools/Ganeti/Confd/Utils.hs +++ b/htools/Ganeti/Confd/Utils.hs @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA module Ganeti.Confd.Utils ( getClusterHmac , parseSignedMessage - , parseMessage + , parseRequest , signMessage , getCurrentTime ) where @@ -67,9 +67,9 @@ parseSignedMessage key str = do -- | Message parsing. This can either result in a good, valid message, -- or fail in the Result monad. -parseMessage :: HashKey -> String -> Integer +parseRequest :: HashKey -> String -> Integer -> Result (String, ConfdRequest) -parseMessage hmac msg curtime = do +parseRequest hmac msg curtime = do (salt, origmsg, request) <- parseSignedMessage hmac msg ts <- tryRead "Parsing timestamp" salt::Result Integer if abs (ts - curtime) > maxClockSkew -- GitLab