diff options
-rw-r--r-- | DHTTransport.hs | 13 | ||||
-rw-r--r-- | ToxAddress.hs | 6 | ||||
-rw-r--r-- | ToxCrypto.hs | 7 |
3 files changed, 19 insertions, 7 deletions
diff --git a/DHTTransport.hs b/DHTTransport.hs index 3de276f1..97a8113c 100644 --- a/DHTTransport.hs +++ b/DHTTransport.hs | |||
@@ -1,19 +1,21 @@ | |||
1 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} | 1 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} |
2 | {-# LANGUAGE KindSignatures #-} | 2 | {-# LANGUAGE KindSignatures #-} |
3 | {-# LANGUAGE LambdaCase #-} | 3 | {-# LANGUAGE LambdaCase #-} |
4 | {-# LANGUAGE RankNTypes #-} | ||
4 | module DHTTransport | 5 | module DHTTransport |
5 | ( parseDHTAddr | 6 | ( parseDHTAddr |
6 | , encodeDHTAddr | 7 | , encodeDHTAddr |
7 | , forwardDHTRequests | 8 | , forwardDHTRequests |
8 | , module ToxAddress | 9 | , module ToxAddress |
9 | , DHTMessage(..) | 10 | , DHTMessage(..) |
10 | , Ping | 11 | , Ping(..) |
11 | , Pong | 12 | , Pong(..) |
12 | , GetNodes | 13 | , GetNodes(..) |
13 | , SendNodes | 14 | , SendNodes(..) |
14 | , CookieRequest | 15 | , CookieRequest |
15 | , Cookie | 16 | , Cookie |
16 | , DHTRequest | 17 | , DHTRequest |
18 | , mapMessage | ||
17 | ) where | 19 | ) where |
18 | 20 | ||
19 | import ToxAddress | 21 | import ToxAddress |
@@ -40,6 +42,9 @@ data DHTMessage (f :: * -> *) | |||
40 | | DHTCookie Nonce24 (f Cookie) | 42 | | DHTCookie Nonce24 (f Cookie) |
41 | | DHTDHTRequest PublicKey (Assym (f DHTRequest)) | 43 | | DHTDHTRequest PublicKey (Assym (f DHTRequest)) |
42 | 44 | ||
45 | mapMessage :: forall f b. (forall a. Nonce24 -> f a -> b) -> DHTMessage f -> b | ||
46 | mapMessage f msg = f _todo _todo | ||
47 | |||
43 | instance Sized GetNodes where | 48 | instance Sized GetNodes where |
44 | size = ConstSize 32 -- TODO This right? | 49 | size = ConstSize 32 -- TODO This right? |
45 | 50 | ||
diff --git a/ToxAddress.hs b/ToxAddress.hs index 9aa7a575..f0d4aba3 100644 --- a/ToxAddress.hs +++ b/ToxAddress.hs | |||
@@ -41,6 +41,7 @@ import Network.Address hiding (nodePort) | |||
41 | import System.IO.Unsafe (unsafeDupablePerformIO) | 41 | import System.IO.Unsafe (unsafeDupablePerformIO) |
42 | import qualified Text.ParserCombinators.ReadP as RP | 42 | import qualified Text.ParserCombinators.ReadP as RP |
43 | import Text.Read | 43 | import Text.Read |
44 | import Data.Bits | ||
44 | 45 | ||
45 | -- | perform io for hashes that do allocation and ffi. | 46 | -- | perform io for hashes that do allocation and ffi. |
46 | -- unsafeDupablePerformIO is used when possible as the | 47 | -- unsafeDupablePerformIO is used when possible as the |
@@ -85,6 +86,11 @@ instance S.Serialize NodeId where | |||
85 | get = NodeId . throwCryptoError . publicKey <$> S.getBytes 32 | 86 | get = NodeId . throwCryptoError . publicKey <$> S.getBytes 32 |
86 | put (NodeId bs) = S.putByteString $ BA.convert bs | 87 | put (NodeId bs) = S.putByteString $ BA.convert bs |
87 | 88 | ||
89 | instance Bits NodeId where -- TODO | ||
90 | |||
91 | instance FiniteBits NodeId where | ||
92 | finiteBitSize _ = 256 | ||
93 | |||
88 | data NodeInfo = NodeInfo | 94 | data NodeInfo = NodeInfo |
89 | { nodeId :: NodeId | 95 | { nodeId :: NodeId |
90 | , nodeIP :: IP | 96 | , nodeIP :: IP |
diff --git a/ToxCrypto.hs b/ToxCrypto.hs index 4a8de635..6b5e6f19 100644 --- a/ToxCrypto.hs +++ b/ToxCrypto.hs | |||
@@ -15,14 +15,15 @@ module ToxCrypto | |||
15 | , computeSharedSecret | 15 | , computeSharedSecret |
16 | , encrypt | 16 | , encrypt |
17 | , decrypt | 17 | , decrypt |
18 | , Nonce8 | 18 | , Nonce8(..) |
19 | , Nonce24 | 19 | , Nonce24(..) |
20 | , Nonce32 | 20 | , Nonce32(..) |
21 | , getRemainingEncrypted | 21 | , getRemainingEncrypted |
22 | , putEncrypted | 22 | , putEncrypted |
23 | , Auth | 23 | , Auth |
24 | , Sized(..) | 24 | , Sized(..) |
25 | , Size(..) | 25 | , Size(..) |
26 | , State(..) | ||
26 | ) where | 27 | ) where |
27 | 28 | ||
28 | import qualified Crypto.Cipher.Salsa as Salsa | 29 | import qualified Crypto.Cipher.Salsa as Salsa |