summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bittorrent.cabal1
-rw-r--r--src/Network/BitTorrent/Exchange.hs13
-rw-r--r--src/Network/BitTorrent/Exchange/Protocol.hs4
3 files changed, 11 insertions, 7 deletions
diff --git a/bittorrent.cabal b/bittorrent.cabal
index 02130385..88a8e50d 100644
--- a/bittorrent.cabal
+++ b/bittorrent.cabal
@@ -74,6 +74,7 @@ library
74 , conduit >= 1.0 74 , conduit >= 1.0
75 , network-conduit >= 1.0 75 , network-conduit >= 1.0
76 , cereal-conduit >= 0.5 76 , cereal-conduit >= 0.5
77 , binary-conduit
77 78
78 -- Data 79 -- Data
79 , array >= 0.4 80 , array >= 0.4
diff --git a/src/Network/BitTorrent/Exchange.hs b/src/Network/BitTorrent/Exchange.hs
index 9f119d13..b0a94853 100644
--- a/src/Network/BitTorrent/Exchange.hs
+++ b/src/Network/BitTorrent/Exchange.hs
@@ -79,7 +79,8 @@ import Control.Monad.Trans.Resource
79 79
80import Data.IORef 80import Data.IORef
81import Data.Conduit as C 81import Data.Conduit as C
82import Data.Conduit.Cereal 82import Data.Conduit.Cereal as S
83import Data.Conduit.Serialization.Binary as B
83import Data.Conduit.Network 84import Data.Conduit.Network
84import Data.Serialize as S 85import Data.Serialize as S
85import Text.PrettyPrint as PP hiding (($$)) 86import Text.PrettyPrint as PP hiding (($$))
@@ -103,10 +104,12 @@ type PeerWire = ConduitM Message Message IO
103 104
104runPeerWire :: Socket -> PeerWire () -> IO () 105runPeerWire :: Socket -> PeerWire () -> IO ()
105runPeerWire sock p2p = 106runPeerWire sock p2p =
106 sourceSocket sock $= 107 sourceSocket sock $=
107 conduitGet S.get $= 108 S.conduitGet S.get $=
108 p2p $= 109-- B.conduitDecode $=
109 conduitPut S.put $$ 110 p2p $=
111 S.conduitPut S.put $$
112-- B.conduitEncode $$
110 sinkSocket sock 113 sinkSocket sock
111 114
112awaitMessage :: P2P Message 115awaitMessage :: P2P Message
diff --git a/src/Network/BitTorrent/Exchange/Protocol.hs b/src/Network/BitTorrent/Exchange/Protocol.hs
index 83774f06..a285f8d2 100644
--- a/src/Network/BitTorrent/Exchange/Protocol.hs
+++ b/src/Network/BitTorrent/Exchange/Protocol.hs
@@ -435,7 +435,7 @@ instance Serialize Message where
435 435
436instance Binary Message where 436instance Binary Message where
437 get = do 437 get = do
438 len <- undefined --getInt 438 len <- getIntB
439-- _ <- lookAhead $ ensure len 439-- _ <- lookAhead $ ensure len
440 if len == 0 then return KeepAlive 440 if len == 0 then return KeepAlive
441 else do 441 else do
@@ -463,7 +463,7 @@ instance Binary Message where
463 463
464 where 464 where
465 getBlock :: Int -> B.Get Block 465 getBlock :: Int -> B.Get Block
466 getBlock len = Block <$> getIntB <*> getIntB <*> B.getBytes len 466 getBlock len = Block <$> getIntB <*> getIntB <*> B.getByteString len
467 {-# INLINE getBlock #-} 467 {-# INLINE getBlock #-}
468 468
469 put KeepAlive = putIntB 0 469 put KeepAlive = putIntB 0