diff options
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Message.hs | 23 |
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 | |||
549 | extendedHandshakeId :: ExtendedMessageId | 550 | extendedHandshakeId :: ExtendedMessageId |
550 | extendedHandshakeId = 0 | 551 | extendedHandshakeId = 0 |
551 | 552 | ||
553 | -- | Default 'Request' queue size. | ||
554 | defaultQueueLength :: Int | ||
555 | defaultQueueLength = 0 | ||
556 | |||
557 | -- | All fields are empty. | ||
552 | instance Default ExtendedHandshake where | 558 | instance Default ExtendedHandshake where |
553 | def = nullExtendedHandshake def | 559 | def = ExtendedHandshake def def def def def def |
554 | 560 | ||
555 | instance BEncode ExtendedHandshake where | 561 | instance 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'. | ||
585 | nullExtendedHandshake :: ExtendedCaps -> ExtendedHandshake | 592 | nullExtendedHandshake :: ExtendedCaps -> ExtendedHandshake |
586 | nullExtendedHandshake caps | 593 | nullExtendedHandshake 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> |
640 | data ExtendedMessage | 657 | data ExtendedMessage |
641 | = EHandshake ExtendedHandshake | 658 | = EHandshake ExtendedHandshake |