diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/Tracker/Protocol.hs | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/Network/BitTorrent/Tracker/Protocol.hs b/src/Network/BitTorrent/Tracker/Protocol.hs index 5741c1d7..d61a269c 100644 --- a/src/Network/BitTorrent/Tracker/Protocol.hs +++ b/src/Network/BitTorrent/Tracker/Protocol.hs | |||
@@ -146,12 +146,12 @@ data TResponse = | |||
146 | 146 | ||
147 | instance BEncodable TResponse where | 147 | instance BEncodable TResponse where |
148 | toBEncode (Failure t) = fromAssocs ["failure reason" --> t] | 148 | toBEncode (Failure t) = fromAssocs ["failure reason" --> t] |
149 | toBEncode resp@(OK {}) = fromAssocs | 149 | toBEncode (OK {..}) = fromAssocs |
150 | [ "interval" --> respInterval resp | 150 | [ "interval" --> respInterval |
151 | , "min interval" -->? respMinInterval resp | 151 | , "min interval" -->? respMinInterval |
152 | , "complete" -->? respComplete resp | 152 | , "complete" -->? respComplete |
153 | , "incomplete" -->? respIncomplete resp | 153 | , "incomplete" -->? respIncomplete |
154 | , "peers" --> respPeers resp | 154 | , "peers" --> respPeers |
155 | ] | 155 | ] |
156 | 156 | ||
157 | fromBEncode (BDict d) | 157 | fromBEncode (BDict d) |
@@ -184,15 +184,15 @@ instance URLShow Event where | |||
184 | (x : xs) = show e | 184 | (x : xs) = show e |
185 | 185 | ||
186 | instance URLEncode TRequest where | 186 | instance URLEncode TRequest where |
187 | urlEncode req = mconcat | 187 | urlEncode TRequest {..} = mconcat |
188 | [ s "peer_id" %= reqPeerId req | 188 | [ s "peer_id" %= reqPeerId |
189 | , s "port" %= reqPort req | 189 | , s "port" %= reqPort |
190 | , s "uploaded" %= reqUploaded req | 190 | , s "uploaded" %= reqUploaded |
191 | , s "downloaded" %= reqDownloaded req | 191 | , s "downloaded" %= reqDownloaded |
192 | , s "left" %= reqLeft req | 192 | , s "left" %= reqLeft |
193 | , s "ip" %=? reqIP req | 193 | , s "ip" %=? reqIP |
194 | , s "numwant" %=? reqNumWant req | 194 | , s "numwant" %=? reqNumWant |
195 | , s "event" %=? reqEvent req | 195 | , s "event" %=? reqEvent |
196 | ] | 196 | ] |
197 | where s :: String -> String; s = id; {-# INLINE s #-} | 197 | where s :: String -> String; s = id; {-# INLINE s #-} |
198 | 198 | ||
@@ -342,7 +342,4 @@ askTracker req = do | |||
342 | leaveTracker :: TRequest -> IO () | 342 | leaveTracker :: TRequest -> IO () |
343 | leaveTracker req = do | 343 | leaveTracker req = do |
344 | let r = mkHTTPRequest (encodeRequest req) | 344 | let r = mkHTTPRequest (encodeRequest req) |
345 | 345 | void $ simpleHTTP r >>= getResponseBody | |
346 | rawResp <- simpleHTTP r | ||
347 | _ <- getResponseBody rawResp | ||
348 | return () | ||