diff options
Diffstat (limited to 'src/Network/BitTorrent/Peer.hs')
-rw-r--r-- | src/Network/BitTorrent/Peer.hs | 14 |
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) |
94 | version :: Version | 95 | version :: Version |
95 | version = Version [0, 10, 0, 0] [] | 96 | version = Version [0, 10, 0, 0] [] |
@@ -109,6 +110,7 @@ instance Serialize PeerID where | |||
109 | instance URLShow PeerID where | 110 | instance URLShow PeerID where |
110 | urlShow = BC.unpack . getPeerID | 111 | urlShow = BC.unpack . getPeerID |
111 | 112 | ||
113 | -- | Format peer id in human readable form. | ||
112 | ppPeerID :: PeerID -> Doc | 114 | ppPeerID :: PeerID -> Doc |
113 | ppPeerID = text . BC.unpack . getPeerID | 115 | ppPeerID = text . BC.unpack . getPeerID |
114 | 116 | ||
@@ -354,11 +356,13 @@ parseImpl = f . BC.unpack | |||
354 | ppClientImpl :: ClientImpl -> Doc | 356 | ppClientImpl :: ClientImpl -> Doc |
355 | ppClientImpl = text . tail . show | 357 | ppClientImpl = text . tail . show |
356 | 358 | ||
359 | -- | Used to represent not recognized implementation | ||
357 | unknownImpl :: ClientImpl | 360 | unknownImpl :: ClientImpl |
358 | unknownImpl = IUnknown | 361 | unknownImpl = IUnknown |
359 | 362 | ||
363 | -- TODO use Data.Version | ||
360 | 364 | ||
361 | 365 | -- | Raw version of client, normally extracted from peer id. | |
362 | type ClientVersion = ByteString | 366 | type 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 | -- |
393 | clientInfo :: PeerID -> ClientInfo | 397 | clientInfo :: PeerID -> ClientInfo |
394 | clientInfo pid = either (const unknownClient) id $ runGet getCI (getPeerID pid) | 398 | clientInfo 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. | ||
481 | data PeerAddr = PeerAddr { | 487 | data PeerAddr = PeerAddr { |
482 | peerID :: Maybe PeerID | 488 | peerID :: Maybe PeerID |
483 | , peerIP :: HostAddress | 489 | , peerIP :: HostAddress |