summaryrefslogtreecommitdiff
path: root/src/Erebos/Network/Protocol.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-07-26 09:07:01 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2026-07-31 22:06:16 +0200
commit2d1b098f4dee1fa7aac7a81c7b3a43e2dadd351b (patch)
tree50e4fef7bf91b6a5e123a87664624a8048c44263 /src/Erebos/Network/Protocol.hs
parentf8c856864eba8186b19a7b4ebb61866d95f9e65a (diff)
Network: ignore connection attempts to selfHEADmaster
Diffstat (limited to 'src/Erebos/Network/Protocol.hs')
-rw-r--r--src/Erebos/Network/Protocol.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/Erebos/Network/Protocol.hs b/src/Erebos/Network/Protocol.hs
index c0dff4b..f015db6 100644
--- a/src/Erebos/Network/Protocol.hs
+++ b/src/Erebos/Network/Protocol.hs
@@ -738,18 +738,20 @@ processPacket gs@GlobalState {..} econn secure packet@(TransportPacket (Transpor
_ -> return Nothing
-- Initiation packet
- | _:_ <- mapMaybe (\case Initiation x -> Just x; _ -> Nothing) header
+ | _ : _ <- mapMaybe (\case Initiation x -> Just x; _ -> Nothing) header
+ , pids <- mapMaybe (\case AnnounceSelf x -> Just x; _ -> Nothing) header
, Just ver <- version
-> do
cookie <- createCookie gs addr
atomically $ do
identity <- fst <$> readTVar gIdentity
- let reply = BL.toStrict $ serializeObject $ transportToObject gStorage $ TransportHeader
- [ CookieSet cookie
- , AnnounceSelf $ refDigest $ storedRef $ idData identity
- , ProtocolVersion ver
- ]
- writeFlow gDataFlow (addr, reply)
+ when ((refDigest $ storedRef $ idData identity) `notElem` pids) $ do
+ let reply = BL.toStrict $ serializeObject $ transportToObject gStorage $ TransportHeader
+ [ CookieSet cookie
+ , AnnounceSelf $ refDigest $ storedRef $ idData identity
+ , ProtocolVersion ver
+ ]
+ writeFlow gDataFlow (addr, reply)
return Nothing
-- Announce packet outside any connection