diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Data/Torrent.hs | 9 |
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 | |||
85 | import Data.Time | 86 | import Data.Time |
86 | import Data.Time.Clock.POSIX | 87 | import Data.Time.Clock.POSIX |
87 | import Data.Typeable | 88 | import Data.Typeable |
89 | import Network (HostName) | ||
88 | import Network.URI | 90 | import Network.URI |
89 | import Text.PrettyPrint as PP | 91 | import Text.PrettyPrint as PP |
90 | import Text.PrettyPrint.Class | 92 | import 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 | ||
292 | instance BEncode String where | ||
293 | toBEncode = toBEncode . T.pack | ||
294 | fromBEncode v = T.unpack <$> fromBEncode v | ||
295 | |||
289 | instance BEncode Torrent where | 296 | instance BEncode Torrent where |
290 | toBEncode Torrent {..} = toDict $ | 297 | toBEncode Torrent {..} = toDict $ |
291 | "announce" .=? tAnnounce | 298 | "announce" .=? tAnnounce |