diff options
Diffstat (limited to 'src/Network/BitTorrent/Peer/Addr.hs')
-rw-r--r-- | src/Network/BitTorrent/Peer/Addr.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/Peer/Addr.hs b/src/Network/BitTorrent/Peer/Addr.hs index 1c2ac2eb..5c05180a 100644 --- a/src/Network/BitTorrent/Peer/Addr.hs +++ b/src/Network/BitTorrent/Peer/Addr.hs | |||
@@ -6,6 +6,7 @@ | |||
6 | -- Portability : non-portable | 6 | -- Portability : non-portable |
7 | -- | 7 | -- |
8 | {-# LANGUAGE OverloadedStrings #-} | 8 | {-# LANGUAGE OverloadedStrings #-} |
9 | {-# LANGUAGE RecordWildCards #-} | ||
9 | {-# OPTIONS -fno-warn-orphans #-} | 10 | {-# OPTIONS -fno-warn-orphans #-} |
10 | module Network.BitTorrent.Peer.Addr | 11 | module Network.BitTorrent.Peer.Addr |
11 | ( PeerAddr(..) | 12 | ( PeerAddr(..) |
@@ -17,6 +18,7 @@ import Control.Applicative | |||
17 | import Data.BEncode | 18 | import Data.BEncode |
18 | import Data.Bits | 19 | import Data.Bits |
19 | import Data.Word | 20 | import Data.Word |
21 | import Text.PrettyPrint | ||
20 | import Network | 22 | import Network |
21 | import Network.Socket | 23 | import Network.Socket |
22 | 24 | ||
@@ -73,6 +75,9 @@ connectToPeer p = do | |||
73 | connect sock (peerSockAddr p) | 75 | connect sock (peerSockAddr p) |
74 | return sock | 76 | return sock |
75 | 77 | ||
76 | ppPeer :: PeerAddr -> String | 78 | ppPeer :: PeerAddr -> Doc |
77 | ppPeer p = maybe "" (++ " at ") ((ppClientInfo . clientInfo) <$> peerID p) | 79 | ppPeer p @ PeerAddr {..} = case peerID of |
78 | ++ show (peerSockAddr p) | 80 | Just pid -> ppClientInfo (clientInfo pid) <+> "at" <+> paddr |
81 | Nothing -> paddr | ||
82 | where | ||
83 | paddr = text (show (peerSockAddr p)) | ||