summaryrefslogtreecommitdiff
path: root/src/Network/Tox.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox.hs')
-rw-r--r--src/Network/Tox.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs
index 70962844..f73de4e9 100644
--- a/src/Network/Tox.hs
+++ b/src/Network/Tox.hs
@@ -89,7 +89,7 @@ import Crypto.Tox
89import Data.Word64Map (fitsInInt) 89import Data.Word64Map (fitsInInt)
90import qualified Data.Word64Map (empty) 90import qualified Data.Word64Map (empty)
91import Network.Tox.Crypto.Transport (NetCrypto) 91import Network.Tox.Crypto.Transport (NetCrypto)
92import Network.Tox.Crypto.Handlers (newSessionsState, cryptoNetHandler, defaultCryptoDataHooks) 92import Network.Tox.Crypto.Handlers (cryptoNetHandler, newSessionsState, defaultUnRecHook, defaultCryptoDataHooks, NetCryptoSessions(..))
93import qualified Network.Tox.DHT.Handlers as DHT 93import qualified Network.Tox.DHT.Handlers as DHT
94import qualified Network.Tox.DHT.Transport as DHT 94import qualified Network.Tox.DHT.Transport as DHT
95import Network.Tox.NodeId 95import Network.Tox.NodeId
@@ -281,10 +281,15 @@ getOnionAlias crypto dhtself remoteNode = atomically $ do
281 return $ Onion.OnionDestination Onion.SearchingAlias alias Nothing 281 return $ Onion.OnionDestination Onion.SearchingAlias alias Nothing
282 282
283 283
284newTox :: TVar Onion.AnnouncedKeys -> SockAddr -> IO Tox 284newTox :: TVar Onion.AnnouncedKeys -> SockAddr -> Maybe NetCryptoSessions -> IO Tox
285newTox keydb addr = do 285newTox keydb addr mbSessionsState = do
286 udp <- addVerbosity <$> udpTransport addr 286 udp <- addVerbosity <$> udpTransport addr
287 crypto <- newCrypto 287 (crypto,sessionsState) <- case mbSessionsState of
288 Nothing -> do
289 crypto <- newCrypto
290 sessionsState <- newSessionsState crypto defaultUnRecHook defaultCryptoDataHooks
291 return (crypto,sessionsState)
292 Just s -> return (transportCrypto s, s)
288 drg <- drgNew 293 drg <- drgNew
289 let lookupClose _ = return Nothing 294 let lookupClose _ = return Nothing
290 295
@@ -309,7 +314,6 @@ newTox keydb addr = do
309 (const id) 314 (const id)
310 315
311 roster <- newRoster 316 roster <- newRoster
312 sessionsState <- newSessionsState crypto defaultCryptoDataHooks
313 return Tox 317 return Tox
314 { toxDHT = dhtclient 318 { toxDHT = dhtclient
315 , toxOnion = onionclient 319 , toxOnion = onionclient