summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2019-09-28 15:33:33 -0400
committerJoe Crayne <joe@jerkface.net>2020-01-01 19:33:39 -0500
commit51d24d17974235a4c2a0d8a913bbbdc7f4d2c001 (patch)
tree7fdb092ddcc7d857988feb93ee3ec0d7a27acb25
parent11987749fc6e6d3e53ea737d46d5ab13a16faeb8 (diff)
Move Data.Torrent to torrent-types library
-rw-r--r--dht/dht-client.cabal2
-rw-r--r--torrent-types/CHANGELOG.md5
-rw-r--r--torrent-types/LICENSE30
-rw-r--r--torrent-types/Setup.hs2
-rw-r--r--torrent-types/src/Data/.Torrent.hs.swobin0 -> 16384 bytes
-rw-r--r--torrent-types/src/Data/.Torrent.hs.swpbin0 -> 57344 bytes
-rw-r--r--torrent-types/src/Data/Torrent.hs (renamed from dht/src/Data/Torrent.hs)19
-rw-r--r--torrent-types/torrent-types.cabal51
8 files changed, 107 insertions, 2 deletions
diff --git a/dht/dht-client.cabal b/dht/dht-client.cabal
index 7355bae6..7efc2392 100644
--- a/dht/dht-client.cabal
+++ b/dht/dht-client.cabal
@@ -76,7 +76,6 @@ library
76 Data.Digest.CRC32C 76 Data.Digest.CRC32C
77 Data.Bits.ByteString 77 Data.Bits.ByteString
78 Data.TableMethods 78 Data.TableMethods
79 Data.Torrent
80 Network.BitTorrent.DHT.ContactInfo 79 Network.BitTorrent.DHT.ContactInfo
81 Network.BitTorrent.DHT.Token 80 Network.BitTorrent.DHT.Token
82 Network.QueryResponse 81 Network.QueryResponse
@@ -222,6 +221,7 @@ library
222 , minmax-psq 221 , minmax-psq
223 , kad 222 , kad
224 , tasks 223 , tasks
224 , torrent-types
225 225
226 if impl(ghc < 8) 226 if impl(ghc < 8)
227 Build-depends: transformers 227 Build-depends: transformers
diff --git a/torrent-types/CHANGELOG.md b/torrent-types/CHANGELOG.md
new file mode 100644
index 00000000..ef14ae8c
--- /dev/null
+++ b/torrent-types/CHANGELOG.md
@@ -0,0 +1,5 @@
1# Revision history for torrents
2
3## 0.1.0.0 -- YYYY-mm-dd
4
5* First version. Released on an unsuspecting world.
diff --git a/torrent-types/LICENSE b/torrent-types/LICENSE
new file mode 100644
index 00000000..e8eaef49
--- /dev/null
+++ b/torrent-types/LICENSE
@@ -0,0 +1,30 @@
1Copyright (c) 2019, James Crayne
2
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10
11 * Redistributions in binary form must reproduce the above
12 copyright notice, this list of conditions and the following
13 disclaimer in the documentation and/or other materials provided
14 with the distribution.
15
16 * Neither the name of James Crayne nor the names of other
17 contributors may be used to endorse or promote products derived
18 from this software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/torrent-types/Setup.hs b/torrent-types/Setup.hs
new file mode 100644
index 00000000..9a994af6
--- /dev/null
+++ b/torrent-types/Setup.hs
@@ -0,0 +1,2 @@
1import Distribution.Simple
2main = defaultMain
diff --git a/torrent-types/src/Data/.Torrent.hs.swo b/torrent-types/src/Data/.Torrent.hs.swo
new file mode 100644
index 00000000..9f06d911
--- /dev/null
+++ b/torrent-types/src/Data/.Torrent.hs.swo
Binary files differ
diff --git a/torrent-types/src/Data/.Torrent.hs.swp b/torrent-types/src/Data/.Torrent.hs.swp
new file mode 100644
index 00000000..0aecaad6
--- /dev/null
+++ b/torrent-types/src/Data/.Torrent.hs.swp
Binary files differ
diff --git a/dht/src/Data/Torrent.hs b/torrent-types/src/Data/Torrent.hs
index 32c709be..a1eb286c 100644
--- a/dht/src/Data/Torrent.hs
+++ b/torrent-types/src/Data/Torrent.hs
@@ -28,6 +28,8 @@
28{-# LANGUAGE DeriveFoldable #-} 28{-# LANGUAGE DeriveFoldable #-}
29{-# LANGUAGE DeriveTraversable #-} 29{-# LANGUAGE DeriveTraversable #-}
30{-# LANGUAGE TemplateHaskell #-} 30{-# LANGUAGE TemplateHaskell #-}
31{-# LANGUAGE RecordWildCards #-}
32{-# LANGUAGE OverloadedStrings #-}
31{-# OPTIONS -fno-warn-orphans #-} 33{-# OPTIONS -fno-warn-orphans #-}
32module Data.Torrent 34module Data.Torrent
33 ( -- * InfoHash 35 ( -- * InfoHash
@@ -203,6 +205,15 @@ import Text.PrettyPrint as PP
203import Text.PrettyPrint.HughesPJClass hiding ((<>),($$)) 205import Text.PrettyPrint.HughesPJClass hiding ((<>),($$))
204import System.FilePath 206import System.FilePath
205import System.Posix.Types 207import System.Posix.Types
208#ifdef USE_lens
209#ifdef VERSION_lens
210import Control.Lens.TH
211#elif defined(VERSION_microlens_th)
212import Lens.Micro.TH
213#elif defined(VERSION_lens_family_th)
214import Lens.Family.TH
215#endif
216#endif
206 217
207import Network.Address 218import Network.Address
208 219
@@ -626,6 +637,7 @@ toPow2 :: Int -> Int
626#ifdef VERSION_bits_extras 637#ifdef VERSION_bits_extras
627toPow2 x = bit $ fromIntegral (leadingZeros (0 :: Int) - leadingZeros x) 638toPow2 x = bit $ fromIntegral (leadingZeros (0 :: Int) - leadingZeros x)
628#else 639#else
640-- base >= 4.8.0.0
629toPow2 x = bit $ fromIntegral (countLeadingZeros (0 :: Int) - countLeadingZeros x) 641toPow2 x = bit $ fromIntegral (countLeadingZeros (0 :: Int) - countLeadingZeros x)
630#endif 642#endif
631 643
@@ -782,7 +794,7 @@ data InfoDict = InfoDict
782 -- BEP 27: <http://www.bittorrent.org/beps/bep_0027.html> 794 -- BEP 27: <http://www.bittorrent.org/beps/bep_0027.html>
783 } deriving (Show, Read, Eq, Typeable) 795 } deriving (Show, Read, Eq, Typeable)
784 796
785#ifdef VERISON_lens 797#ifdef USE_lens
786makeLensesFor 798makeLensesFor
787 [ ("idInfoHash" , "infohash" ) 799 [ ("idInfoHash" , "infohash" )
788 , ("idLayoutInfo", "layoutInfo") 800 , ("idLayoutInfo", "layoutInfo")
@@ -944,6 +956,11 @@ instance BEncode POSIXTime where
944instance {-# OVERLAPPING #-} BEncode String where 956instance {-# OVERLAPPING #-} BEncode String where
945 toBEncode = toBEncode . T.pack 957 toBEncode = toBEncode . T.pack
946 fromBEncode v = T.unpack <$> fromBEncode v 958 fromBEncode v = T.unpack <$> fromBEncode v
959{-
960instance {-# OVERLAPPING #-} BEncode HostName where
961 toBEncode = toBEncode . T.pack
962 fromBEncode v = T.unpack <$> fromBEncode v
963-}
947 964
948instance BEncode Torrent where 965instance BEncode Torrent where
949 toBEncode Torrent {..} = toDict $ 966 toBEncode Torrent {..} = toDict $
diff --git a/torrent-types/torrent-types.cabal b/torrent-types/torrent-types.cabal
new file mode 100644
index 00000000..c5939983
--- /dev/null
+++ b/torrent-types/torrent-types.cabal
@@ -0,0 +1,51 @@
1cabal-version: >=1.10
2-- Initial package description 'torrents.cabal' generated by 'cabal init'.
3-- For further documentation, see http://haskell.org/cabal/users-guide/
4
5name: torrent-types
6version: 0.1.0.0
7-- synopsis:
8-- description:
9-- bug-reports:
10license: BSD3
11license-file: LICENSE
12author: James Crayne
13maintainer: jim.crayne@gmail.com
14-- copyright:
15-- category:
16build-type: Simple
17extra-source-files: CHANGELOG.md
18
19library
20 exposed-modules: Data.Torrent
21 -- other-modules:
22 other-extensions: CPP, NamedFieldPuns, FlexibleInstances, MultiParamTypeClasses, BangPatterns, GeneralizedNewtypeDeriving, StandaloneDeriving, DeriveDataTypeable, DeriveFunctor, DeriveFoldable, DeriveTraversable, TemplateHaskell
23 build-depends:
24 base
25 , deepseq
26 , memory
27 , bytestring
28 , base16-bytestring
29 , base64-bytestring
30 , hashable
31 , containers
32 , text
33 , time
34 , network < 2.7
35 , network-addr
36 , data-default
37 , network-uri
38 , cereal
39 , convertible
40 , pretty
41 , filepath
42 , base32-bytestring
43 , http-types
44 , cryptonite
45 , bencoding
46 , bits
47 , microlens-th
48 cpp-options: -DUSE_lens
49 hs-source-dirs: src
50 default-language: Haskell2010
51