summaryrefslogtreecommitdiff
path: root/src/Propellor/Server.hs
diff options
context:
space:
mode:
authorJoey Hess2014-11-22 15:01:08 -0400
committerJoey Hess2014-11-22 15:01:08 -0400
commit0b9164e286911a2e1d594f0c4561737e2d5416af (patch)
treece6a8d9f05181865d694d2aa0c3e73b59b757a52 /src/Propellor/Server.hs
parentfdde4d91c7dda15dcc4eee5fc91859c0e1a45b9b (diff)
propellor spin
Diffstat (limited to 'src/Propellor/Server.hs')
-rw-r--r--src/Propellor/Server.hs17
1 files changed, 13 insertions, 4 deletions
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 =