summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Core/PeerId.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-11-23 05:22:59 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-11-23 05:22:59 +0400
commit53fd4f2c4a3aa66d2f4cb36a673be3199002414e (patch)
treec2c3f09f8b44c53f03e0b2ea6b3b51c12dfc7d59 /src/Network/BitTorrent/Core/PeerId.hs
parent0d45d13454644224d6eb461225ef938b84adab6a (diff)
Add BitComet peer id encoding style
Diffstat (limited to 'src/Network/BitTorrent/Core/PeerId.hs')
-rw-r--r--src/Network/BitTorrent/Core/PeerId.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Core/PeerId.hs b/src/Network/BitTorrent/Core/PeerId.hs
index 5962a6e5..b8dd17e2 100644
--- a/src/Network/BitTorrent/Core/PeerId.hs
+++ b/src/Network/BitTorrent/Core/PeerId.hs
@@ -287,6 +287,8 @@ clientInfo pid = either (const def) id $ runGet getCI (getPeerId pid)
287 case leading of 287 case leading of
288 '-' -> ClientInfo <$> getAzureusImpl <*> getAzureusVersion 288 '-' -> ClientInfo <$> getAzureusImpl <*> getAzureusVersion
289 'M' -> ClientInfo <$> pure IMainline <*> getMainlineVersion 289 'M' -> ClientInfo <$> pure IMainline <*> getMainlineVersion
290 'e' -> ClientInfo <$> getBitCometImpl <*> getBitCometVersion
291 'F' -> ClientInfo <$> getBitCometImpl <*> getBitCometVersion
290 c -> ClientInfo <$> pure (getShadowImpl c) <*> getShadowVersion 292 c -> ClientInfo <$> pure (getShadowImpl c) <*> getShadowVersion
291 293
292 getMainlineVersion = do 294 getMainlineVersion = do
@@ -299,6 +301,21 @@ clientInfo pid = either (const def) id $ runGet getCI (getPeerId pid)
299 where 301 where
300 mkVer bs = Version [fromMaybe 0 $ readMaybe $ BC.unpack bs] [] 302 mkVer bs = Version [fromMaybe 0 $ readMaybe $ BC.unpack bs] []
301 303
304 getBitCometImpl = do
305 bs <- getByteString 3
306 lookAhead $ do
307 _ <- getByteString 2
308 lr <- getByteString 4
309 return $
310 if lr == "LORD" then IBitLord else
311 if bs == "UTB" then IBitComet else
312 if bs == "xbc" then IBitComet else def
313
314 getBitCometVersion = do
315 x <- getWord8
316 y <- getWord8
317 return $ Version [fromIntegral x, fromIntegral y] []
318
302 getShadowImpl 'A' = IABC 319 getShadowImpl 'A' = IABC
303 getShadowImpl 'O' = IOspreyPermaseed 320 getShadowImpl 'O' = IOspreyPermaseed
304 getShadowImpl 'Q' = IBTQueue 321 getShadowImpl 'Q' = IBTQueue