summaryrefslogtreecommitdiff
path: root/Assistant/Threads/XMPPClient.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-30 17:36:03 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-30 17:38:58 -0400
commit1ab83814a0838a237e381a615e2e40ee9c675077 (patch)
tree306a09143daca0bf4ff28f9e5f780d6923629773 /Assistant/Threads/XMPPClient.hs
parente6625dd99136455ab319b1b50e625668e58ade23 (diff)
avoid auto-accepting pair requests from friends already paired with
Unless the request is for repo uuid we already know. This way, if A1 pairs with friend B1, and B1 pairs with device B2, then B1 can request A1 pair with it and no confirmation is needed. (In future, may want to try to do that automatically, to make a more robust network.)
Diffstat (limited to 'Assistant/Threads/XMPPClient.hs')
-rw-r--r--Assistant/Threads/XMPPClient.hs18
1 files changed, 13 insertions, 5 deletions
diff --git a/Assistant/Threads/XMPPClient.hs b/Assistant/Threads/XMPPClient.hs
index 2f4f57d9a..086494a74 100644
--- a/Assistant/Threads/XMPPClient.hs
+++ b/Assistant/Threads/XMPPClient.hs
@@ -25,6 +25,7 @@ import Assistant.Alert
import Assistant.Pairing
import Assistant.XMPP.Git
import Annex.UUID
+import Logs.UUID
import Network.Protocol.XMPP
import Control.Concurrent
@@ -282,19 +283,26 @@ pull us = do
unlessM (null . fst <$> manualPull branch [r]) $
pullone rs branch
+{- PairReq from another client using our JID is automatically
+ - accepted. This is so pairing devices all using the same XMPP
+ - account works without confirmations.
+ -
+ - Also, autoaccept PairReq from the same JID of any repo we've
+ - already paired with, as long as the UUID in the PairReq is
+ - one we know about.
+-}
pairMsgReceived :: UrlRenderer -> PairStage -> UUID -> JID -> JID -> Assistant ()
pairMsgReceived urlrenderer PairReq theiruuid selfjid theirjid
| baseJID selfjid == baseJID theirjid = autoaccept
| otherwise = do
knownjids <- catMaybes . map (parseJID . getXMPPClientID)
. filter isXMPPRemote . syncRemotes <$> getDaemonStatus
- if any (== baseJID theirjid) knownjids
+ um <- liftAnnex uuidMap
+ if any (== baseJID theirjid) knownjids && M.member theiruuid um
then autoaccept
else showalert
where
- -- PairReq from another client using our JID, or the JID of
- -- any repo we're already paired with is automatically accepted.
autoaccept = do
selfuuid <- liftAnnex getUUID
sendNetMessage $
@@ -309,9 +317,9 @@ pairMsgReceived urlrenderer PairReq theiruuid selfjid theirjid
(T.unpack $ buddyName theirjid)
button
+{- PairAck must come from one of the buddies we are pairing with;
+ - don't pair with just anyone. -}
pairMsgReceived _ PairAck theiruuid _selfjid theirjid =
- {- PairAck must come from one of the buddies we are pairing with;
- - don't pair with just anyone. -}
whenM (isBuddyPairing theirjid) $ do
changeBuddyPairing theirjid False
selfuuid <- liftAnnex getUUID