summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-12-13 06:19:18 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-12-13 06:19:18 +0400
commitb3ebd83bda11e5fbf8e749fe4105e7a50522a9a7 (patch)
treeaf013f4725441023356b8570bcea539d344a08cb
parent0d197ed216b238a482901481c1e617fd6169d28a (diff)
Add Client.hs module
-rw-r--r--bittorrent.cabal1
-rw-r--r--src/Network/BitTorrent/Client.hs40
2 files changed, 41 insertions, 0 deletions
diff --git a/bittorrent.cabal b/bittorrent.cabal
index dbb3c3be..f1a4f545 100644
--- a/bittorrent.cabal
+++ b/bittorrent.cabal
@@ -50,6 +50,7 @@ library
50 Data.Torrent.Progress 50 Data.Torrent.Progress
51 Data.Torrent.Tree 51 Data.Torrent.Tree
52-- Network.BitTorrent 52-- Network.BitTorrent
53 Network.BitTorrent.Client
53 Network.BitTorrent.Core 54 Network.BitTorrent.Core
54 Network.BitTorrent.Core.Fingerprint 55 Network.BitTorrent.Core.Fingerprint
55 Network.BitTorrent.Core.PeerId 56 Network.BitTorrent.Core.PeerId
diff --git a/src/Network/BitTorrent/Client.hs b/src/Network/BitTorrent/Client.hs
new file mode 100644
index 00000000..fc2b904a
--- /dev/null
+++ b/src/Network/BitTorrent/Client.hs
@@ -0,0 +1,40 @@
1module Network.BitTorrent.Client
2 ( Options (..)
3 , Client (..)
4 ) where
5
6import Data.Default
7import Data.Function
8import Data.Ord
9import Data.Text
10import Network
11
12import Data.Torrent
13import Data.Torrent.InfoHash
14import Network.BitTorrent.Core
15import Network.BitTorrent.Exchange.Message
16
17
18data Options = Options
19 { fingerprint :: Fingerprint
20 , name :: Text
21 , port :: PortNumber
22 }
23
24instance Default Options where
25 def = Options
26 { fingerprint = def
27 , name = "hs-bittorrent"
28 , port = 6882
29 }
30
31data Client = Client
32 { clientPeerId :: !PeerId
33 , allowedExtensions :: !Caps
34 }
35
36instance Eq Client where
37 (==) = (==) `on` clientPeerId
38
39instance Ord Client where
40 compare = comparing clientPeerId