From 368bb61f147b2b59cf33ada8e76f285a1992a4f1 Mon Sep 17 00:00:00 2001 From: James Crayne Date: Tue, 31 Oct 2017 03:55:35 +0000 Subject: NetCrypto wip --- src/Crypto/Tox.hs | 2 +- src/Network/Tox.hs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Crypto/Tox.hs b/src/Crypto/Tox.hs index 9f7c5e16..a25f9f4f 100644 --- a/src/Crypto/Tox.hs +++ b/src/Crypto/Tox.hs @@ -90,7 +90,7 @@ import Data.Word64Map (fitsInInt) -- | A 16-byte mac and an arbitrary-length encrypted stream. newtype Encrypted a = Encrypted ByteString - deriving (Eq,Ord,Data) + deriving (Eq,Ord,Data,ByteArrayAccess) newtype Encrypted8 a = E8 (Encrypted (a,Nonce8)) deriving (Serialize, Show) diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs index d5db6979..4cc762c4 100644 --- a/src/Network/Tox.hs +++ b/src/Network/Tox.hs @@ -89,6 +89,7 @@ import Crypto.Tox import Data.Word64Map (fitsInInt) import qualified Data.Word64Map (empty) import Network.Tox.Crypto.Transport (NetCrypto) +import Network.Tox.Crypto.Handlers (newSessionsState, cryptoNetHandler) import qualified Network.Tox.DHT.Handlers as DHT import qualified Network.Tox.DHT.Transport as DHT import Network.Tox.NodeId @@ -308,11 +309,12 @@ newTox keydb addr = do (const id) roster <- newRoster + sessionsState <- newSessionsState crypto return Tox { toxDHT = dhtclient , toxOnion = onionclient , toxToRoute = onInbound (updateRoster roster) dtacrypt - , toxCrypto = cryptonet + , toxCrypto = addHandler (error "printErrors stderr") (cryptoNetHandler sessionsState) cryptonet , toxCryptoKeys = crypto , toxRouting = routing , toxTokens = toks -- cgit v1.2.3