From: Ramakrishnan Muthukrishnan Date: Sun, 28 Feb 2016 12:02:05 +0000 (+0530) Subject: Tracker: add UDP tracker error response parsing X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/bcase/frontends/index.php?a=commitdiff_plain;h=fdb47f1503a234491a59997dc052dda3cec79c73;p=functorrent.git Tracker: add UDP tracker error response parsing --- diff --git a/src/FuncTorrent/Tracker.hs b/src/FuncTorrent/Tracker.hs index 224a30e..dd66c12 100644 --- a/src/FuncTorrent/Tracker.hs +++ b/src/FuncTorrent/Tracker.hs @@ -78,6 +78,7 @@ data UDPRequest = ConnectReq Integer data UDPResponse = ConnectResp Integer Integer -- transaction_id connection_id | AnnounceResp Integer Integer Integer Integer [(IP, Port)] -- transaction_id interval leechers seeders [(ip, port)] | ScrapeResp Integer Integer Integer Integer + | ErrorResp Integer String deriving (Show, Eq) actionToInteger :: Action -> Integer @@ -137,6 +138,10 @@ instance Binary UDPResponse where _ <- getWord32be _ <- getWord32be return $ ScrapeResp tid 0 0 0 + 3 -> do -- error response + tid <- fromIntegral <$> getWord32be + bs <- getByteString 4 + return $ ErrorResp tid $ unpack bs _ -> error ("unknown response action type: " ++ show a) getIPPortPairs :: Get [(IP, Port)]