diff options
-rw-r--r-- | bittorrent.cabal | 1 | ||||
-rw-r--r-- | src/Network/BitTorrent/Client.hs | 40 |
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 @@ | |||
1 | module Network.BitTorrent.Client | ||
2 | ( Options (..) | ||
3 | , Client (..) | ||
4 | ) where | ||
5 | |||
6 | import Data.Default | ||
7 | import Data.Function | ||
8 | import Data.Ord | ||
9 | import Data.Text | ||
10 | import Network | ||
11 | |||
12 | import Data.Torrent | ||
13 | import Data.Torrent.InfoHash | ||
14 | import Network.BitTorrent.Core | ||
15 | import Network.BitTorrent.Exchange.Message | ||
16 | |||
17 | |||
18 | data Options = Options | ||
19 | { fingerprint :: Fingerprint | ||
20 | , name :: Text | ||
21 | , port :: PortNumber | ||
22 | } | ||
23 | |||
24 | instance Default Options where | ||
25 | def = Options | ||
26 | { fingerprint = def | ||
27 | , name = "hs-bittorrent" | ||
28 | , port = 6882 | ||
29 | } | ||
30 | |||
31 | data Client = Client | ||
32 | { clientPeerId :: !PeerId | ||
33 | , allowedExtensions :: !Caps | ||
34 | } | ||
35 | |||
36 | instance Eq Client where | ||
37 | (==) = (==) `on` clientPeerId | ||
38 | |||
39 | instance Ord Client where | ||
40 | compare = comparing clientPeerId | ||