diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-10 08:42:26 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-10 08:42:26 +0400 |
commit | caa5e1b2eed5488eac08e6e4b7f129fe6ba2ae1b (patch) | |
tree | 84946e965d86cb739fd55e86700d808c42952053 /src | |
parent | 06215daa078845e5fdff303106689950abd4ba4f (diff) |
Fix bug in mempty :: Caps
We should not include unknown bits in reserved handshake field.
Otherwise peer can think that we support extensions we don't support
actually.
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Message.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/Exchange/Message.hs b/src/Network/BitTorrent/Exchange/Message.hs index e1e17e6e..c3f6818f 100644 --- a/src/Network/BitTorrent/Exchange/Message.hs +++ b/src/Network/BitTorrent/Exchange/Message.hs | |||
@@ -180,9 +180,9 @@ instance Default Caps where | |||
180 | def = Caps 0 | 180 | def = Caps 0 |
181 | {-# INLINE def #-} | 181 | {-# INLINE def #-} |
182 | 182 | ||
183 | -- | Monoid under intersection. | 183 | -- | Monoid under intersection. 'mempty' includes all known extensions. |
184 | instance Monoid Caps where | 184 | instance Monoid Caps where |
185 | mempty = Caps (-1) | 185 | mempty = toCaps [minBound .. maxBound] |
186 | {-# INLINE mempty #-} | 186 | {-# INLINE mempty #-} |
187 | 187 | ||
188 | mappend (Caps a) (Caps b) = Caps (a .&. b) | 188 | mappend (Caps a) (Caps b) = Caps (a .&. b) |
@@ -578,7 +578,7 @@ instance Default ExtendedCaps where | |||
578 | 578 | ||
579 | -- | Monoid under intersection: | 579 | -- | Monoid under intersection: |
580 | -- | 580 | -- |
581 | -- * The 'mempty' caps include all known extensions; | 581 | -- * The 'mempty' caps includes all known extensions; |
582 | -- | 582 | -- |
583 | -- * the 'mappend' operation is NOT commutative: it return message | 583 | -- * the 'mappend' operation is NOT commutative: it return message |
584 | -- id from the first caps for the extensions existing in both caps. | 584 | -- id from the first caps for the extensions existing in both caps. |