summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-08-31 23:45:35 -0400
committerjoe <joe@jerkface.net>2017-08-31 23:45:35 -0400
commitf198e2b07a53603fa854b3a74702948493525613 (patch)
tree2db550e190cbd6b2ffc4ac8459afe065bc42a737
parent1f8782c9efbe5ebe384cfe892b29d7822d704283 (diff)
Miscelaneous exports and TODO: Bits NodeId
-rw-r--r--DHTTransport.hs13
-rw-r--r--ToxAddress.hs6
-rw-r--r--ToxCrypto.hs7
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 #-}
4module DHTTransport 5module 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
19import ToxAddress 21import 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
45mapMessage :: forall f b. (forall a. Nonce24 -> f a -> b) -> DHTMessage f -> b
46mapMessage f msg = f _todo _todo
47
43instance Sized GetNodes where 48instance 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)
41import System.IO.Unsafe (unsafeDupablePerformIO) 41import System.IO.Unsafe (unsafeDupablePerformIO)
42import qualified Text.ParserCombinators.ReadP as RP 42import qualified Text.ParserCombinators.ReadP as RP
43import Text.Read 43import Text.Read
44import 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
89instance Bits NodeId where -- TODO
90
91instance FiniteBits NodeId where
92 finiteBitSize _ = 256
93
88data NodeInfo = NodeInfo 94data 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
28import qualified Crypto.Cipher.Salsa as Salsa 29import qualified Crypto.Cipher.Salsa as Salsa