summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/Torrent/PeerID.hs11
-rw-r--r--src/Network/Torrent/Tracker.hs8
2 files changed, 11 insertions, 8 deletions
diff --git a/src/Network/Torrent/PeerID.hs b/src/Network/Torrent/PeerID.hs
index d0687f59..6298cb87 100644
--- a/src/Network/Torrent/PeerID.hs
+++ b/src/Network/Torrent/PeerID.hs
@@ -4,7 +4,7 @@
4-- though this module exports some other goodies for custom generation. 4-- though this module exports some other goodies for custom generation.
5-- 5--
6module Network.Torrent.PeerID 6module Network.Torrent.PeerID
7 ( PeerID (getPeerID) 7 ( Peer(..), PeerID (getPeerID)
8 -- * Encoding styles 8 -- * Encoding styles
9 , azureusStyle, shadowStyle 9 , azureusStyle, shadowStyle
10 -- * Defaults 10 -- * Defaults
@@ -30,12 +30,21 @@ import Data.Version (Version(Version), versionBranch)
30import Data.Time.Clock (getCurrentTime) 30import Data.Time.Clock (getCurrentTime)
31import Data.Time.Format (formatTime) 31import Data.Time.Format (formatTime)
32import System.Locale (defaultTimeLocale) 32import System.Locale (defaultTimeLocale)
33import Network
34import Network.Socket
35
33 36
34-- TODO we have linker error here, so manual hardcoded version for a while. 37-- TODO we have linker error here, so manual hardcoded version for a while.
35-- import Paths_network_bittorrent (version) 38-- import Paths_network_bittorrent (version)
36version :: Version 39version :: Version
37version = Version [0, 10, 0, 0] [] 40version = Version [0, 10, 0, 0] []
38 41
42data Peer = Peer {
43 peerID :: Maybe PeerID
44 , peerIP :: HostAddress
45 , peerPort :: PortNumber
46 } deriving Show
47
39-- | Peer identifier is exactly 20 bytes long bytestring. 48-- | Peer identifier is exactly 20 bytes long bytestring.
40newtype PeerID = PeerID { getPeerID :: ByteString } 49newtype PeerID = PeerID { getPeerID :: ByteString }
41 deriving (Show, Eq, Ord, BEncodable) 50 deriving (Show, Eq, Ord, BEncodable)
diff --git a/src/Network/Torrent/Tracker.hs b/src/Network/Torrent/Tracker.hs
index ef2413f6..20cdb2fc 100644
--- a/src/Network/Torrent/Tracker.hs
+++ b/src/Network/Torrent/Tracker.hs
@@ -2,7 +2,7 @@
2{-# LANGUAGE OverloadedStrings #-} 2{-# LANGUAGE OverloadedStrings #-}
3module Network.Torrent.Tracker 3module Network.Torrent.Tracker
4 ( module Network.Torrent.Tracker.Scrape 4 ( module Network.Torrent.Tracker.Scrape
5 , Peer(..), Event(..), TRequest(..), TResponse(..) 5 , Event(..), TRequest(..), TResponse(..)
6 , defaultRequest, defaultPorts 6 , defaultRequest, defaultPorts
7 , sendRequest 7 , sendRequest
8 ) 8 )
@@ -31,12 +31,6 @@ import Network.URI
31import Network.Torrent.PeerID 31import Network.Torrent.PeerID
32 32
33 33
34data Peer = Peer {
35 peerID :: Maybe PeerID
36 , peerIP :: HostAddress
37 , peerPort :: PortNumber
38 } deriving Show
39
40data Event = Started -- ^ For first request. 34data Event = Started -- ^ For first request.
41 | Stopped -- ^ Sent when the peer is shutting down. 35 | Stopped -- ^ Sent when the peer is shutting down.
42 | Completed -- ^ To be sent when the peer completes a download. 36 | Completed -- ^ To be sent when the peer completes a download.