From 59b812124590dc4d4d11b51dff4073b495231363 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Wed, 12 Feb 2014 18:57:11 +0400 Subject: Add externalAddr function --- src/Network/BitTorrent/Client/Types.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/Network/BitTorrent') 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 ( -- * Core types Handle (..) , Client (..) + , externalAddr -- * Monad BitTorrent , BitTorrent (..) @@ -52,6 +53,16 @@ instance Eq Client where instance Ord Client where compare = comparing clientPeerId +-- | External IP address of a host running a bittorrent client +-- software may be used to acknowledge remote peer the host connected +-- to. See 'Network.BitTorrent.Exchange.Message.ExtendedHandshake'. +externalAddr :: Client -> PeerAddr (Maybe IP) +externalAddr Client {..} = PeerAddr + { peerId = Just clientPeerId + , peerHost = Nothing -- TODO return external IP address, if known + , peerPort = clientListenerPort + } + {----------------------------------------------------------------------- -- BitTorrent monad -----------------------------------------------------------------------} -- cgit v1.2.3