summaryrefslogtreecommitdiff
path: root/Assistant/Threads
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-09-08 15:30:04 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-09-08 15:30:04 -0400
commit5401b9f2497c7719dfe65d9d576f645bec282785 (patch)
treed7d1d469c066a05b890082e5a04756400844dbf6 /Assistant/Threads
parent61ee1e16602900b279b96eb6e53192b1181ad581 (diff)
filter out our own pairing requests
Due to being multicast, requests sent by one thread are received by the listener in another thread.
Diffstat (limited to 'Assistant/Threads')
-rw-r--r--Assistant/Threads/PairListener.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/Assistant/Threads/PairListener.hs b/Assistant/Threads/PairListener.hs
index bb9ab6d0f..58d8fd969 100644
--- a/Assistant/Threads/PairListener.hs
+++ b/Assistant/Threads/PairListener.hs
@@ -39,13 +39,18 @@ pairListenerThread st dstatus = thread $ withSocketsDo $ do
chunksz = 1024
dispatch Nothing = noop
- dispatch (Just (PairReqM (PairReq r))) = void $ do
- let pairdata = verifiableVal r
+ dispatch (Just (PairReqM (PairReq v))) = unlessM (mypair v) $ do
+ let pairdata = verifiableVal v
let repo = remoteUserName pairdata ++ "@" ++
fromMaybe (showAddr $ remoteAddress pairdata)
(remoteHostName pairdata)
let msg = repo ++ " is sending a pair request."
{- Pair request alerts from the same host combine,
- so repeated requests do not add additional alerts. -}
- addAlert dstatus $ pairRequestAlert repo msg
+ void $ addAlert dstatus $ pairRequestAlert repo msg
dispatch (Just (PairAckM _)) = noop -- TODO
+
+ {- Filter out our own pair requests, by checking if we
+ - can verify using the secrets of any of them. -}
+ mypair v = any (verified v . inProgressSecret) . pairingInProgress
+ <$> getDaemonStatus dstatus