diff options
author | James Crayne <jim.crayne@gmail.com> | 2017-11-01 16:59:50 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2017-11-01 16:59:50 +0000 |
commit | 1766abbd8e4072fa47a82c09daceeb4235f3564d (patch) | |
tree | 9bf2ae47af2a4cec249ae433f07956130b9c75ba | |
parent | 6880807978615fe52a28a1ca85134e4df68b9ac4 (diff) |
bring crypto-sessions state into scope
-rw-r--r-- | examples/dhtd.hs | 7 | ||||
-rw-r--r-- | src/Network/Tox.hs | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index bd9b9e09..c6643fb5 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -351,6 +351,7 @@ data Session = Session | |||
351 | , dhts :: Map.Map String DHT | 351 | , dhts :: Map.Map String DHT |
352 | , externalAddresses :: IO [SockAddr] | 352 | , externalAddresses :: IO [SockAddr] |
353 | , swarms :: Mainline.SwarmsDatabase | 353 | , swarms :: Mainline.SwarmsDatabase |
354 | , cryptosessions :: Tox.NetCryptoSessions | ||
354 | , toxkeys :: TVar Tox.AnnouncedKeys | 355 | , toxkeys :: TVar Tox.AnnouncedKeys |
355 | , userkeys :: TVar [(SecretKey,PublicKey)] | 356 | , userkeys :: TVar [(SecretKey,PublicKey)] |
356 | , roster :: Roster | 357 | , roster :: Roster |
@@ -880,12 +881,13 @@ main = do | |||
880 | 881 | ||
881 | keysdb <- Tox.newKeysDatabase | 882 | keysdb <- Tox.newKeysDatabase |
882 | 883 | ||
884 | crypto <- Tox.newCrypto | ||
885 | netCryptoSessionsState <- Tox.newSessionsState crypto Tox.defaultUnRecHook Tox.defaultCryptoDataHooks | ||
886 | |||
883 | (mbtox,quitTox,toxdhts,toxips,taddrs) <- case porttox opts of | 887 | (mbtox,quitTox,toxdhts,toxips,taddrs) <- case porttox opts of |
884 | "" -> return (Nothing,return (), Map.empty, return [],[]) | 888 | "" -> return (Nothing,return (), Map.empty, return [],[]) |
885 | toxport -> do | 889 | toxport -> do |
886 | addrTox <- getBindAddress toxport (ip6tox opts) | 890 | addrTox <- getBindAddress toxport (ip6tox opts) |
887 | crypto <- Tox.newCrypto | ||
888 | netCryptoSessionsState <- Tox.newSessionsState crypto Tox.defaultUnRecHook Tox.defaultCryptoDataHooks | ||
889 | tox <- Tox.newTox keysdb addrTox (Just netCryptoSessionsState) | 891 | tox <- Tox.newTox keysdb addrTox (Just netCryptoSessionsState) |
890 | quitTox <- Tox.forkTox tox | 892 | quitTox <- Tox.forkTox tox |
891 | 893 | ||
@@ -1008,6 +1010,7 @@ main = do | |||
1008 | , dhts = dhts -- all DHTs | 1010 | , dhts = dhts -- all DHTs |
1009 | , signalQuit = signalQuit | 1011 | , signalQuit = signalQuit |
1010 | , swarms = swarms | 1012 | , swarms = swarms |
1013 | , cryptosessions = netCryptoSessionsState | ||
1011 | , toxkeys = keysdb | 1014 | , toxkeys = keysdb |
1012 | , userkeys = toxids | 1015 | , userkeys = toxids |
1013 | , roster = rstr | 1016 | , roster = rstr |
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs index f73de4e9..0400f14a 100644 --- a/src/Network/Tox.hs +++ b/src/Network/Tox.hs | |||
@@ -219,6 +219,7 @@ data Tox = Tox | |||
219 | , toxOnion :: Onion.Client RouteId | 219 | , toxOnion :: Onion.Client RouteId |
220 | , toxToRoute :: Transport String Onion.AnnouncedRendezvous (PublicKey,Onion.OnionData) | 220 | , toxToRoute :: Transport String Onion.AnnouncedRendezvous (PublicKey,Onion.OnionData) |
221 | , toxCrypto :: Transport String SockAddr NetCrypto | 221 | , toxCrypto :: Transport String SockAddr NetCrypto |
222 | , toxCryptoSessions :: NetCryptoSessions | ||
222 | , toxCryptoKeys :: TransportCrypto | 223 | , toxCryptoKeys :: TransportCrypto |
223 | , toxRouting :: DHT.Routing | 224 | , toxRouting :: DHT.Routing |
224 | , toxTokens :: TVar SessionTokens | 225 | , toxTokens :: TVar SessionTokens |
@@ -319,6 +320,7 @@ newTox keydb addr mbSessionsState = do | |||
319 | , toxOnion = onionclient | 320 | , toxOnion = onionclient |
320 | , toxToRoute = onInbound (updateRoster roster) dtacrypt | 321 | , toxToRoute = onInbound (updateRoster roster) dtacrypt |
321 | , toxCrypto = addHandler (hPutStrLn stderr) (cryptoNetHandler sessionsState) cryptonet | 322 | , toxCrypto = addHandler (hPutStrLn stderr) (cryptoNetHandler sessionsState) cryptonet |
323 | , toxCryptoSessions = sessionsState | ||
322 | , toxCryptoKeys = crypto | 324 | , toxCryptoKeys = crypto |
323 | , toxRouting = routing | 325 | , toxRouting = routing |
324 | , toxTokens = toks | 326 | , toxTokens = toks |