diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Message.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Exchange/Message.hs b/src/Network/BitTorrent/Exchange/Message.hs index b7567e60..8d0c62f4 100644 --- a/src/Network/BitTorrent/Exchange/Message.hs +++ b/src/Network/BitTorrent/Exchange/Message.hs | |||
@@ -677,6 +677,24 @@ defaultQueueLength = 1 | |||
677 | instance Default ExtendedHandshake where | 677 | instance Default ExtendedHandshake where |
678 | def = ExtendedHandshake def def def def def def def def | 678 | def = ExtendedHandshake def def def def def def def def |
679 | 679 | ||
680 | instance Monoid ExtendedHandshake where | ||
681 | mempty = def { ehsCaps = mempty } | ||
682 | mappend old new = | ||
683 | ExtendedHandshake { | ||
684 | ehsCaps = ehsCaps old <> ehsCaps new, | ||
685 | ehsIPv4 = ehsIPv4 old `mergeOld` ehsIPv4 new, | ||
686 | ehsIPv6 = ehsIPv6 old `mergeOld` ehsIPv6 new, | ||
687 | ehsMetadataSize = ehsMetadataSize old `mergeNew` ehsMetadataSize new, | ||
688 | ehsPort = ehsPort old `mergeOld` ehsPort new, | ||
689 | ehsQueueLength = ehsQueueLength old `mergeNew` ehsQueueLength new, | ||
690 | ehsVersion = ehsVersion old `mergeOld` ehsVersion new, | ||
691 | ehsYourIp = ehsYourIp old `mergeOld` ehsYourIp new | ||
692 | } | ||
693 | where | ||
694 | mergeOld old new = old <|> new | ||
695 | mergeNew old new = new <|> old | ||
696 | |||
697 | |||
680 | instance BEncode ExtendedHandshake where | 698 | instance BEncode ExtendedHandshake where |
681 | toBEncode ExtendedHandshake {..} = toDict $ | 699 | toBEncode ExtendedHandshake {..} = toDict $ |
682 | "ipv4" .=? (S.encode <$> ehsIPv4) | 700 | "ipv4" .=? (S.encode <$> ehsIPv4) |