diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-12 08:13:18 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-12 08:13:18 +0400 |
commit | eadb3a6826fb784c33b10b2eab7d4f7bf72b0043 (patch) | |
tree | d7ca09465f9fa90fc61732da659231353b797f31 /src/Network | |
parent | 69c24795715ecb871433bed46e0f43b777b3ca25 (diff) |
- Remove some debug stuff.
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/BitTorrent/Internal.hs | 8 | ||||
-rw-r--r-- | src/Network/BitTorrent/Peer.hs | 4 | ||||
-rw-r--r-- | src/Network/BitTorrent/Tracker.hs | 8 | ||||
-rw-r--r-- | src/Network/BitTorrent/Tracker/Protocol.hs | 3 |
4 files changed, 5 insertions, 18 deletions
diff --git a/src/Network/BitTorrent/Internal.hs b/src/Network/BitTorrent/Internal.hs index 3d07a82f..da104240 100644 --- a/src/Network/BitTorrent/Internal.hs +++ b/src/Network/BitTorrent/Internal.hs | |||
@@ -250,10 +250,7 @@ withPeerSession ss @ SwarmSession {..} addr | |||
250 | let caps = encodeExts $ allowedExtensions $ clientSession | 250 | let caps = encodeExts $ allowedExtensions $ clientSession |
251 | let pid = clientPeerID $ clientSession | 251 | let pid = clientPeerID $ clientSession |
252 | let chs = Handshake defaultBTProtocol caps (tInfoHash torrentMeta) pid | 252 | let chs = Handshake defaultBTProtocol caps (tInfoHash torrentMeta) pid |
253 | putStrLn "trying to connect" | ||
254 | sock <- connectToPeer addr | 253 | sock <- connectToPeer addr |
255 | |||
256 | putStrLn "trying to handshake" | ||
257 | phs <- handshake sock chs `onException` close sock | 254 | phs <- handshake sock chs `onException` close sock |
258 | 255 | ||
259 | cbf <- readTVarIO clientBitfield | 256 | cbf <- readTVarIO clientBitfield |
@@ -324,11 +321,12 @@ updateOutcoming PeerSession {..} = | |||
324 | 321 | ||
325 | sendKA :: Socket -> IO () | 322 | sendKA :: Socket -> IO () |
326 | sendKA sock {- SwarmSession {..} -} = do | 323 | sendKA sock {- SwarmSession {..} -} = do |
327 | print "I'm sending keep alive." | 324 | return () |
325 | -- print "I'm sending keep alive." | ||
328 | -- sendAll sock (encode BT.KeepAlive) | 326 | -- sendAll sock (encode BT.KeepAlive) |
329 | -- let mgr = eventManager clientSession | 327 | -- let mgr = eventManager clientSession |
330 | -- updateTimeout mgr | 328 | -- updateTimeout mgr |
331 | print "Done.." | 329 | -- print "Done.." |
332 | 330 | ||
333 | abortSession :: IO () | 331 | abortSession :: IO () |
334 | abortSession = error "abortSession: not implemented" | 332 | abortSession = error "abortSession: not implemented" |
diff --git a/src/Network/BitTorrent/Peer.hs b/src/Network/BitTorrent/Peer.hs index 6e5db0e0..9aa924d3 100644 --- a/src/Network/BitTorrent/Peer.hs +++ b/src/Network/BitTorrent/Peer.hs | |||
@@ -531,12 +531,8 @@ peerSockAddr = SockAddrInet <$> (g . peerPort) <*> (htonl . peerIP) | |||
531 | -- | Tries to connect to peer using reasonable default parameters. | 531 | -- | Tries to connect to peer using reasonable default parameters. |
532 | connectToPeer :: PeerAddr -> IO Socket | 532 | connectToPeer :: PeerAddr -> IO Socket |
533 | connectToPeer p = do | 533 | connectToPeer p = do |
534 | putStrLn "socket" | ||
535 | sock <- socket AF_INET Stream Network.Socket.defaultProtocol | 534 | sock <- socket AF_INET Stream Network.Socket.defaultProtocol |
536 | |||
537 | putStrLn "connect" | ||
538 | connect sock (peerSockAddr p) | 535 | connect sock (peerSockAddr p) |
539 | putStrLn "connected" | ||
540 | return sock | 536 | return sock |
541 | 537 | ||
542 | -- | Pretty print peer address in human readable form. | 538 | -- | Pretty print peer address in human readable form. |
diff --git a/src/Network/BitTorrent/Tracker.hs b/src/Network/BitTorrent/Tracker.hs index 6bf6de4b..179dae1d 100644 --- a/src/Network/BitTorrent/Tracker.hs +++ b/src/Network/BitTorrent/Tracker.hs | |||
@@ -170,7 +170,6 @@ sec = 1000 * 1000 | |||
170 | waitInterval :: TSession -> IO () | 170 | waitInterval :: TSession -> IO () |
171 | waitInterval se @ TSession {..} = do | 171 | waitInterval se @ TSession {..} = do |
172 | delay <- readIORef seInterval | 172 | delay <- readIORef seInterval |
173 | print delay | ||
174 | threadDelay (delay * sec) | 173 | threadDelay (delay * sec) |
175 | 174 | ||
176 | withTracker :: Progress -> TConnection -> (TSession -> IO a) -> IO a | 175 | withTracker :: Progress -> TConnection -> (TSession -> IO a) -> IO a |
@@ -178,21 +177,17 @@ withTracker initProgress conn action = bracket start end (action . fst) | |||
178 | where | 177 | where |
179 | start = do | 178 | start = do |
180 | resp <- askTracker (startedReq conn initProgress) | 179 | resp <- askTracker (startedReq conn initProgress) |
181 | print resp | ||
182 | se <- newSession initProgress (respInterval resp) (respPeers resp) | 180 | se <- newSession initProgress (respInterval resp) (respPeers resp) |
183 | tid <- forkIO (return ()) -- (syncSession se) | 181 | tid <- forkIO (syncSession se) |
184 | return (se, tid) | 182 | return (se, tid) |
185 | 183 | ||
186 | syncSession se @ TSession {..} = forever $ do | 184 | syncSession se @ TSession {..} = forever $ do |
187 | waitInterval se | 185 | waitInterval se |
188 | pr <- getProgress se | 186 | pr <- getProgress se |
189 | print "tracker req" | ||
190 | resp <- tryJust isIOException $ do | 187 | resp <- tryJust isIOException $ do |
191 | askTracker (regularReq defaultNumWant conn pr) | 188 | askTracker (regularReq defaultNumWant conn pr) |
192 | print "tracker resp" | ||
193 | case resp of | 189 | case resp of |
194 | Right (ok @ OK {..}) -> do | 190 | Right (ok @ OK {..}) -> do |
195 | print ok | ||
196 | writeIORef seInterval respInterval | 191 | writeIORef seInterval respInterval |
197 | writeList2Chan sePeers respPeers | 192 | writeList2Chan sePeers respPeers |
198 | _ -> return () | 193 | _ -> return () |
@@ -203,7 +198,6 @@ withTracker initProgress conn action = bracket start end (action . fst) | |||
203 | end (se, tid) = do | 198 | end (se, tid) = do |
204 | killThread tid | 199 | killThread tid |
205 | pr <- getProgress se | 200 | pr <- getProgress se |
206 | print "stopping" | ||
207 | leaveTracker $ stoppedReq conn pr | 201 | leaveTracker $ stoppedReq conn pr |
208 | 202 | ||
209 | 203 | ||
diff --git a/src/Network/BitTorrent/Tracker/Protocol.hs b/src/Network/BitTorrent/Tracker/Protocol.hs index efc709e2..f7599ba2 100644 --- a/src/Network/BitTorrent/Tracker/Protocol.hs +++ b/src/Network/BitTorrent/Tracker/Protocol.hs | |||
@@ -230,7 +230,6 @@ askTracker req = do | |||
230 | 230 | ||
231 | rawResp <- simpleHTTP r | 231 | rawResp <- simpleHTTP r |
232 | respBody <- getResponseBody rawResp | 232 | respBody <- getResponseBody rawResp |
233 | print $ respBody | ||
234 | checkResult $ decoded respBody | 233 | checkResult $ decoded respBody |
235 | where | 234 | where |
236 | 235 | ||
@@ -247,5 +246,5 @@ leaveTracker req = do | |||
247 | let r = mkHTTPRequest (encodeRequest req) | 246 | let r = mkHTTPRequest (encodeRequest req) |
248 | 247 | ||
249 | rawResp <- simpleHTTP r | 248 | rawResp <- simpleHTTP r |
250 | respBody <- getResponseBody rawResp | 249 | _ <- getResponseBody rawResp |
251 | return () | 250 | return () |