From 0b9164e286911a2e1d594f0c4561737e2d5416af Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 22 Nov 2014 15:01:08 -0400 Subject: propellor spin --- src/Propellor/Server.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/Propellor/Server.hs') diff --git a/src/Propellor/Server.hs b/src/Propellor/Server.hs index e2d6552f..05a8856d 100644 --- a/src/Propellor/Server.hs +++ b/src/Propellor/Server.hs @@ -74,7 +74,7 @@ updateServer target relay hst connect = connect go sendRepoUrl toh loop (Just NeedPrivData) -> do - sendPrivData hn hst toh + sendPrivData hn hst toh relay loop (Just NeedGitPush) -> do sendGitUpdate hn fromh toh @@ -96,12 +96,21 @@ updateServer target relay hst connect = connect go sendRepoUrl :: Handle -> IO () sendRepoUrl toh = sendMarked toh repoUrlMarker =<< (fromMaybe "" <$> getRepoUrl) -sendPrivData :: HostName -> Host -> Handle -> IO () -sendPrivData hn hst toh = do - privdata <- show . filterPrivData hst <$> decryptPrivData +sendPrivData :: HostName -> Host -> Handle -> Maybe HostName -> IO () +sendPrivData hn hst toh target = do + privdata <- getdata void $ actionMessage ("Sending privdata (" ++ show (length privdata) ++ " bytes) to " ++ hn) $ do sendMarked toh privDataMarker privdata return True + where + getdata + | isNothing target = + show . filterPrivData hst <$> decryptPrivData + | otherwise = do + let f = privDataRelay hn + d <- readFileStrictAnyEncoding f + nukeFile f + return d sendGitUpdate :: HostName -> Handle -> Handle -> IO () sendGitUpdate hn fromh toh = -- cgit v1.2.3