summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Peer/Addr.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Peer/Addr.hs')
-rw-r--r--src/Network/BitTorrent/Peer/Addr.hs11
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 #-}
10module Network.BitTorrent.Peer.Addr 11module Network.BitTorrent.Peer.Addr
11 ( PeerAddr(..) 12 ( PeerAddr(..)
@@ -17,6 +18,7 @@ import Control.Applicative
17import Data.BEncode 18import Data.BEncode
18import Data.Bits 19import Data.Bits
19import Data.Word 20import Data.Word
21import Text.PrettyPrint
20import Network 22import Network
21import Network.Socket 23import 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
76ppPeer :: PeerAddr -> String 78ppPeer :: PeerAddr -> Doc
77ppPeer p = maybe "" (++ " at ") ((ppClientInfo . clientInfo) <$> peerID p) 79ppPeer 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))