aboutsummaryrefslogtreecommitdiff
path: root/Assistant/Types
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-30 13:22:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-30 13:22:55 -0400
commitd12b1fb179bc1744f813ea3f616d503d2b0dfe09 (patch)
treedd4087ad7f6bf5883877c1c37e6a11c89cc5f46a /Assistant/Types
parenteba8c5d2610dd916401312e590fab2dcb713548c (diff)
add uuid to all xmpp messages
(Except for the actual streaming of receive-pack through XMPP, which can only run once we've gotten an appropriate uuid in a push initiation message.) Pushes are now only initiated when the initiation message comes from a known uuid. This allows multiple distinct repositories to use the same xmpp address. Note: This probably breaks initial push after xmpp pairing, because at that point we may not know about the paired uuid, and so reject the push from it. It won't break in simple cases, because the annex-uuid of the remote is checked. However, when there are multiple clients behind a single xmpp address, only uuid of the first is recorded in annex-uuid, and so any pushes from the others will be rejected (unless the first remote pushes their uuids to us beforehand.
Diffstat (limited to 'Assistant/Types')
-rw-r--r--Assistant/Types/NetMessager.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/Assistant/Types/NetMessager.hs b/Assistant/Types/NetMessager.hs
index e0dcbbb56..09a558033 100644
--- a/Assistant/Types/NetMessager.hs
+++ b/Assistant/Types/NetMessager.hs
@@ -37,11 +37,11 @@ type ClientID = Text
data PushStage
-- indicates that we have data to push over the out of band network
- = CanPush
+ = CanPush UUID
-- request that a git push be sent over the out of band network
- | PushRequest
+ | PushRequest UUID
-- indicates that a push is starting
- | StartingPush
+ | StartingPush UUID
-- a chunk of output of git receive-pack
| ReceivePackOutput SequenceNum ByteString
-- a chuck of output of git send-pack
@@ -58,8 +58,8 @@ type SequenceNum = Int
{- NetMessages that are important (and small), and should be stored to be
- resent when new clients are seen. -}
isImportantNetMessage :: NetMessage -> Maybe ClientID
-isImportantNetMessage (Pushing c CanPush) = Just c
-isImportantNetMessage (Pushing c PushRequest) = Just c
+isImportantNetMessage (Pushing c (CanPush _)) = Just c
+isImportantNetMessage (Pushing c (PushRequest _)) = Just c
isImportantNetMessage _ = Nothing
readdressNetMessage :: NetMessage -> ClientID -> NetMessage
@@ -85,18 +85,18 @@ logClientID c = T.concat [T.take 1 c, T.pack $ show $ T.length c]
{- Things that initiate either side of a push, but do not actually send data. -}
isPushInitiation :: PushStage -> Bool
-isPushInitiation CanPush = True
-isPushInitiation PushRequest = True
-isPushInitiation StartingPush = True
+isPushInitiation (CanPush _) = True
+isPushInitiation (PushRequest _) = True
+isPushInitiation (StartingPush _) = True
isPushInitiation _ = False
data PushSide = SendPack | ReceivePack
deriving (Eq, Ord)
pushDestinationSide :: PushStage -> PushSide
-pushDestinationSide CanPush = ReceivePack
-pushDestinationSide PushRequest = SendPack
-pushDestinationSide StartingPush = ReceivePack
+pushDestinationSide (CanPush _) = ReceivePack
+pushDestinationSide (PushRequest _) = SendPack
+pushDestinationSide (StartingPush _) = ReceivePack
pushDestinationSide (ReceivePackOutput _ _) = SendPack
pushDestinationSide (SendPackOutput _ _) = ReceivePack
pushDestinationSide (ReceivePackDone _) = SendPack