From 71f8dde4f3b7d7cd2274c3bcf235287457969095 Mon Sep 17 00:00:00 2001 From: joe Date: Fri, 8 Jun 2018 22:10:26 -0400 Subject: Bittorrent: Fix build of tracker-related modules. --- .../src/Network/BitTorrent/Tracker/Message.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'bittorrent/src/Network/BitTorrent/Tracker/Message.hs') diff --git a/bittorrent/src/Network/BitTorrent/Tracker/Message.hs b/bittorrent/src/Network/BitTorrent/Tracker/Message.hs index b9b6a9d3..e01ebbf4 100644 --- a/bittorrent/src/Network/BitTorrent/Tracker/Message.hs +++ b/bittorrent/src/Network/BitTorrent/Tracker/Message.hs @@ -404,8 +404,8 @@ parseAnnounceQuery params = AnnounceQuery -- For more info see: -- data PeerList ip - = PeerList [PeerAddr IP] - | CompactPeerList [PeerAddr ip] + = PeerList [PeerAddr] + | CompactPeerList [PeerAddr] deriving (Show, Eq, Typeable, Functor) -- | The empty non-compact peer list. @@ -413,11 +413,11 @@ instance Default (PeerList IP) where def = PeerList [] {-# INLINE def #-} -getPeerList :: PeerList IP -> [PeerAddr IP] +getPeerList :: PeerList IP -> [PeerAddr] getPeerList (PeerList xs) = xs getPeerList (CompactPeerList xs) = xs -instance Serialize a => BEncode (PeerList a) where +instance BEncode (PeerList a) where toBEncode (PeerList xs) = toBEncode xs toBEncode (CompactPeerList xs) = toBEncode $ runPut (mapM_ put xs) @@ -491,10 +491,10 @@ instance BEncode AnnounceInfo where | L.null v6s = (CompactPeerList v4s, Nothing) | otherwise = (CompactPeerList v4s, Just (CompactPeerList v6s)) - toEither :: PeerAddr IP -> Either (PeerAddr IPv4) (PeerAddr IPv6) + toEither :: PeerAddr -> Either PeerAddr PeerAddr toEither PeerAddr {..} = case peerHost of - IPv4 ipv4 -> Left $ PeerAddr peerId ipv4 peerPort - IPv6 ipv6 -> Right $ PeerAddr peerId ipv6 peerPort + ipv4@IPv4{} -> Left $ PeerAddr peerId ipv4 peerPort + ipv6@IPv6{} -> Right $ PeerAddr peerId ipv6 peerPort fromBEncode (BDict d) | Just t <- BE.lookup "failure reason" d = Failure <$> fromBEncode t @@ -514,7 +514,7 @@ instance BEncode AnnounceInfo where \but the `peers6' field present" merge (CompactPeerList ipv4s) Nothing - = pure $ CompactPeerList (fmap IPv4 <$> ipv4s) + = pure $ CompactPeerList ipv4s merge (CompactPeerList _ ) (Just (PeerList _)) = fail "PeerList: the `peers6' field value \ @@ -522,7 +522,7 @@ instance BEncode AnnounceInfo where merge (CompactPeerList ipv4s) (Just (CompactPeerList ipv6s)) = pure $ CompactPeerList $ - (fmap IPv4 <$> ipv4s) <> (fmap IPv6 <$> ipv6s) + ipv4s <> ipv6s fromBEncode _ = decodingError "Announce info" @@ -533,13 +533,13 @@ instance Serialize AnnounceInfo where putWord32be $ fromIntegral respInterval putWord32be $ fromIntegral $ fromMaybe 0 respIncomplete putWord32be $ fromIntegral $ fromMaybe 0 respComplete - forM_ (fmap ipv4 <$> getPeerList respPeers) put + forM_ (getPeerList respPeers) put get = do interval <- getWord32be leechers <- getWord32be seeders <- getWord32be - peers <- many $ fmap IPv4 <$> get + peers <- many $ isolate 6 get -- isolated to specify IPv4. return $ AnnounceInfo { respWarning = Nothing -- cgit v1.2.3