filter out our own pairing requests
Due to being multicast, requests sent by one thread are received by the listener in another thread.
This commit is contained in:
parent
61ee1e1660
commit
5401b9f249
2 changed files with 12 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue