summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Data/Torrent.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Data/Torrent.hs b/src/Data/Torrent.hs
index 7833c261..e76ea57e 100644
--- a/src/Data/Torrent.hs
+++ b/src/Data/Torrent.hs
@@ -18,6 +18,7 @@
18-- 18--
19{-# LANGUAGE CPP #-} 19{-# LANGUAGE CPP #-}
20{-# LANGUAGE FlexibleInstances #-} 20{-# LANGUAGE FlexibleInstances #-}
21{-# LANGUAGE OverlappingInstances #-}
21{-# LANGUAGE BangPatterns #-} 22{-# LANGUAGE BangPatterns #-}
22{-# LANGUAGE GeneralizedNewtypeDeriving #-} 23{-# LANGUAGE GeneralizedNewtypeDeriving #-}
23{-# LANGUAGE DeriveDataTypeable #-} 24{-# LANGUAGE DeriveDataTypeable #-}
@@ -85,6 +86,7 @@ import Data.Text as T
85import Data.Time 86import Data.Time
86import Data.Time.Clock.POSIX 87import Data.Time.Clock.POSIX
87import Data.Typeable 88import Data.Typeable
89import Network (HostName)
88import Network.URI 90import Network.URI
89import Text.PrettyPrint as PP 91import Text.PrettyPrint as PP
90import Text.PrettyPrint.Class 92import Text.PrettyPrint.Class
@@ -219,7 +221,7 @@ data Torrent = Torrent
219 , tInfoDict :: !InfoDict 221 , tInfoDict :: !InfoDict
220 -- ^ Info about each content file. 222 -- ^ Info about each content file.
221 223
222 , tNodes :: !(Maybe [NodeAddr ByteString]) 224 , tNodes :: !(Maybe [NodeAddr HostName])
223 -- ^ This key should be set to the /K closest/ nodes in the 225 -- ^ This key should be set to the /K closest/ nodes in the
224 -- torrent generating client's routing table. Alternatively, the 226 -- torrent generating client's routing table. Alternatively, the
225 -- key could be set to a known good 'Network.BitTorrent.Core.Node' 227 -- key could be set to a known good 'Network.BitTorrent.Core.Node'
@@ -286,6 +288,11 @@ instance BEncode POSIXTime where
286 fromBEncode (BInteger i) = return $ fromIntegral i 288 fromBEncode (BInteger i) = return $ fromIntegral i
287 fromBEncode _ = decodingError $ "POSIXTime" 289 fromBEncode _ = decodingError $ "POSIXTime"
288 290
291-- TODO to bencoding package
292instance BEncode String where
293 toBEncode = toBEncode . T.pack
294 fromBEncode v = T.unpack <$> fromBEncode v
295
289instance BEncode Torrent where 296instance BEncode Torrent where
290 toBEncode Torrent {..} = toDict $ 297 toBEncode Torrent {..} = toDict $
291 "announce" .=? tAnnounce 298 "announce" .=? tAnnounce