summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Exchange
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Exchange')
-rw-r--r--src/Network/BitTorrent/Exchange/Message.hs23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/Exchange/Message.hs b/src/Network/BitTorrent/Exchange/Message.hs
index c614b1ae..8f6e1a5a 100644
--- a/src/Network/BitTorrent/Exchange/Message.hs
+++ b/src/Network/BitTorrent/Exchange/Message.hs
@@ -68,6 +68,7 @@ module Network.BitTorrent.Exchange.Message
68 68
69 -- *** Handshake 69 -- *** Handshake
70 , ExtendedHandshake (..) 70 , ExtendedHandshake (..)
71 , defaultQueueLength
71 , nullExtendedHandshake 72 , nullExtendedHandshake
72 73
73 -- *** Metadata 74 -- *** Metadata
@@ -549,8 +550,13 @@ data ExtendedHandshake = ExtendedHandshake
549extendedHandshakeId :: ExtendedMessageId 550extendedHandshakeId :: ExtendedMessageId
550extendedHandshakeId = 0 551extendedHandshakeId = 0
551 552
553-- | Default 'Request' queue size.
554defaultQueueLength :: Int
555defaultQueueLength = 0
556
557-- | All fields are empty.
552instance Default ExtendedHandshake where 558instance Default ExtendedHandshake where
553 def = nullExtendedHandshake def 559 def = ExtendedHandshake def def def def def def
554 560
555instance BEncode ExtendedHandshake where 561instance BEncode ExtendedHandshake where
556 toBEncode ExtendedHandshake {..} = toDict $ 562 toBEncode ExtendedHandshake {..} = toDict $
@@ -582,9 +588,16 @@ instance PeerMessage ExtendedHandshake where
582 requires _ = Just ExtExtended 588 requires _ = Just ExtExtended
583 {-# INLINE requires #-} 589 {-# INLINE requires #-}
584 590
591-- | Set default values and the specified 'ExtendedCaps'.
585nullExtendedHandshake :: ExtendedCaps -> ExtendedHandshake 592nullExtendedHandshake :: ExtendedCaps -> ExtendedHandshake
586nullExtendedHandshake caps 593nullExtendedHandshake caps = ExtendedHandshake
587 = ExtendedHandshake Nothing Nothing caps Nothing Nothing Nothing 594 { ehsIPv4 = Nothing
595 , ehsIPv6 = Nothing
596 , ehsCaps = caps
597 , ehsPort = Nothing
598 , ehsQueueLength = Just defaultQueueLength
599 , ehsVersion = Just $ T.pack $ render $ pretty libFingerprint
600 }
588 601
589{----------------------------------------------------------------------- 602{-----------------------------------------------------------------------
590-- Metadata exchange extension 603-- Metadata exchange extension
@@ -636,6 +649,10 @@ instance PeerMessage ExtendedMetadata where
636 requires _ = Just ExtExtended 649 requires _ = Just ExtExtended
637 {-# INLINE requires #-} 650 {-# INLINE requires #-}
638 651
652{-----------------------------------------------------------------------
653-- Extension protocol messages
654-----------------------------------------------------------------------}
655
639-- | For more info see <http://www.bittorrent.org/beps/bep_0010.html> 656-- | For more info see <http://www.bittorrent.org/beps/bep_0010.html>
640data ExtendedMessage 657data ExtendedMessage
641 = EHandshake ExtendedHandshake 658 = EHandshake ExtendedHandshake