diff options
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/Address.hs | 4 | ||||
-rw-r--r-- | src/Network/BitTorrent/DHT/ContactInfo.hs | 1 | ||||
-rw-r--r-- | src/Network/BitTorrent/DHT/Token.hs | 1 | ||||
-rw-r--r-- | src/Network/BitTorrent/MainlineDHT.hs | 13 | ||||
-rw-r--r-- | src/Network/Kademlia.hs | 24 | ||||
-rw-r--r-- | src/Network/Kademlia/Bootstrap.hs | 16 | ||||
-rw-r--r-- | src/Network/Kademlia/Search.hs | 9 | ||||
-rw-r--r-- | src/Network/StreamServer.hs | 16 | ||||
-rw-r--r-- | src/Network/Tox.hs | 63 | ||||
-rw-r--r-- | src/Network/Tox/Avahi.hs | 2 | ||||
-rw-r--r-- | src/Network/Tox/ContactInfo.hs | 4 | ||||
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 10 | ||||
-rw-r--r-- | src/Network/Tox/DHT/Handlers.hs | 7 | ||||
-rw-r--r-- | src/Network/Tox/DHT/Transport.hs | 6 | ||||
-rw-r--r-- | src/Network/Tox/NodeId.hs | 2 | ||||
-rw-r--r-- | src/Network/Tox/Onion/Handlers.hs | 16 | ||||
-rw-r--r-- | src/Network/Tox/Onion/Transport.hs | 3 | ||||
-rw-r--r-- | src/Network/Tox/Transport.hs | 1 | ||||
-rw-r--r-- | src/Network/UPNP.hs | 1 |
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 |
111 | import Data.List as L | 111 | import Data.List as L |
112 | import Data.List.Split as L | 112 | import Data.List.Split as L |
113 | import Data.Maybe (fromMaybe, catMaybes, mapMaybe) | 113 | import Data.Maybe (fromMaybe, catMaybes) |
114 | import Data.Monoid | 114 | import Data.Monoid |
115 | import Data.Hashable | 115 | import Data.Hashable |
116 | import Data.Ord | ||
117 | import Data.Serialize as S | 116 | import Data.Serialize as S |
118 | import Data.String | 117 | import Data.String |
119 | import Data.Time | 118 | import Data.Time |
@@ -130,7 +129,6 @@ import Text.PrettyPrint.HughesPJClass hiding ((<>),($$)) | |||
130 | import System.Locale (defaultTimeLocale) | 129 | import System.Locale (defaultTimeLocale) |
131 | #endif | 130 | #endif |
132 | import System.Entropy | 131 | import System.Entropy |
133 | import System.IO (stderr) | ||
134 | import DPut | 132 | import 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 | |||
20 | import Data.Time.Clock.POSIX | 20 | import Data.Time.Clock.POSIX |
21 | import Data.ByteString (ByteString) | 21 | import Data.ByteString (ByteString) |
22 | import Data.Word | 22 | import Data.Word |
23 | import Network.Socket (SockAddr(..)) | ||
24 | 23 | ||
25 | import Data.Torrent | 24 | import Data.Torrent |
26 | import Network.Address | 25 | import 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 | |||
61 | import Data.Time | 61 | import Data.Time |
62 | import System.Random | 62 | import System.Random |
63 | import Control.Concurrent.STM | 63 | import Control.Concurrent.STM |
64 | import 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 | |||
23 | import Data.BEncode.Pretty | 23 | import Data.BEncode.Pretty |
24 | import Data.BEncode.Types (BDict) | 24 | import Data.BEncode.Types (BDict) |
25 | import Data.Bits | 25 | import Data.Bits |
26 | import Data.Bits.ByteString | 26 | import Data.Bits.ByteString () |
27 | import Data.Bool | 27 | import Data.Bool |
28 | import qualified Data.ByteArray as BA | 28 | import Data.ByteArray (ByteArrayAccess) |
29 | ;import Data.ByteArray (ByteArrayAccess) | ||
30 | import qualified Data.ByteString as B | 29 | import qualified Data.ByteString as B |
31 | ;import Data.ByteString (ByteString) | 30 | ;import Data.ByteString (ByteString) |
32 | import qualified Data.ByteString.Base16 as Base16 | 31 | import qualified Data.ByteString.Base16 as Base16 |
@@ -45,7 +44,6 @@ import Data.IP hiding (fromSockAddr) | |||
45 | #else | 44 | #else |
46 | import Data.IP | 45 | import Data.IP |
47 | #endif | 46 | #endif |
48 | import Data.List | ||
49 | import Data.Maybe | 47 | import Data.Maybe |
50 | import Data.Monoid | 48 | import Data.Monoid |
51 | import Data.Ord | 49 | import Data.Ord |
@@ -53,14 +51,13 @@ import qualified Data.Serialize as S | |||
53 | import Data.Set (Set) | 51 | import Data.Set (Set) |
54 | import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) | 52 | import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) |
55 | import Data.Torrent | 53 | import Data.Torrent |
56 | import Data.Typeable | ||
57 | import Data.Word | 54 | import Data.Word |
58 | import qualified Data.Wrapper.PSQInt as Int | 55 | import qualified Data.Wrapper.PSQInt as Int |
59 | import Debug.Trace | 56 | import Debug.Trace |
60 | import Network.BitTorrent.MainlineDHT.Symbols | 57 | import Network.BitTorrent.MainlineDHT.Symbols |
61 | import Network.Kademlia | 58 | import Network.Kademlia |
62 | import Network.Kademlia.Bootstrap | 59 | import Network.Kademlia.Bootstrap |
63 | import Network.Address (Address, fromAddr, fromSockAddr, | 60 | import 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 | |||
68 | import Network.Kademlia.Search (Search (..)) | 65 | import Network.Kademlia.Search (Search (..)) |
69 | import Network.BitTorrent.DHT.Token as Token | 66 | import Network.BitTorrent.DHT.Token as Token |
70 | import qualified Network.Kademlia.Routing as R | 67 | import qualified Network.Kademlia.Routing as R |
71 | ;import Network.Kademlia.Routing (Timestamp, getTimestamp) | 68 | ;import Network.Kademlia.Routing (getTimestamp) |
72 | import Network.QueryResponse | 69 | import Network.QueryResponse |
73 | import Network.Socket | 70 | import Network.Socket |
74 | import System.IO | ||
75 | import System.IO.Error | 71 | import System.IO.Error |
76 | import System.IO.Unsafe (unsafeInterleaveIO) | 72 | import System.IO.Unsafe (unsafeInterleaveIO) |
77 | import qualified Text.ParserCombinators.ReadP as RP | 73 | import qualified Text.ParserCombinators.ReadP as RP |
@@ -81,7 +77,6 @@ import Control.Concurrent.Lifted.Instrument | |||
81 | import Control.Concurrent.Lifted | 77 | import Control.Concurrent.Lifted |
82 | import GHC.Conc (labelThread) | 78 | import GHC.Conc (labelThread) |
83 | #endif | 79 | #endif |
84 | import Control.Exception (SomeException (..), handle) | ||
85 | import qualified Data.Aeson as JSON | 80 | import qualified Data.Aeson as JSON |
86 | ;import Data.Aeson (FromJSON, ToJSON, (.=)) | 81 | ;import Data.Aeson (FromJSON, ToJSON, (.=)) |
87 | import Text.Read | 82 | import 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 #-} |
7 | module Network.Kademlia where | 7 | module Network.Kademlia where |
8 | 8 | ||
9 | import Data.Function | ||
10 | import Data.Maybe | 9 | import Data.Maybe |
11 | import qualified Data.Set as Set | 10 | import Data.Time.Clock.POSIX |
12 | import Data.Time.Clock (getCurrentTime) | ||
13 | import Data.Time.Clock.POSIX (getPOSIXTime, utcTimeToPOSIXSeconds) | ||
14 | import Network.Kademlia.Routing as R | 11 | import Network.Kademlia.Routing as R |
15 | #ifdef THREAD_DEBUG | 12 | #ifdef THREAD_DEBUG |
16 | import Control.Concurrent.Lifted.Instrument | 13 | import Control.Concurrent.Lifted.Instrument |
@@ -20,24 +17,7 @@ import GHC.Conc (labelThread) | |||
20 | #endif | 17 | #endif |
21 | import Control.Concurrent.STM | 18 | import Control.Concurrent.STM |
22 | import Control.Monad | 19 | import Control.Monad |
23 | import Data.Bits | ||
24 | import Data.Hashable | ||
25 | #if MIN_VERSION_iproute(1,7,4) | ||
26 | import Data.IP hiding (fromSockAddr) | ||
27 | #else | ||
28 | import Data.IP | ||
29 | #endif | ||
30 | import Data.Monoid | ||
31 | import Data.Serialize (Serialize) | ||
32 | import Data.Time.Clock.POSIX (POSIXTime) | 20 | import Data.Time.Clock.POSIX (POSIXTime) |
33 | import Network.Address (bucketRange,genBucketSample) | ||
34 | import Network.Kademlia.Search | ||
35 | import System.Entropy | ||
36 | import System.Timeout | ||
37 | import Text.PrettyPrint as PP hiding (($$), (<>)) | ||
38 | import Text.PrettyPrint.HughesPJClass hiding (($$), (<>)) | ||
39 | import System.IO | ||
40 | import 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. |
43 | data RoutingStatus | 23 | data RoutingStatus |
@@ -147,7 +127,7 @@ accepted (_,y) = RoutingTransition y Accepted | |||
147 | insertNode :: Kademlia nid ni -> ni -> IO () | 127 | insertNode :: Kademlia nid ni -> ni -> IO () |
148 | insertNode (Kademlia reporter space io) node = do | 128 | insertNode (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 | |||
16 | import Data.Function | 16 | import Data.Function |
17 | import Data.Maybe | 17 | import Data.Maybe |
18 | import qualified Data.Set as Set | 18 | import qualified Data.Set as Set |
19 | import Data.Time.Clock (getCurrentTime) | 19 | import Data.Time.Clock.POSIX (getPOSIXTime) |
20 | import Data.Time.Clock.POSIX (getPOSIXTime, utcTimeToPOSIXSeconds) | ||
21 | import Network.Kademlia.Routing as R | 20 | import Network.Kademlia.Routing as R |
22 | #ifdef THREAD_DEBUG | 21 | #ifdef THREAD_DEBUG |
23 | import Control.Concurrent.Lifted.Instrument | 22 | import Control.Concurrent.Lifted.Instrument |
@@ -27,27 +26,16 @@ import GHC.Conc (labelThread) | |||
27 | #endif | 26 | #endif |
28 | import Control.Concurrent.STM | 27 | import Control.Concurrent.STM |
29 | import Control.Monad | 28 | import Control.Monad |
30 | import Data.Bits | ||
31 | import Data.Hashable | 29 | import Data.Hashable |
32 | #if MIN_VERSION_iproute(1,7,4) | ||
33 | import Data.IP hiding (fromSockAddr) | ||
34 | #else | ||
35 | import Data.IP | ||
36 | #endif | ||
37 | import Data.Monoid | ||
38 | import Data.Serialize (Serialize) | ||
39 | import Data.Time.Clock.POSIX (POSIXTime) | 30 | import Data.Time.Clock.POSIX (POSIXTime) |
40 | import Data.Ord | 31 | import Data.Ord |
41 | import System.Entropy | 32 | import System.Entropy |
42 | import System.Timeout | 33 | import System.Timeout |
43 | import Text.PrettyPrint as PP hiding (($$), (<>)) | ||
44 | import Text.PrettyPrint.HughesPJClass hiding (($$), (<>)) | ||
45 | import System.IO | ||
46 | import DPut | 34 | import DPut |
47 | 35 | ||
48 | import qualified Data.Wrapper.PSQInt as Int | 36 | import qualified Data.Wrapper.PSQInt as Int |
49 | ;import Data.Wrapper.PSQInt (pattern (:->)) | 37 | ;import Data.Wrapper.PSQInt (pattern (:->)) |
50 | import Network.Address (bucketRange,genBucketSample) | 38 | import Network.Address (bucketRange) |
51 | import Network.Kademlia.Search | 39 | import Network.Kademlia.Search |
52 | import Control.Concurrent.Tasks | 40 | import Control.Concurrent.Tasks |
53 | import Network.Kademlia | 41 | import 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 | ||
9 | import Control.Concurrent.Tasks | 9 | import Control.Concurrent.Tasks |
10 | import Control.Concurrent.STM | 10 | import Control.Concurrent.STM |
11 | import Control.Exception | ||
12 | import Control.Monad | 11 | import Control.Monad |
13 | import Data.Bool | ||
14 | import Data.Function | 12 | import Data.Function |
15 | import Data.List | ||
16 | import qualified Data.Map.Strict as Map | ||
17 | ;import Data.Map.Strict (Map) | ||
18 | import Data.Maybe | 13 | import Data.Maybe |
19 | import qualified Data.Set as Set | 14 | import qualified Data.Set as Set |
20 | ;import Data.Set (Set) | 15 | ;import Data.Set (Set) |
21 | import Data.Hashable (Hashable(..)) -- for type sigs | 16 | import Data.Hashable (Hashable(..)) -- for type sigs |
22 | import System.IO | ||
23 | import System.IO.Error | 17 | import System.IO.Error |
24 | 18 | ||
25 | import qualified Data.MinMaxPSQ as MM | 19 | import qualified Data.MinMaxPSQ as MM |
26 | ;import Data.MinMaxPSQ (MinMaxPSQ, MinMaxPSQ') | 20 | ;import Data.MinMaxPSQ (MinMaxPSQ, MinMaxPSQ') |
27 | import qualified Data.Wrapper.PSQ as PSQ | 21 | import 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) |
29 | import Network.Address hiding (NodeId) | ||
30 | import Network.Kademlia.Routing as R | 23 | import Network.Kademlia.Routing as R |
31 | #ifdef THREAD_DEBUG | 24 | #ifdef THREAD_DEBUG |
32 | import Control.Concurrent.Lifted.Instrument | 25 | import 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 | ||
16 | import Data.Monoid | 16 | import Data.Monoid |
17 | import Network.Socket as Socket | 17 | import Network.Socket as Socket |
18 | import Data.ByteString.Char8 | ||
19 | ( hGetNonBlocking | ||
20 | ) | ||
21 | import qualified Data.ByteString.Char8 as S | ||
22 | ( hPutStrLn | ||
23 | ) | ||
24 | import System.Directory (removeFile) | 18 | import System.Directory (removeFile) |
25 | import System.IO | 19 | import 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 |
48 | import Control.Exception (catch,handle,try,finally) | 36 | import Control.Exception (handle,finally) |
49 | import System.IO.Error (tryIOError) | 37 | import System.IO.Error (tryIOError) |
50 | import System.Mem.Weak | 38 | import System.Mem.Weak |
51 | import System.IO.Error | 39 | import System.IO.Error |
52 | 40 | ||
53 | -- import Data.Conduit | 41 | -- import Data.Conduit |
54 | import Control.Monad.IO.Class (MonadIO (liftIO)) | ||
55 | import qualified Data.ByteString as S (ByteString) | ||
56 | import System.IO (Handle) | 42 | import System.IO (Handle) |
57 | import Control.Concurrent.MVar (newMVar) | 43 | import 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 #-} |
18 | module Network.Tox where | 18 | module Network.Tox where |
19 | 19 | ||
20 | import Debug.Trace | ||
21 | import Control.Exception hiding (Handler) | ||
22 | import Control.Applicative | ||
23 | import Control.Arrow | ||
24 | #ifdef THREAD_DEBUG | 20 | #ifdef THREAD_DEBUG |
25 | import Control.Concurrent.Lifted.Instrument | 21 | import Control.Concurrent.Lifted.Instrument |
26 | #else | 22 | #else |
@@ -28,79 +24,27 @@ import Control.Concurrent.Lifted | |||
28 | #endif | 24 | #endif |
29 | import Control.Concurrent.STM | 25 | import Control.Concurrent.STM |
30 | import Control.Monad | 26 | import Control.Monad |
31 | import Control.Monad.Fix | ||
32 | import qualified Crypto.Cipher.ChaChaPoly1305 as Symmetric | ||
33 | import qualified Crypto.Cipher.Salsa as Salsa | ||
34 | import qualified Crypto.Cipher.XSalsa as XSalsa | ||
35 | import qualified Crypto.Error as Cryptonite | ||
36 | #ifdef CRYPTONITE_BACKPORT | ||
37 | import Crypto.ECC.Class | ||
38 | import Crypto.Error.Types | ||
39 | #else | ||
40 | import Crypto.ECC | ||
41 | import Crypto.Error | ||
42 | #endif | ||
43 | import qualified Crypto.MAC.Poly1305 as Poly1305 | ||
44 | import Crypto.PubKey.Curve25519 | 27 | import Crypto.PubKey.Curve25519 |
45 | import Crypto.PubKey.ECC.Types | ||
46 | import Crypto.Random | 28 | import Crypto.Random |
47 | import qualified Data.Aeson as JSON | ||
48 | ;import Data.Aeson (FromJSON, ToJSON, (.=)) | ||
49 | import Data.Bitraversable (bisequence) | ||
50 | import Data.Bits | ||
51 | import Data.Bits.ByteString () | 29 | import Data.Bits.ByteString () |
52 | import Data.Bool | ||
53 | import qualified Data.ByteArray as BA | ||
54 | ;import Data.ByteArray (ByteArrayAccess, Bytes) | ||
55 | import qualified Data.ByteString as B | 30 | import qualified Data.ByteString as B |
56 | ;import Data.ByteString (ByteString) | 31 | ;import Data.ByteString (ByteString) |
57 | import qualified Data.ByteString.Base16 as Base16 | ||
58 | import qualified Data.ByteString.Char8 as C8 | 32 | import qualified Data.ByteString.Char8 as C8 |
59 | import Data.ByteString.Lazy (toStrict) | ||
60 | import Data.Char | ||
61 | import Data.Conduit (Source,Sink,Flush(..)) | ||
62 | import Data.Data | 33 | import Data.Data |
63 | import Data.Functor.Contravariant | 34 | import Data.Functor.Contravariant |
64 | import Data.Hashable | ||
65 | #if MIN_VERSION_iproute(1,7,4) | ||
66 | import Data.IP hiding (fromSockAddr) | ||
67 | #else | ||
68 | import Data.IP | ||
69 | #endif | ||
70 | import Data.Maybe | 35 | import Data.Maybe |
71 | import qualified Data.MinMaxPSQ as MinMaxPSQ | 36 | import qualified Data.MinMaxPSQ as MinMaxPSQ |
72 | ;import Data.MinMaxPSQ (MinMaxPSQ') | ||
73 | import Data.Monoid | ||
74 | import Data.Ord | ||
75 | import qualified Data.Serialize as S | 37 | import qualified Data.Serialize as S |
76 | import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) | 38 | import Data.Time.Clock.POSIX (getPOSIXTime) |
77 | import Data.Typeable | ||
78 | import Data.Word | 39 | import Data.Word |
79 | import qualified Data.Wrapper.PSQ as PSQ | 40 | import qualified Data.Wrapper.PSQ as PSQ |
80 | ;import Data.Wrapper.PSQ (PSQ) | ||
81 | import qualified Data.Wrapper.PSQInt as Int | ||
82 | import Foreign.Marshal.Alloc | ||
83 | import Foreign.Ptr | ||
84 | import Foreign.Storable | ||
85 | import GHC.Generics (Generic) | ||
86 | import System.Global6 | 41 | import System.Global6 |
87 | import Network.Kademlia | 42 | import Network.Address (WantIP (..)) |
88 | import Network.Address (Address, WantIP (..), either4or6, | ||
89 | fromSockAddr, ipFamily, setPort, | ||
90 | sockAddrPort, testIdBit, | ||
91 | toSockAddr, un4map) | ||
92 | import Network.Kademlia.Search (Search (..)) | ||
93 | import qualified Network.Kademlia.Routing as R | 43 | import qualified Network.Kademlia.Routing as R |
94 | import Network.QueryResponse | 44 | import Network.QueryResponse |
95 | import Network.Socket | 45 | import Network.Socket |
96 | import System.Endian | 46 | import System.Endian |
97 | import System.IO | ||
98 | import qualified Text.ParserCombinators.ReadP as RP | ||
99 | import Text.Printf | ||
100 | import Text.Read | ||
101 | import Control.TriadCommittee | ||
102 | import Network.BitTorrent.DHT.Token as Token | 47 | import Network.BitTorrent.DHT.Token as Token |
103 | import GHC.TypeLits | ||
104 | 48 | ||
105 | import Connection | 49 | import Connection |
106 | import Connection.Tox | 50 | import Connection.Tox |
@@ -108,7 +52,7 @@ import Crypto.Tox | |||
108 | import Data.Word64Map (fitsInInt) | 52 | import Data.Word64Map (fitsInInt) |
109 | import qualified Data.Word64Map (empty) | 53 | import qualified Data.Word64Map (empty) |
110 | import Network.Kademlia.Bootstrap (forkPollForRefresh, bootstrap) | 54 | import Network.Kademlia.Bootstrap (forkPollForRefresh, bootstrap) |
111 | import Network.Tox.Crypto.Transport (CryptoMessage, HandshakeData(..), Handshake(..),CryptoPacket) | 55 | import Network.Tox.Crypto.Transport (Handshake(..),CryptoPacket) |
112 | import Network.Tox.Handshake | 56 | import Network.Tox.Handshake |
113 | import Network.Tox.Crypto.Handlers | 57 | import Network.Tox.Crypto.Handlers |
114 | import qualified Network.Tox.DHT.Handlers as DHT | 58 | import qualified Network.Tox.DHT.Handlers as DHT |
@@ -121,7 +65,6 @@ import OnionRouter | |||
121 | import Network.Tox.ContactInfo | 65 | import Network.Tox.ContactInfo |
122 | import Text.XXD | 66 | import Text.XXD |
123 | import qualified Data.HashMap.Strict as HashMap | 67 | import qualified Data.HashMap.Strict as HashMap |
124 | import Data.HashMap.Strict (HashMap) | ||
125 | import qualified Data.Map.Strict as Map | 68 | import qualified Data.Map.Strict as Map |
126 | import DPut | 69 | import DPut |
127 | import Network.Tox.Avahi | 70 | import 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 | ||
9 | import Data.Foldable | 9 | import Data.Foldable |
10 | import GHC.Word (Word16) | ||
11 | import Network.Address | 10 | import Network.Address |
12 | import Network.Avahi | 11 | import Network.Avahi |
13 | import Network.Socket | ||
14 | import Network.Tox.NodeId | 12 | import Network.Tox.NodeId |
15 | import Text.Read | 13 | import 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 #-} |
2 | module Network.Tox.ContactInfo where | 2 | module Network.Tox.ContactInfo where |
3 | 3 | ||
4 | import ConnectionKey | ||
5 | import Connection | 4 | import Connection |
6 | 5 | ||
7 | import Data.Time.Clock.POSIX | 6 | import Data.Time.Clock.POSIX |
@@ -11,13 +10,10 @@ import Crypto.PubKey.Curve25519 | |||
11 | import qualified Data.HashMap.Strict as HashMap | 10 | import qualified Data.HashMap.Strict as HashMap |
12 | ;import Data.HashMap.Strict (HashMap) | 11 | ;import Data.HashMap.Strict (HashMap) |
13 | import Data.Maybe | 12 | import Data.Maybe |
14 | import qualified Data.Set as Set | ||
15 | ;import Data.Set (Set) | ||
16 | import Network.Socket | 13 | import Network.Socket |
17 | import Network.Tox.DHT.Transport as DHT | 14 | import Network.Tox.DHT.Transport as DHT |
18 | import Network.Tox.NodeId (id2key) | 15 | import Network.Tox.NodeId (id2key) |
19 | import Network.Tox.Onion.Transport as Onion | 16 | import Network.Tox.Onion.Transport as Onion |
20 | import System.IO | ||
21 | import DPut | 17 | import DPut |
22 | 18 | ||
23 | newtype ContactInfo extra = ContactInfo | 19 | newtype 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 | ||
10 | import Network.Tox.NodeId | 10 | import Network.Tox.NodeId |
11 | import Network.Tox.Crypto.Transport | 11 | import Network.Tox.Crypto.Transport |
12 | import Network.Tox.DHT.Transport (Cookie(..),CookieData(..), CookieRequest(..), NoSpam(..)) | 12 | import Network.Tox.DHT.Transport (Cookie(..), NoSpam(..)) |
13 | import Network.Tox.DHT.Handlers (Client, cookieRequest, createCookieSTM ) | ||
14 | import Crypto.Tox | 13 | import Crypto.Tox |
15 | import Control.Arrow | 14 | import Control.Arrow |
16 | import Control.Concurrent.STM | 15 | import Control.Concurrent.STM |
17 | import Control.Concurrent.STM.TMChan | 16 | import Control.Concurrent.STM.TMChan |
18 | import Network.Address | 17 | import Network.Address |
19 | import qualified Data.Map.Strict as Map | 18 | import qualified Data.Map.Strict as Map |
20 | import Crypto.Hash | ||
21 | import Control.Applicative | ||
22 | import Control.Monad | 19 | import Control.Monad |
23 | import Data.Time.Clock.POSIX | 20 | import Data.Time.Clock.POSIX |
24 | import qualified Data.ByteString as B | 21 | import qualified Data.ByteString as B |
25 | import System.IO | ||
26 | import Data.ByteString (ByteString) | 22 | import Data.ByteString (ByteString) |
27 | import Control.Lens | 23 | import Control.Lens |
28 | import Data.Function | 24 | import Data.Function |
@@ -39,10 +35,8 @@ import qualified Data.Set as Set | |||
39 | import qualified Data.Array.Unboxed as A | 35 | import qualified Data.Array.Unboxed as A |
40 | import SensibleDir | 36 | import SensibleDir |
41 | import System.FilePath | 37 | import System.FilePath |
42 | import System.IO.Temp | ||
43 | import System.Environment | 38 | import System.Environment |
44 | import System.Directory | 39 | import System.Directory |
45 | import System.Random -- for ping fuzz | ||
46 | #ifdef THREAD_DEBUG | 40 | #ifdef THREAD_DEBUG |
47 | import Control.Concurrent.Lifted.Instrument | 41 | import Control.Concurrent.Lifted.Instrument |
48 | #else | 42 | #else |
@@ -54,11 +48,9 @@ import qualified Data.IntMap.Strict as IntMap | |||
54 | import Control.Concurrent.Supply | 48 | import Control.Concurrent.Supply |
55 | import Data.InOrOut | 49 | import Data.InOrOut |
56 | import DPut | 50 | import DPut |
57 | import Debug.Trace | ||
58 | import Text.Printf | 51 | import Text.Printf |
59 | import Data.Bool | 52 | import Data.Bool |
60 | import Connection (Status(..), Policy(..)) | 53 | import Connection (Status(..), Policy(..)) |
61 | import Network.Tox.ContactInfo | ||
62 | import Network.Tox.Handshake | 54 | import 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 | |||
14 | import qualified Data.Wrapper.PSQInt as Int | 14 | import qualified Data.Wrapper.PSQInt as Int |
15 | import Network.Kademlia | 15 | import Network.Kademlia |
16 | import Network.Kademlia.Bootstrap | 16 | import Network.Kademlia.Bootstrap |
17 | import Network.Address (WantIP (..), ipFamily, testIdBit,fromSockAddr, sockAddrPort) | 17 | import Network.Address (WantIP (..), ipFamily, fromSockAddr, sockAddrPort) |
18 | import qualified Network.Kademlia.Routing as R | 18 | import qualified Network.Kademlia.Routing as R |
19 | import Control.TriadCommittee | 19 | import Control.TriadCommittee |
20 | import System.Global6 | 20 | import System.Global6 |
@@ -29,7 +29,6 @@ import Control.Concurrent.Lifted.Instrument | |||
29 | import Control.Concurrent.STM | 29 | import Control.Concurrent.STM |
30 | import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) | 30 | import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) |
31 | import Network.Socket | 31 | import Network.Socket |
32 | import Data.Hashable | ||
33 | import qualified Data.HashMap.Strict as HashMap | 32 | import 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 |
38 | import Data.IP | 37 | import Data.IP |
39 | #endif | 38 | #endif |
40 | import Data.Ord | ||
41 | import Data.Maybe | 39 | import Data.Maybe |
42 | import Data.Bits | ||
43 | import Data.Serialize (Serialize) | 40 | import Data.Serialize (Serialize) |
44 | import Data.Word | 41 | import Data.Word |
45 | import Data.List | ||
46 | import System.IO | ||
47 | import DPut | 42 | import DPut |
48 | 43 | ||
49 | data TransactionId = TransactionId | 44 | data 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 | |||
45 | import Control.Concurrent.STM | 44 | import Control.Concurrent.STM |
46 | import Control.Monad | 45 | import Control.Monad |
47 | import Data.Bool | 46 | import Data.Bool |
48 | import qualified Data.ByteString.Char8 as B8 | ||
49 | import qualified Data.ByteString as B | 47 | import qualified Data.ByteString as B |
50 | ;import Data.ByteString (ByteString) | 48 | ;import Data.ByteString (ByteString) |
51 | import Data.Functor.Contravariant | 49 | import Data.Functor.Contravariant |
@@ -54,11 +52,7 @@ import Data.Monoid | |||
54 | import Data.Serialize as S | 52 | import Data.Serialize as S |
55 | import Data.Tuple | 53 | import Data.Tuple |
56 | import Data.Word | 54 | import Data.Word |
57 | import Foreign.C (CTime(..)) | ||
58 | import Network.Socket | 55 | import Network.Socket |
59 | import qualified Data.ByteString.Base64 as Base64 | ||
60 | import qualified Data.ByteString.Base16 as Base16 | ||
61 | import Data.Char (isSpace) | ||
62 | 56 | ||
63 | type DHTTransport = Transport String NodeInfo (DHTMessage Encrypted8) | 57 | type DHTTransport = Transport String NodeInfo (DHTMessage Encrypted8) |
64 | type HandleHi a = Maybe (Either String (DHTMessage Encrypted8, NodeInfo)) -> IO a | 58 | type 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 | ||
38 | import Debug.Trace | ||
39 | import Control.Applicative | 38 | import Control.Applicative |
40 | import Control.Arrow | 39 | import Control.Arrow |
41 | import Control.Monad | 40 | import Control.Monad |
@@ -83,7 +82,6 @@ import System.Endian | |||
83 | import qualified Data.Text as Text | 82 | import qualified Data.Text as Text |
84 | ;import Data.Text (Text) | 83 | ;import Data.Text (Text) |
85 | import Util (splitJID) | 84 | import Util (splitJID) |
86 | import 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) | |||
12 | import Crypto.Tox | 12 | import Crypto.Tox |
13 | import qualified Data.Wrapper.PSQ as PSQ | 13 | import qualified Data.Wrapper.PSQ as PSQ |
14 | ;import Data.Wrapper.PSQ (PSQ,pattern (:->)) | 14 | ;import Data.Wrapper.PSQ (PSQ,pattern (:->)) |
15 | #ifdef CRYPTONITE_BACKPORT | ||
16 | import Crypto.Error.Types (CryptoFailable (..), | ||
17 | throwCryptoError) | ||
18 | #else | ||
19 | import Crypto.Error | ||
20 | #endif | ||
21 | import Control.Arrow | 15 | import Control.Arrow |
22 | 16 | ||
23 | import System.IO | ||
24 | import qualified Data.ByteArray as BA | ||
25 | import Data.Function | 17 | import Data.Function |
26 | import Data.Serialize as S | ||
27 | import qualified Data.Wrapper.PSQInt as Int | ||
28 | import Network.Kademlia | ||
29 | import Network.Address (WantIP (..), ipFamily, testIdBit) | ||
30 | import qualified Network.Kademlia.Routing as R | ||
31 | import Control.TriadCommittee | ||
32 | import qualified Data.MinMaxPSQ as MinMaxPSQ | 18 | import qualified Data.MinMaxPSQ as MinMaxPSQ |
33 | ;import Data.MinMaxPSQ (MinMaxPSQ') | 19 | ;import Data.MinMaxPSQ (MinMaxPSQ') |
34 | import Network.BitTorrent.DHT.Token as Token | 20 | import Network.BitTorrent.DHT.Token as Token |
@@ -50,8 +36,6 @@ import Data.IP hiding (fromSockAddr) | |||
50 | import Data.IP | 36 | import Data.IP |
51 | #endif | 37 | #endif |
52 | import Data.Maybe | 38 | import Data.Maybe |
53 | import Data.Bits | ||
54 | import Data.Ord | ||
55 | import Data.Functor.Identity | 39 | import Data.Functor.Identity |
56 | import DPut | 40 | import 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 | |||
62 | import Control.Monad | 62 | import Control.Monad |
63 | import qualified Data.ByteString as B | 63 | import qualified Data.ByteString as B |
64 | ;import Data.ByteString (ByteString) | 64 | ;import Data.ByteString (ByteString) |
65 | import Data.Coerce | ||
66 | import Data.Function | 65 | import Data.Function |
67 | import Data.Functor.Contravariant | 66 | import Data.Functor.Contravariant |
68 | import Data.Functor.Identity | 67 | import Data.Functor.Identity |
@@ -77,11 +76,9 @@ import Data.Serialize as S | |||
77 | import Data.Type.Equality | 76 | import Data.Type.Equality |
78 | import Data.Typeable | 77 | import Data.Typeable |
79 | import Data.Word | 78 | import Data.Word |
80 | import Debug.Trace | ||
81 | import GHC.Generics () | 79 | import GHC.Generics () |
82 | import GHC.TypeLits | 80 | import GHC.TypeLits |
83 | import Network.Socket | 81 | import Network.Socket |
84 | import System.IO | ||
85 | import qualified Text.ParserCombinators.ReadP as RP | 82 | import qualified Text.ParserCombinators.ReadP as RP |
86 | import Data.Hashable | 83 | import Data.Hashable |
87 | import DPut | 84 | import 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 #-} |
9 | module Network.Tox.Transport (toxTransport, RouteId) where | 9 | module Network.Tox.Transport (toxTransport, RouteId) where |
10 | 10 | ||
11 | import Data.ByteString (ByteString) | ||
12 | import Network.QueryResponse | 11 | import Network.QueryResponse |
13 | import Crypto.Tox | 12 | import Crypto.Tox |
14 | import Network.Tox.DHT.Transport | 13 | import 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 | |||
4 | import Network.Address (sockAddrPort) | 4 | import Network.Address (sockAddrPort) |
5 | import Network.Socket | 5 | import Network.Socket |
6 | import System.Directory | 6 | import System.Directory |
7 | import System.IO | ||
8 | import System.Process as Process | 7 | import System.Process as Process |
9 | import DPut | 8 | import DPut |
10 | 9 | ||