diff options
Diffstat (limited to 'src/Network/Tox.hs')
-rw-r--r-- | src/Network/Tox.hs | 14 |
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 | |||
89 | import Data.Word64Map (fitsInInt) | 89 | import Data.Word64Map (fitsInInt) |
90 | import qualified Data.Word64Map (empty) | 90 | import qualified Data.Word64Map (empty) |
91 | import Network.Tox.Crypto.Transport (NetCrypto) | 91 | import Network.Tox.Crypto.Transport (NetCrypto) |
92 | import Network.Tox.Crypto.Handlers (newSessionsState, cryptoNetHandler, defaultCryptoDataHooks) | 92 | import Network.Tox.Crypto.Handlers (cryptoNetHandler, newSessionsState, defaultUnRecHook, defaultCryptoDataHooks, NetCryptoSessions(..)) |
93 | import qualified Network.Tox.DHT.Handlers as DHT | 93 | import qualified Network.Tox.DHT.Handlers as DHT |
94 | import qualified Network.Tox.DHT.Transport as DHT | 94 | import qualified Network.Tox.DHT.Transport as DHT |
95 | import Network.Tox.NodeId | 95 | import 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 | ||
284 | newTox :: TVar Onion.AnnouncedKeys -> SockAddr -> IO Tox | 284 | newTox :: TVar Onion.AnnouncedKeys -> SockAddr -> Maybe NetCryptoSessions -> IO Tox |
285 | newTox keydb addr = do | 285 | newTox 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 |