summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-12 18:57:11 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-12 18:57:11 +0400
commit59b812124590dc4d4d11b51dff4073b495231363 (patch)
tree9f472a52def2a8c8400442b9c4e5334060f86872
parent3a4b33c0a526c958c447ce6820b0ba11fb0a7c4c (diff)
Add externalAddr function
-rw-r--r--src/Network/BitTorrent/Client/Types.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Client/Types.hs b/src/Network/BitTorrent/Client/Types.hs
index 603142d5..e80578a3 100644
--- a/src/Network/BitTorrent/Client/Types.hs
+++ b/src/Network/BitTorrent/Client/Types.hs
@@ -3,6 +3,7 @@ module Network.BitTorrent.Client.Types
3 ( -- * Core types 3 ( -- * Core types
4 Handle (..) 4 Handle (..)
5 , Client (..) 5 , Client (..)
6 , externalAddr
6 7
7 -- * Monad BitTorrent 8 -- * Monad BitTorrent
8 , BitTorrent (..) 9 , BitTorrent (..)
@@ -52,6 +53,16 @@ instance Eq Client where
52instance Ord Client where 53instance Ord Client where
53 compare = comparing clientPeerId 54 compare = comparing clientPeerId
54 55
56-- | External IP address of a host running a bittorrent client
57-- software may be used to acknowledge remote peer the host connected
58-- to. See 'Network.BitTorrent.Exchange.Message.ExtendedHandshake'.
59externalAddr :: Client -> PeerAddr (Maybe IP)
60externalAddr Client {..} = PeerAddr
61 { peerId = Just clientPeerId
62 , peerHost = Nothing -- TODO return external IP address, if known
63 , peerPort = clientListenerPort
64 }
65
55{----------------------------------------------------------------------- 66{-----------------------------------------------------------------------
56-- BitTorrent monad 67-- BitTorrent monad
57-----------------------------------------------------------------------} 68-----------------------------------------------------------------------}