summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Peer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Peer.hs')
-rw-r--r--src/Network/BitTorrent/Peer.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/Peer.hs b/src/Network/BitTorrent/Peer.hs
index f4502f8b..6ab80fb6 100644
--- a/src/Network/BitTorrent/Peer.hs
+++ b/src/Network/BitTorrent/Peer.hs
@@ -89,7 +89,8 @@ import Network.Socket
89 89
90 90
91 91
92-- TODO we have linker error here, so manual hardcoded version for a while. 92-- TODO we have linker error here, so manual hardcoded version for a
93-- while.
93-- import Paths_network_bittorrent (version) 94-- import Paths_network_bittorrent (version)
94version :: Version 95version :: Version
95version = Version [0, 10, 0, 0] [] 96version = Version [0, 10, 0, 0] []
@@ -109,6 +110,7 @@ instance Serialize PeerID where
109instance URLShow PeerID where 110instance URLShow PeerID where
110 urlShow = BC.unpack . getPeerID 111 urlShow = BC.unpack . getPeerID
111 112
113-- | Format peer id in human readable form.
112ppPeerID :: PeerID -> Doc 114ppPeerID :: PeerID -> Doc
113ppPeerID = text . BC.unpack . getPeerID 115ppPeerID = text . BC.unpack . getPeerID
114 116
@@ -354,11 +356,13 @@ parseImpl = f . BC.unpack
354ppClientImpl :: ClientImpl -> Doc 356ppClientImpl :: ClientImpl -> Doc
355ppClientImpl = text . tail . show 357ppClientImpl = text . tail . show
356 358
359-- | Used to represent not recognized implementation
357unknownImpl :: ClientImpl 360unknownImpl :: ClientImpl
358unknownImpl = IUnknown 361unknownImpl = IUnknown
359 362
363-- TODO use Data.Version
360 364
361 365-- | Raw version of client, normally extracted from peer id.
362type ClientVersion = ByteString 366type ClientVersion = ByteString
363 367
364-- | Format client implementation version in human readable form. 368-- | Format client implementation version in human readable form.
@@ -391,7 +395,8 @@ unknownClient = ClientInfo unknownImpl unknownVersion
391-- 'unknownClient'. 395-- 'unknownClient'.
392-- 396--
393clientInfo :: PeerID -> ClientInfo 397clientInfo :: PeerID -> ClientInfo
394clientInfo pid = either (const unknownClient) id $ runGet getCI (getPeerID pid) 398clientInfo pid = either (const unknownClient) id $
399 runGet getCI (getPeerID pid)
395 where -- TODO other styles 400 where -- TODO other styles
396 getCI = do 401 getCI = do
397 _ <- getWord8 402 _ <- getWord8
@@ -477,7 +482,8 @@ nameMap =
477 Peer address 482 Peer address
478-----------------------------------------------------------------------} 483-----------------------------------------------------------------------}
479 484
480 485-- | Peer address info normally extracted from peer list or peer
486-- compact list encoding.
481data PeerAddr = PeerAddr { 487data PeerAddr = PeerAddr {
482 peerID :: Maybe PeerID 488 peerID :: Maybe PeerID
483 , peerIP :: HostAddress 489 , peerIP :: HostAddress