diff options
Diffstat (limited to 'src/Network/BitTorrent/Exchange')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Protocol.hs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/Network/BitTorrent/Exchange/Protocol.hs b/src/Network/BitTorrent/Exchange/Protocol.hs index 5ea104cc..8d42e3a8 100644 --- a/src/Network/BitTorrent/Exchange/Protocol.hs +++ b/src/Network/BitTorrent/Exchange/Protocol.hs | |||
@@ -164,10 +164,8 @@ defaultHandshake = Handshake defaultBTProtocol defaultReserved | |||
164 | -- | Handshaking with a peer specified by the second argument. | 164 | -- | Handshaking with a peer specified by the second argument. |
165 | handshake :: Socket -> Handshake -> IO Handshake | 165 | handshake :: Socket -> Handshake -> IO Handshake |
166 | handshake sock hs = do | 166 | handshake sock hs = do |
167 | putStrLn "send handshake" | ||
168 | sendAll sock (S.encode hs) | 167 | sendAll sock (S.encode hs) |
169 | 168 | ||
170 | putStrLn "recv handshake size" | ||
171 | header <- recv sock 1 | 169 | header <- recv sock 1 |
172 | when (B.length header == 0) $ | 170 | when (B.length header == 0) $ |
173 | throw $ userError "Unable to receive handshake." | 171 | throw $ userError "Unable to receive handshake." |
@@ -175,7 +173,6 @@ handshake sock hs = do | |||
175 | let protocolLen = B.head header | 173 | let protocolLen = B.head header |
176 | let restLen = handshakeSize protocolLen - 1 | 174 | let restLen = handshakeSize protocolLen - 1 |
177 | 175 | ||
178 | putStrLn "recv handshake body" | ||
179 | body <- recv sock restLen | 176 | body <- recv sock restLen |
180 | let resp = B.cons protocolLen body | 177 | let resp = B.cons protocolLen body |
181 | 178 | ||
@@ -432,9 +429,9 @@ ppMessage msg = text (show msg) | |||
432 | 429 | ||
433 | -- | | 430 | -- | |
434 | data PeerStatus = PeerStatus { | 431 | data PeerStatus = PeerStatus { |
435 | _choking :: Bool | 432 | _choking :: !Bool |
436 | , _interested :: Bool | 433 | , _interested :: !Bool |
437 | } | 434 | } deriving (Show, Eq) |
438 | 435 | ||
439 | $(makeLenses ''PeerStatus) | 436 | $(makeLenses ''PeerStatus) |
440 | 437 | ||
@@ -443,9 +440,9 @@ instance Default PeerStatus where | |||
443 | 440 | ||
444 | -- | | 441 | -- | |
445 | data SessionStatus = SessionStatus { | 442 | data SessionStatus = SessionStatus { |
446 | _clientStatus :: PeerStatus | 443 | _clientStatus :: !PeerStatus |
447 | , _peerStatus :: PeerStatus | 444 | , _peerStatus :: !PeerStatus |
448 | } | 445 | } deriving (Show, Eq) |
449 | 446 | ||
450 | $(makeLenses ''SessionStatus) | 447 | $(makeLenses ''SessionStatus) |
451 | 448 | ||