diff options
-rw-r--r-- | src/Network/BitTorrent/PeerWire/Handshake.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/PeerWire/Handshake.hs b/src/Network/BitTorrent/PeerWire/Handshake.hs index a80728aa..a05ecc33 100644 --- a/src/Network/BitTorrent/PeerWire/Handshake.hs +++ b/src/Network/BitTorrent/PeerWire/Handshake.hs | |||
@@ -91,11 +91,14 @@ defaultHandshake :: InfoHash -> PeerID -> Handshake | |||
91 | defaultHandshake = Handshake defaultBTProtocol defaultReserved | 91 | defaultHandshake = Handshake defaultBTProtocol defaultReserved |
92 | 92 | ||
93 | 93 | ||
94 | -- TODO check if hash the same | ||
95 | -- | Handshaking with a peer specified by the second argument. | 94 | -- | Handshaking with a peer specified by the second argument. |
96 | -- | 95 | -- |
97 | handshake :: Socket -> Handshake -> IO (Either String Handshake) | 96 | handshake :: Socket -> Handshake -> IO (Either String Handshake) |
98 | handshake sock hs = do | 97 | handshake sock hs = do |
99 | sendAll sock (S.encode hs) | 98 | sendAll sock (S.encode hs) |
100 | r <- recv sock handshakeMaxSize | 99 | r <- recv sock handshakeMaxSize |
101 | return (S.decode r) | 100 | return (checkIH (S.decode r)) |
101 | where | ||
102 | checkIH (Right hs') | ||
103 | | hsInfoHash hs /= hsInfoHash hs' = Left "Handshake info hash do not match." | ||
104 | checkIH x = x | ||