diff options
Diffstat (limited to 'src/Network/BitTorrent/Tracker/Message.hs')
-rw-r--r-- | src/Network/BitTorrent/Tracker/Message.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Network/BitTorrent/Tracker/Message.hs b/src/Network/BitTorrent/Tracker/Message.hs index 95b9c7ca..0d720471 100644 --- a/src/Network/BitTorrent/Tracker/Message.hs +++ b/src/Network/BitTorrent/Tracker/Message.hs | |||
@@ -81,6 +81,7 @@ import Data.Default | |||
81 | import Data.List as L | 81 | import Data.List as L |
82 | import Data.Maybe | 82 | import Data.Maybe |
83 | import Data.Serialize as S hiding (Result) | 83 | import Data.Serialize as S hiding (Result) |
84 | import Data.String | ||
84 | import Data.Text (Text) | 85 | import Data.Text (Text) |
85 | import Data.Text.Encoding | 86 | import Data.Text.Encoding |
86 | import Data.Typeable | 87 | import Data.Typeable |
@@ -480,7 +481,7 @@ data AnnounceInfo = | |||
480 | 481 | ||
481 | -- | Human readable warning. | 482 | -- | Human readable warning. |
482 | , respWarning :: !(Maybe Text) | 483 | , respWarning :: !(Maybe Text) |
483 | } deriving (Show, Typeable) | 484 | } deriving (Show, Eq, Typeable) |
484 | 485 | ||
485 | -- | HTTP tracker protocol compatible encoding. | 486 | -- | HTTP tracker protocol compatible encoding. |
486 | instance BEncode AnnounceInfo where | 487 | instance BEncode AnnounceInfo where |
@@ -535,6 +536,12 @@ instance Serialize AnnounceInfo where | |||
535 | , respPeers = PeerList peers | 536 | , respPeers = PeerList peers |
536 | } | 537 | } |
537 | 538 | ||
539 | -- | Decodes announce response from bencoded string, for debugging only. | ||
540 | instance IsString AnnounceInfo where | ||
541 | fromString str = either (error . format) id $ BE.decode (fromString str) | ||
542 | where | ||
543 | format msg = "fromString: unable to decode AnnounceInfo: " ++ msg | ||
544 | |||
538 | -- | Above 25, new peers are highly unlikely to increase download | 545 | -- | Above 25, new peers are highly unlikely to increase download |
539 | -- speed. Even 30 peers is /plenty/, the official client version 3 | 546 | -- speed. Even 30 peers is /plenty/, the official client version 3 |
540 | -- in fact only actively forms new connections if it has less than | 547 | -- in fact only actively forms new connections if it has less than |