summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network')
-rw-r--r--src/Network/Address.hs4
-rw-r--r--src/Network/BitTorrent/DHT/ContactInfo.hs1
-rw-r--r--src/Network/BitTorrent/DHT/Token.hs1
-rw-r--r--src/Network/BitTorrent/MainlineDHT.hs13
-rw-r--r--src/Network/Kademlia.hs24
-rw-r--r--src/Network/Kademlia/Bootstrap.hs16
-rw-r--r--src/Network/Kademlia/Search.hs9
-rw-r--r--src/Network/StreamServer.hs16
-rw-r--r--src/Network/Tox.hs63
-rw-r--r--src/Network/Tox/Avahi.hs2
-rw-r--r--src/Network/Tox/ContactInfo.hs4
-rw-r--r--src/Network/Tox/Crypto/Handlers.hs10
-rw-r--r--src/Network/Tox/DHT/Handlers.hs7
-rw-r--r--src/Network/Tox/DHT/Transport.hs6
-rw-r--r--src/Network/Tox/NodeId.hs2
-rw-r--r--src/Network/Tox/Onion/Handlers.hs16
-rw-r--r--src/Network/Tox/Onion/Transport.hs3
-rw-r--r--src/Network/Tox/Transport.hs1
-rw-r--r--src/Network/UPNP.hs1
19 files changed, 16 insertions, 183 deletions
diff --git a/src/Network/Address.hs b/src/Network/Address.hs
index 367f608b..3adfdc91 100644
--- a/src/Network/Address.hs
+++ b/src/Network/Address.hs
@@ -110,10 +110,9 @@ import Data.IP
110#endif 110#endif
111import Data.List as L 111import Data.List as L
112import Data.List.Split as L 112import Data.List.Split as L
113import Data.Maybe (fromMaybe, catMaybes, mapMaybe) 113import Data.Maybe (fromMaybe, catMaybes)
114import Data.Monoid 114import Data.Monoid
115import Data.Hashable 115import Data.Hashable
116import Data.Ord
117import Data.Serialize as S 116import Data.Serialize as S
118import Data.String 117import Data.String
119import Data.Time 118import Data.Time
@@ -130,7 +129,6 @@ import Text.PrettyPrint.HughesPJClass hiding ((<>),($$))
130import System.Locale (defaultTimeLocale) 129import System.Locale (defaultTimeLocale)
131#endif 130#endif
132import System.Entropy 131import System.Entropy
133import System.IO (stderr)
134import DPut 132import DPut
135 133
136-- import Paths_bittorrent (version) 134-- import Paths_bittorrent (version)
diff --git a/src/Network/BitTorrent/DHT/ContactInfo.hs b/src/Network/BitTorrent/DHT/ContactInfo.hs
index ed38caf7..ec7e6658 100644
--- a/src/Network/BitTorrent/DHT/ContactInfo.hs
+++ b/src/Network/BitTorrent/DHT/ContactInfo.hs
@@ -20,7 +20,6 @@ import Data.Wrapper.PSQ as PSQ
20import Data.Time.Clock.POSIX 20import Data.Time.Clock.POSIX
21import Data.ByteString (ByteString) 21import Data.ByteString (ByteString)
22import Data.Word 22import Data.Word
23import Network.Socket (SockAddr(..))
24 23
25import Data.Torrent 24import Data.Torrent
26import Network.Address 25import Network.Address
diff --git a/src/Network/BitTorrent/DHT/Token.hs b/src/Network/BitTorrent/DHT/Token.hs
index 3da59c53..171cc8be 100644
--- a/src/Network/BitTorrent/DHT/Token.hs
+++ b/src/Network/BitTorrent/DHT/Token.hs
@@ -61,7 +61,6 @@ import Data.String
61import Data.Time 61import Data.Time
62import System.Random 62import System.Random
63import Control.Concurrent.STM 63import Control.Concurrent.STM
64import Network.Address
65 64
66-- TODO use ShortByteString 65-- TODO use ShortByteString
67 66
diff --git a/src/Network/BitTorrent/MainlineDHT.hs b/src/Network/BitTorrent/MainlineDHT.hs
index 626f980f..c5b99234 100644
--- a/src/Network/BitTorrent/MainlineDHT.hs
+++ b/src/Network/BitTorrent/MainlineDHT.hs
@@ -23,10 +23,9 @@ import qualified Data.BEncode.BDict as BE
23import Data.BEncode.Pretty 23import Data.BEncode.Pretty
24import Data.BEncode.Types (BDict) 24import Data.BEncode.Types (BDict)
25import Data.Bits 25import Data.Bits
26import Data.Bits.ByteString 26import Data.Bits.ByteString ()
27import Data.Bool 27import Data.Bool
28import qualified Data.ByteArray as BA 28import Data.ByteArray (ByteArrayAccess)
29 ;import Data.ByteArray (ByteArrayAccess)
30import qualified Data.ByteString as B 29import qualified Data.ByteString as B
31 ;import Data.ByteString (ByteString) 30 ;import Data.ByteString (ByteString)
32import qualified Data.ByteString.Base16 as Base16 31import qualified Data.ByteString.Base16 as Base16
@@ -45,7 +44,6 @@ import Data.IP hiding (fromSockAddr)
45#else 44#else
46import Data.IP 45import Data.IP
47#endif 46#endif
48import Data.List
49import Data.Maybe 47import Data.Maybe
50import Data.Monoid 48import Data.Monoid
51import Data.Ord 49import Data.Ord
@@ -53,14 +51,13 @@ import qualified Data.Serialize as S
53import Data.Set (Set) 51import Data.Set (Set)
54import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) 52import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime)
55import Data.Torrent 53import Data.Torrent
56import Data.Typeable
57import Data.Word 54import Data.Word
58import qualified Data.Wrapper.PSQInt as Int 55import qualified Data.Wrapper.PSQInt as Int
59import Debug.Trace 56import Debug.Trace
60import Network.BitTorrent.MainlineDHT.Symbols 57import Network.BitTorrent.MainlineDHT.Symbols
61import Network.Kademlia 58import Network.Kademlia
62import Network.Kademlia.Bootstrap 59import Network.Kademlia.Bootstrap
63import Network.Address (Address, fromAddr, fromSockAddr, 60import Network.Address (fromSockAddr,
64 setPort, sockAddrPort, testIdBit, 61 setPort, sockAddrPort, testIdBit,
65 toSockAddr, genBucketSample', WantIP(..), 62 toSockAddr, genBucketSample', WantIP(..),
66 un4map,either4or6,ipFamily) 63 un4map,either4or6,ipFamily)
@@ -68,10 +65,9 @@ import Network.BitTorrent.DHT.ContactInfo as Peers
68import Network.Kademlia.Search (Search (..)) 65import Network.Kademlia.Search (Search (..))
69import Network.BitTorrent.DHT.Token as Token 66import Network.BitTorrent.DHT.Token as Token
70import qualified Network.Kademlia.Routing as R 67import qualified Network.Kademlia.Routing as R
71 ;import Network.Kademlia.Routing (Timestamp, getTimestamp) 68 ;import Network.Kademlia.Routing (getTimestamp)
72import Network.QueryResponse 69import Network.QueryResponse
73import Network.Socket 70import Network.Socket
74import System.IO
75import System.IO.Error 71import System.IO.Error
76import System.IO.Unsafe (unsafeInterleaveIO) 72import System.IO.Unsafe (unsafeInterleaveIO)
77import qualified Text.ParserCombinators.ReadP as RP 73import qualified Text.ParserCombinators.ReadP as RP
@@ -81,7 +77,6 @@ import Control.Concurrent.Lifted.Instrument
81import Control.Concurrent.Lifted 77import Control.Concurrent.Lifted
82import GHC.Conc (labelThread) 78import GHC.Conc (labelThread)
83#endif 79#endif
84import Control.Exception (SomeException (..), handle)
85import qualified Data.Aeson as JSON 80import qualified Data.Aeson as JSON
86 ;import Data.Aeson (FromJSON, ToJSON, (.=)) 81 ;import Data.Aeson (FromJSON, ToJSON, (.=))
87import Text.Read 82import Text.Read
diff --git a/src/Network/Kademlia.hs b/src/Network/Kademlia.hs
index 50c98967..44ef2ec1 100644
--- a/src/Network/Kademlia.hs
+++ b/src/Network/Kademlia.hs
@@ -6,11 +6,8 @@
6{-# LANGUAGE PatternSynonyms #-} 6{-# LANGUAGE PatternSynonyms #-}
7module Network.Kademlia where 7module Network.Kademlia where
8 8
9import Data.Function
10import Data.Maybe 9import Data.Maybe
11import qualified Data.Set as Set 10import Data.Time.Clock.POSIX
12import Data.Time.Clock (getCurrentTime)
13import Data.Time.Clock.POSIX (getPOSIXTime, utcTimeToPOSIXSeconds)
14import Network.Kademlia.Routing as R 11import Network.Kademlia.Routing as R
15#ifdef THREAD_DEBUG 12#ifdef THREAD_DEBUG
16import Control.Concurrent.Lifted.Instrument 13import Control.Concurrent.Lifted.Instrument
@@ -20,24 +17,7 @@ import GHC.Conc (labelThread)
20#endif 17#endif
21import Control.Concurrent.STM 18import Control.Concurrent.STM
22import Control.Monad 19import Control.Monad
23import Data.Bits
24import Data.Hashable
25#if MIN_VERSION_iproute(1,7,4)
26import Data.IP hiding (fromSockAddr)
27#else
28import Data.IP
29#endif
30import Data.Monoid
31import Data.Serialize (Serialize)
32import Data.Time.Clock.POSIX (POSIXTime) 20import Data.Time.Clock.POSIX (POSIXTime)
33import Network.Address (bucketRange,genBucketSample)
34import Network.Kademlia.Search
35import System.Entropy
36import System.Timeout
37import Text.PrettyPrint as PP hiding (($$), (<>))
38import Text.PrettyPrint.HughesPJClass hiding (($$), (<>))
39import System.IO
40import Control.Concurrent.Tasks
41 21
42-- | The status of a given node with respect to a given routint table. 22-- | The status of a given node with respect to a given routint table.
43data RoutingStatus 23data RoutingStatus
@@ -147,7 +127,7 @@ accepted (_,y) = RoutingTransition y Accepted
147insertNode :: Kademlia nid ni -> ni -> IO () 127insertNode :: Kademlia nid ni -> ni -> IO ()
148insertNode (Kademlia reporter space io) node = do 128insertNode (Kademlia reporter space io) node = do
149 129
150 tm <- utcTimeToPOSIXSeconds <$> getCurrentTime 130 tm <- getPOSIXTime
151 131
152 (ps,reaction) <- atomically $ do 132 (ps,reaction) <- atomically $ do
153 tbl <- tblRead io 133 tbl <- tblRead io
diff --git a/src/Network/Kademlia/Bootstrap.hs b/src/Network/Kademlia/Bootstrap.hs
index 4197e06e..1a70a9c5 100644
--- a/src/Network/Kademlia/Bootstrap.hs
+++ b/src/Network/Kademlia/Bootstrap.hs
@@ -16,8 +16,7 @@ module Network.Kademlia.Bootstrap where
16import Data.Function 16import Data.Function
17import Data.Maybe 17import Data.Maybe
18import qualified Data.Set as Set 18import qualified Data.Set as Set
19import Data.Time.Clock (getCurrentTime) 19import Data.Time.Clock.POSIX (getPOSIXTime)
20import Data.Time.Clock.POSIX (getPOSIXTime, utcTimeToPOSIXSeconds)
21import Network.Kademlia.Routing as R 20import Network.Kademlia.Routing as R
22#ifdef THREAD_DEBUG 21#ifdef THREAD_DEBUG
23import Control.Concurrent.Lifted.Instrument 22import Control.Concurrent.Lifted.Instrument
@@ -27,27 +26,16 @@ import GHC.Conc (labelThread)
27#endif 26#endif
28import Control.Concurrent.STM 27import Control.Concurrent.STM
29import Control.Monad 28import Control.Monad
30import Data.Bits
31import Data.Hashable 29import Data.Hashable
32#if MIN_VERSION_iproute(1,7,4)
33import Data.IP hiding (fromSockAddr)
34#else
35import Data.IP
36#endif
37import Data.Monoid
38import Data.Serialize (Serialize)
39import Data.Time.Clock.POSIX (POSIXTime) 30import Data.Time.Clock.POSIX (POSIXTime)
40import Data.Ord 31import Data.Ord
41import System.Entropy 32import System.Entropy
42import System.Timeout 33import System.Timeout
43import Text.PrettyPrint as PP hiding (($$), (<>))
44import Text.PrettyPrint.HughesPJClass hiding (($$), (<>))
45import System.IO
46import DPut 34import DPut
47 35
48import qualified Data.Wrapper.PSQInt as Int 36import qualified Data.Wrapper.PSQInt as Int
49 ;import Data.Wrapper.PSQInt (pattern (:->)) 37 ;import Data.Wrapper.PSQInt (pattern (:->))
50import Network.Address (bucketRange,genBucketSample) 38import Network.Address (bucketRange)
51import Network.Kademlia.Search 39import Network.Kademlia.Search
52import Control.Concurrent.Tasks 40import Control.Concurrent.Tasks
53import Network.Kademlia 41import Network.Kademlia
diff --git a/src/Network/Kademlia/Search.hs b/src/Network/Kademlia/Search.hs
index 29a8fc61..e13e0742 100644
--- a/src/Network/Kademlia/Search.hs
+++ b/src/Network/Kademlia/Search.hs
@@ -8,25 +8,18 @@ module Network.Kademlia.Search where
8 8
9import Control.Concurrent.Tasks 9import Control.Concurrent.Tasks
10import Control.Concurrent.STM 10import Control.Concurrent.STM
11import Control.Exception
12import Control.Monad 11import Control.Monad
13import Data.Bool
14import Data.Function 12import Data.Function
15import Data.List
16import qualified Data.Map.Strict as Map
17 ;import Data.Map.Strict (Map)
18import Data.Maybe 13import Data.Maybe
19import qualified Data.Set as Set 14import qualified Data.Set as Set
20 ;import Data.Set (Set) 15 ;import Data.Set (Set)
21import Data.Hashable (Hashable(..)) -- for type sigs 16import Data.Hashable (Hashable(..)) -- for type sigs
22import System.IO
23import System.IO.Error 17import System.IO.Error
24 18
25import qualified Data.MinMaxPSQ as MM 19import qualified Data.MinMaxPSQ as MM
26 ;import Data.MinMaxPSQ (MinMaxPSQ, MinMaxPSQ') 20 ;import Data.MinMaxPSQ (MinMaxPSQ, MinMaxPSQ')
27import qualified Data.Wrapper.PSQ as PSQ 21import qualified Data.Wrapper.PSQ as PSQ
28 ;import Data.Wrapper.PSQ (pattern (:->), Binding, pattern Binding, Binding', PSQ, PSQKey) 22 ;import Data.Wrapper.PSQ (pattern (:->), Binding, pattern Binding, Binding', PSQKey)
29import Network.Address hiding (NodeId)
30import Network.Kademlia.Routing as R 23import Network.Kademlia.Routing as R
31#ifdef THREAD_DEBUG 24#ifdef THREAD_DEBUG
32import Control.Concurrent.Lifted.Instrument 25import Control.Concurrent.Lifted.Instrument
diff --git a/src/Network/StreamServer.hs b/src/Network/StreamServer.hs
index 01680b77..2734f0cd 100644
--- a/src/Network/StreamServer.hs
+++ b/src/Network/StreamServer.hs
@@ -15,21 +15,9 @@ module Network.StreamServer
15 15
16import Data.Monoid 16import Data.Monoid
17import Network.Socket as Socket 17import Network.Socket as Socket
18import Data.ByteString.Char8
19 ( hGetNonBlocking
20 )
21import qualified Data.ByteString.Char8 as S
22 ( hPutStrLn
23 )
24import System.Directory (removeFile) 18import System.Directory (removeFile)
25import System.IO 19import System.IO
26 ( IOMode(..) 20 ( IOMode(..)
27 , hSetBuffering
28 , BufferMode(..)
29 , hWaitForInput
30 , hClose
31 , hIsEOF
32 , hPutStrLn
33 , stderr 21 , stderr
34 , hFlush 22 , hFlush
35 ) 23 )
@@ -45,14 +33,12 @@ import Control.Concurrent
45 ( forkIO, threadDelay, ThreadId, mkWeakThreadId, myThreadId 33 ( forkIO, threadDelay, ThreadId, mkWeakThreadId, myThreadId
46 , killThread ) 34 , killThread )
47#endif 35#endif
48import Control.Exception (catch,handle,try,finally) 36import Control.Exception (handle,finally)
49import System.IO.Error (tryIOError) 37import System.IO.Error (tryIOError)
50import System.Mem.Weak 38import System.Mem.Weak
51import System.IO.Error 39import System.IO.Error
52 40
53-- import Data.Conduit 41-- import Data.Conduit
54import Control.Monad.IO.Class (MonadIO (liftIO))
55import qualified Data.ByteString as S (ByteString)
56import System.IO (Handle) 42import System.IO (Handle)
57import Control.Concurrent.MVar (newMVar) 43import Control.Concurrent.MVar (newMVar)
58 44
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs
index fcfa872f..f7cf7b1e 100644
--- a/src/Network/Tox.hs
+++ b/src/Network/Tox.hs
@@ -17,10 +17,6 @@
17{-# LANGUAGE ViewPatterns #-} 17{-# LANGUAGE ViewPatterns #-}
18module Network.Tox where 18module Network.Tox where
19 19
20import Debug.Trace
21import Control.Exception hiding (Handler)
22import Control.Applicative
23import Control.Arrow
24#ifdef THREAD_DEBUG 20#ifdef THREAD_DEBUG
25import Control.Concurrent.Lifted.Instrument 21import Control.Concurrent.Lifted.Instrument
26#else 22#else
@@ -28,79 +24,27 @@ import Control.Concurrent.Lifted
28#endif 24#endif
29import Control.Concurrent.STM 25import Control.Concurrent.STM
30import Control.Monad 26import Control.Monad
31import Control.Monad.Fix
32import qualified Crypto.Cipher.ChaChaPoly1305 as Symmetric
33import qualified Crypto.Cipher.Salsa as Salsa
34import qualified Crypto.Cipher.XSalsa as XSalsa
35import qualified Crypto.Error as Cryptonite
36#ifdef CRYPTONITE_BACKPORT
37import Crypto.ECC.Class
38import Crypto.Error.Types
39#else
40import Crypto.ECC
41import Crypto.Error
42#endif
43import qualified Crypto.MAC.Poly1305 as Poly1305
44import Crypto.PubKey.Curve25519 27import Crypto.PubKey.Curve25519
45import Crypto.PubKey.ECC.Types
46import Crypto.Random 28import Crypto.Random
47import qualified Data.Aeson as JSON
48 ;import Data.Aeson (FromJSON, ToJSON, (.=))
49import Data.Bitraversable (bisequence)
50import Data.Bits
51import Data.Bits.ByteString () 29import Data.Bits.ByteString ()
52import Data.Bool
53import qualified Data.ByteArray as BA
54 ;import Data.ByteArray (ByteArrayAccess, Bytes)
55import qualified Data.ByteString as B 30import qualified Data.ByteString as B
56 ;import Data.ByteString (ByteString) 31 ;import Data.ByteString (ByteString)
57import qualified Data.ByteString.Base16 as Base16
58import qualified Data.ByteString.Char8 as C8 32import qualified Data.ByteString.Char8 as C8
59import Data.ByteString.Lazy (toStrict)
60import Data.Char
61import Data.Conduit (Source,Sink,Flush(..))
62import Data.Data 33import Data.Data
63import Data.Functor.Contravariant 34import Data.Functor.Contravariant
64import Data.Hashable
65#if MIN_VERSION_iproute(1,7,4)
66import Data.IP hiding (fromSockAddr)
67#else
68import Data.IP
69#endif
70import Data.Maybe 35import Data.Maybe
71import qualified Data.MinMaxPSQ as MinMaxPSQ 36import qualified Data.MinMaxPSQ as MinMaxPSQ
72 ;import Data.MinMaxPSQ (MinMaxPSQ')
73import Data.Monoid
74import Data.Ord
75import qualified Data.Serialize as S 37import qualified Data.Serialize as S
76import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) 38import Data.Time.Clock.POSIX (getPOSIXTime)
77import Data.Typeable
78import Data.Word 39import Data.Word
79import qualified Data.Wrapper.PSQ as PSQ 40import qualified Data.Wrapper.PSQ as PSQ
80 ;import Data.Wrapper.PSQ (PSQ)
81import qualified Data.Wrapper.PSQInt as Int
82import Foreign.Marshal.Alloc
83import Foreign.Ptr
84import Foreign.Storable
85import GHC.Generics (Generic)
86import System.Global6 41import System.Global6
87import Network.Kademlia 42import Network.Address (WantIP (..))
88import Network.Address (Address, WantIP (..), either4or6,
89 fromSockAddr, ipFamily, setPort,
90 sockAddrPort, testIdBit,
91 toSockAddr, un4map)
92import Network.Kademlia.Search (Search (..))
93import qualified Network.Kademlia.Routing as R 43import qualified Network.Kademlia.Routing as R
94import Network.QueryResponse 44import Network.QueryResponse
95import Network.Socket 45import Network.Socket
96import System.Endian 46import System.Endian
97import System.IO
98import qualified Text.ParserCombinators.ReadP as RP
99import Text.Printf
100import Text.Read
101import Control.TriadCommittee
102import Network.BitTorrent.DHT.Token as Token 47import Network.BitTorrent.DHT.Token as Token
103import GHC.TypeLits
104 48
105import Connection 49import Connection
106import Connection.Tox 50import Connection.Tox
@@ -108,7 +52,7 @@ import Crypto.Tox
108import Data.Word64Map (fitsInInt) 52import Data.Word64Map (fitsInInt)
109import qualified Data.Word64Map (empty) 53import qualified Data.Word64Map (empty)
110import Network.Kademlia.Bootstrap (forkPollForRefresh, bootstrap) 54import Network.Kademlia.Bootstrap (forkPollForRefresh, bootstrap)
111import Network.Tox.Crypto.Transport (CryptoMessage, HandshakeData(..), Handshake(..),CryptoPacket) 55import Network.Tox.Crypto.Transport (Handshake(..),CryptoPacket)
112import Network.Tox.Handshake 56import Network.Tox.Handshake
113import Network.Tox.Crypto.Handlers 57import Network.Tox.Crypto.Handlers
114import qualified Network.Tox.DHT.Handlers as DHT 58import qualified Network.Tox.DHT.Handlers as DHT
@@ -121,7 +65,6 @@ import OnionRouter
121import Network.Tox.ContactInfo 65import Network.Tox.ContactInfo
122import Text.XXD 66import Text.XXD
123import qualified Data.HashMap.Strict as HashMap 67import qualified Data.HashMap.Strict as HashMap
124import Data.HashMap.Strict (HashMap)
125import qualified Data.Map.Strict as Map 68import qualified Data.Map.Strict as Map
126import DPut 69import DPut
127import Network.Tox.Avahi 70import Network.Tox.Avahi
diff --git a/src/Network/Tox/Avahi.hs b/src/Network/Tox/Avahi.hs
index ed52de74..7fe87db2 100644
--- a/src/Network/Tox/Avahi.hs
+++ b/src/Network/Tox/Avahi.hs
@@ -7,10 +7,8 @@ module Network.Tox.Avahi
7 ) where 7 ) where
8 8
9import Data.Foldable 9import Data.Foldable
10import GHC.Word (Word16)
11import Network.Address 10import Network.Address
12import Network.Avahi 11import Network.Avahi
13import Network.Socket
14import Network.Tox.NodeId 12import Network.Tox.NodeId
15import Text.Read 13import Text.Read
16 14
diff --git a/src/Network/Tox/ContactInfo.hs b/src/Network/Tox/ContactInfo.hs
index e76e2f1b..3f794197 100644
--- a/src/Network/Tox/ContactInfo.hs
+++ b/src/Network/Tox/ContactInfo.hs
@@ -1,7 +1,6 @@
1{-# LANGUAGE NamedFieldPuns #-} 1{-# LANGUAGE NamedFieldPuns #-}
2module Network.Tox.ContactInfo where 2module Network.Tox.ContactInfo where
3 3
4import ConnectionKey
5import Connection 4import Connection
6 5
7import Data.Time.Clock.POSIX 6import Data.Time.Clock.POSIX
@@ -11,13 +10,10 @@ import Crypto.PubKey.Curve25519
11import qualified Data.HashMap.Strict as HashMap 10import qualified Data.HashMap.Strict as HashMap
12 ;import Data.HashMap.Strict (HashMap) 11 ;import Data.HashMap.Strict (HashMap)
13import Data.Maybe 12import Data.Maybe
14import qualified Data.Set as Set
15 ;import Data.Set (Set)
16import Network.Socket 13import Network.Socket
17import Network.Tox.DHT.Transport as DHT 14import Network.Tox.DHT.Transport as DHT
18import Network.Tox.NodeId (id2key) 15import Network.Tox.NodeId (id2key)
19import Network.Tox.Onion.Transport as Onion 16import Network.Tox.Onion.Transport as Onion
20import System.IO
21import DPut 17import DPut
22 18
23newtype ContactInfo extra = ContactInfo 19newtype ContactInfo extra = ContactInfo
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs
index 73e5f686..282a7dce 100644
--- a/src/Network/Tox/Crypto/Handlers.hs
+++ b/src/Network/Tox/Crypto/Handlers.hs
@@ -9,20 +9,16 @@ module Network.Tox.Crypto.Handlers where
9 9
10import Network.Tox.NodeId 10import Network.Tox.NodeId
11import Network.Tox.Crypto.Transport 11import Network.Tox.Crypto.Transport
12import Network.Tox.DHT.Transport (Cookie(..),CookieData(..), CookieRequest(..), NoSpam(..)) 12import Network.Tox.DHT.Transport (Cookie(..), NoSpam(..))
13import Network.Tox.DHT.Handlers (Client, cookieRequest, createCookieSTM )
14import Crypto.Tox 13import Crypto.Tox
15import Control.Arrow 14import Control.Arrow
16import Control.Concurrent.STM 15import Control.Concurrent.STM
17import Control.Concurrent.STM.TMChan 16import Control.Concurrent.STM.TMChan
18import Network.Address 17import Network.Address
19import qualified Data.Map.Strict as Map 18import qualified Data.Map.Strict as Map
20import Crypto.Hash
21import Control.Applicative
22import Control.Monad 19import Control.Monad
23import Data.Time.Clock.POSIX 20import Data.Time.Clock.POSIX
24import qualified Data.ByteString as B 21import qualified Data.ByteString as B
25import System.IO
26import Data.ByteString (ByteString) 22import Data.ByteString (ByteString)
27import Control.Lens 23import Control.Lens
28import Data.Function 24import Data.Function
@@ -39,10 +35,8 @@ import qualified Data.Set as Set
39import qualified Data.Array.Unboxed as A 35import qualified Data.Array.Unboxed as A
40import SensibleDir 36import SensibleDir
41import System.FilePath 37import System.FilePath
42import System.IO.Temp
43import System.Environment 38import System.Environment
44import System.Directory 39import System.Directory
45import System.Random -- for ping fuzz
46#ifdef THREAD_DEBUG 40#ifdef THREAD_DEBUG
47import Control.Concurrent.Lifted.Instrument 41import Control.Concurrent.Lifted.Instrument
48#else 42#else
@@ -54,11 +48,9 @@ import qualified Data.IntMap.Strict as IntMap
54import Control.Concurrent.Supply 48import Control.Concurrent.Supply
55import Data.InOrOut 49import Data.InOrOut
56import DPut 50import DPut
57import Debug.Trace
58import Text.Printf 51import Text.Printf
59import Data.Bool 52import Data.Bool
60import Connection (Status(..), Policy(..)) 53import Connection (Status(..), Policy(..))
61import Network.Tox.ContactInfo
62import Network.Tox.Handshake 54import Network.Tox.Handshake
63 55
64-- | This type indicates the progress of a tox encrypted friend link 56-- | This type indicates the progress of a tox encrypted friend link
diff --git a/src/Network/Tox/DHT/Handlers.hs b/src/Network/Tox/DHT/Handlers.hs
index 6c29e958..09d6f66b 100644
--- a/src/Network/Tox/DHT/Handlers.hs
+++ b/src/Network/Tox/DHT/Handlers.hs
@@ -14,7 +14,7 @@ import Network.Kademlia.Search
14import qualified Data.Wrapper.PSQInt as Int 14import qualified Data.Wrapper.PSQInt as Int
15import Network.Kademlia 15import Network.Kademlia
16import Network.Kademlia.Bootstrap 16import Network.Kademlia.Bootstrap
17import Network.Address (WantIP (..), ipFamily, testIdBit,fromSockAddr, sockAddrPort) 17import Network.Address (WantIP (..), ipFamily, fromSockAddr, sockAddrPort)
18import qualified Network.Kademlia.Routing as R 18import qualified Network.Kademlia.Routing as R
19import Control.TriadCommittee 19import Control.TriadCommittee
20import System.Global6 20import System.Global6
@@ -29,7 +29,6 @@ import Control.Concurrent.Lifted.Instrument
29import Control.Concurrent.STM 29import Control.Concurrent.STM
30import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) 30import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime)
31import Network.Socket 31import Network.Socket
32import Data.Hashable
33import qualified Data.HashMap.Strict as HashMap 32import qualified Data.HashMap.Strict as HashMap
34 ;import Data.HashMap.Strict (HashMap) 33 ;import Data.HashMap.Strict (HashMap)
35#if MIN_VERSION_iproute(1,7,4) 34#if MIN_VERSION_iproute(1,7,4)
@@ -37,13 +36,9 @@ import Data.IP hiding (fromSockAddr)
37#else 36#else
38import Data.IP 37import Data.IP
39#endif 38#endif
40import Data.Ord
41import Data.Maybe 39import Data.Maybe
42import Data.Bits
43import Data.Serialize (Serialize) 40import Data.Serialize (Serialize)
44import Data.Word 41import Data.Word
45import Data.List
46import System.IO
47import DPut 42import DPut
48 43
49data TransactionId = TransactionId 44data TransactionId = TransactionId
diff --git a/src/Network/Tox/DHT/Transport.hs b/src/Network/Tox/DHT/Transport.hs
index 9ff1839c..c6fe121c 100644
--- a/src/Network/Tox/DHT/Transport.hs
+++ b/src/Network/Tox/DHT/Transport.hs
@@ -21,7 +21,6 @@ module Network.Tox.DHT.Transport
21 , DHTPublicKey(..) 21 , DHTPublicKey(..)
22 , FriendRequest(..) 22 , FriendRequest(..)
23 , NoSpam(..) 23 , NoSpam(..)
24 , verifyChecksum
25 , CookieRequest(..) 24 , CookieRequest(..)
26 , CookieResponse(..) 25 , CookieResponse(..)
27 , Cookie(..) 26 , Cookie(..)
@@ -45,7 +44,6 @@ import Control.Arrow
45import Control.Concurrent.STM 44import Control.Concurrent.STM
46import Control.Monad 45import Control.Monad
47import Data.Bool 46import Data.Bool
48import qualified Data.ByteString.Char8 as B8
49import qualified Data.ByteString as B 47import qualified Data.ByteString as B
50 ;import Data.ByteString (ByteString) 48 ;import Data.ByteString (ByteString)
51import Data.Functor.Contravariant 49import Data.Functor.Contravariant
@@ -54,11 +52,7 @@ import Data.Monoid
54import Data.Serialize as S 52import Data.Serialize as S
55import Data.Tuple 53import Data.Tuple
56import Data.Word 54import Data.Word
57import Foreign.C (CTime(..))
58import Network.Socket 55import Network.Socket
59import qualified Data.ByteString.Base64 as Base64
60import qualified Data.ByteString.Base16 as Base16
61import Data.Char (isSpace)
62 56
63type DHTTransport = Transport String NodeInfo (DHTMessage Encrypted8) 57type DHTTransport = Transport String NodeInfo (DHTMessage Encrypted8)
64type HandleHi a = Maybe (Either String (DHTMessage Encrypted8, NodeInfo)) -> IO a 58type HandleHi a = Maybe (Either String (DHTMessage Encrypted8, NodeInfo)) -> IO a
diff --git a/src/Network/Tox/NodeId.hs b/src/Network/Tox/NodeId.hs
index 2f836b8e..f9cf22a8 100644
--- a/src/Network/Tox/NodeId.hs
+++ b/src/Network/Tox/NodeId.hs
@@ -35,7 +35,6 @@ module Network.Tox.NodeId
35 , nospam16 35 , nospam16
36 , verifyChecksum) where 36 , verifyChecksum) where
37 37
38import Debug.Trace
39import Control.Applicative 38import Control.Applicative
40import Control.Arrow 39import Control.Arrow
41import Control.Monad 40import Control.Monad
@@ -83,7 +82,6 @@ import System.Endian
83import qualified Data.Text as Text 82import qualified Data.Text as Text
84 ;import Data.Text (Text) 83 ;import Data.Text (Text)
85import Util (splitJID) 84import Util (splitJID)
86import Text.Printf
87 85
88-- | perform io for hashes that do allocation and ffi. 86-- | perform io for hashes that do allocation and ffi.
89-- unsafeDupablePerformIO is used when possible as the 87-- unsafeDupablePerformIO is used when possible as the
diff --git a/src/Network/Tox/Onion/Handlers.hs b/src/Network/Tox/Onion/Handlers.hs
index f497a1bf..80a6ae3a 100644
--- a/src/Network/Tox/Onion/Handlers.hs
+++ b/src/Network/Tox/Onion/Handlers.hs
@@ -12,23 +12,9 @@ import qualified Network.QueryResponse as QR (Client)
12import Crypto.Tox 12import Crypto.Tox
13import qualified Data.Wrapper.PSQ as PSQ 13import qualified Data.Wrapper.PSQ as PSQ
14 ;import Data.Wrapper.PSQ (PSQ,pattern (:->)) 14 ;import Data.Wrapper.PSQ (PSQ,pattern (:->))
15#ifdef CRYPTONITE_BACKPORT
16import Crypto.Error.Types (CryptoFailable (..),
17 throwCryptoError)
18#else
19import Crypto.Error
20#endif
21import Control.Arrow 15import Control.Arrow
22 16
23import System.IO
24import qualified Data.ByteArray as BA
25import Data.Function 17import Data.Function
26import Data.Serialize as S
27import qualified Data.Wrapper.PSQInt as Int
28import Network.Kademlia
29import Network.Address (WantIP (..), ipFamily, testIdBit)
30import qualified Network.Kademlia.Routing as R
31import Control.TriadCommittee
32import qualified Data.MinMaxPSQ as MinMaxPSQ 18import qualified Data.MinMaxPSQ as MinMaxPSQ
33 ;import Data.MinMaxPSQ (MinMaxPSQ') 19 ;import Data.MinMaxPSQ (MinMaxPSQ')
34import Network.BitTorrent.DHT.Token as Token 20import Network.BitTorrent.DHT.Token as Token
@@ -50,8 +36,6 @@ import Data.IP hiding (fromSockAddr)
50import Data.IP 36import Data.IP
51#endif 37#endif
52import Data.Maybe 38import Data.Maybe
53import Data.Bits
54import Data.Ord
55import Data.Functor.Identity 39import Data.Functor.Identity
56import DPut 40import DPut
57 41
diff --git a/src/Network/Tox/Onion/Transport.hs b/src/Network/Tox/Onion/Transport.hs
index 70714465..e2e136ae 100644
--- a/src/Network/Tox/Onion/Transport.hs
+++ b/src/Network/Tox/Onion/Transport.hs
@@ -62,7 +62,6 @@ import Control.Concurrent.STM
62import Control.Monad 62import Control.Monad
63import qualified Data.ByteString as B 63import qualified Data.ByteString as B
64 ;import Data.ByteString (ByteString) 64 ;import Data.ByteString (ByteString)
65import Data.Coerce
66import Data.Function 65import Data.Function
67import Data.Functor.Contravariant 66import Data.Functor.Contravariant
68import Data.Functor.Identity 67import Data.Functor.Identity
@@ -77,11 +76,9 @@ import Data.Serialize as S
77import Data.Type.Equality 76import Data.Type.Equality
78import Data.Typeable 77import Data.Typeable
79import Data.Word 78import Data.Word
80import Debug.Trace
81import GHC.Generics () 79import GHC.Generics ()
82import GHC.TypeLits 80import GHC.TypeLits
83import Network.Socket 81import Network.Socket
84import System.IO
85import qualified Text.ParserCombinators.ReadP as RP 82import qualified Text.ParserCombinators.ReadP as RP
86import Data.Hashable 83import Data.Hashable
87import DPut 84import DPut
diff --git a/src/Network/Tox/Transport.hs b/src/Network/Tox/Transport.hs
index 57f07aad..0b03ed19 100644
--- a/src/Network/Tox/Transport.hs
+++ b/src/Network/Tox/Transport.hs
@@ -8,7 +8,6 @@
8{-# LANGUAGE TypeOperators #-} 8{-# LANGUAGE TypeOperators #-}
9module Network.Tox.Transport (toxTransport, RouteId) where 9module Network.Tox.Transport (toxTransport, RouteId) where
10 10
11import Data.ByteString (ByteString)
12import Network.QueryResponse 11import Network.QueryResponse
13import Crypto.Tox 12import Crypto.Tox
14import Network.Tox.DHT.Transport 13import Network.Tox.DHT.Transport
diff --git a/src/Network/UPNP.hs b/src/Network/UPNP.hs
index f053369f..e89471c2 100644
--- a/src/Network/UPNP.hs
+++ b/src/Network/UPNP.hs
@@ -4,7 +4,6 @@ import Data.Maybe
4import Network.Address (sockAddrPort) 4import Network.Address (sockAddrPort)
5import Network.Socket 5import Network.Socket
6import System.Directory 6import System.Directory
7import System.IO
8import System.Process as Process 7import System.Process as Process
9import DPut 8import DPut
10 9