diff options
author | joe <joe@jerkface.net> | 2018-06-02 00:25:00 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-06-02 00:25:00 -0400 |
commit | e086fb825a24293725b5c57cc567739c4ca796db (patch) | |
tree | 0a98acbd1085d55e888e508c6117c940fef804bb /src/Network/Tox.hs | |
parent | 3433bee9e382b650a924d60502f9286a850568d0 (diff) |
Delete NetCrypto type, separate transports for Handshake,CryptoPacket.
Diffstat (limited to 'src/Network/Tox.hs')
-rw-r--r-- | src/Network/Tox.hs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs index 8b966266..7ee4dbe0 100644 --- a/src/Network/Tox.hs +++ b/src/Network/Tox.hs | |||
@@ -97,7 +97,7 @@ import Crypto.Tox | |||
97 | import Data.Word64Map (fitsInInt) | 97 | import Data.Word64Map (fitsInInt) |
98 | import qualified Data.Word64Map (empty) | 98 | import qualified Data.Word64Map (empty) |
99 | import Network.Kademlia.Bootstrap (forkPollForRefresh, bootstrap) | 99 | import Network.Kademlia.Bootstrap (forkPollForRefresh, bootstrap) |
100 | import Network.Tox.Crypto.Transport (NetCrypto(..), CryptoMessage, HandshakeData(..), Handshake(..),CryptoPacket) | 100 | import Network.Tox.Crypto.Transport (CryptoMessage, HandshakeData(..), Handshake(..),CryptoPacket) |
101 | import Network.Tox.Crypto.Handlers | 101 | import Network.Tox.Crypto.Handlers |
102 | import qualified Network.Tox.DHT.Handlers as DHT | 102 | import qualified Network.Tox.DHT.Handlers as DHT |
103 | import qualified Network.Tox.DHT.Transport as DHT | 103 | import qualified Network.Tox.DHT.Transport as DHT |
@@ -441,17 +441,10 @@ newTox keydb addr mbSessionsState suppliedDHTKey = do | |||
441 | let ignoreErrors _ = return () -- Set this to (hPutStrLn stderr) to debug onion route building. | 441 | let ignoreErrors _ = return () -- Set this to (hPutStrLn stderr) to debug onion route building. |
442 | orouter <- newOnionRouter ignoreErrors | 442 | orouter <- newOnionRouter ignoreErrors |
443 | (cryptonet,dhtcrypt,onioncrypt,dtacrypt,handshakes) <- toxTransport crypto orouter lookupClose udp | 443 | (cryptonet,dhtcrypt,onioncrypt,dtacrypt,handshakes) <- toxTransport crypto orouter lookupClose udp |
444 | let sessionsState = sessionsState0 { sessionTransport = nc_combo | 444 | |
445 | , transportCrypto = crypto } | 445 | let sessionsState = sessionsState0 { sendHandshake = sendMessage handshakes |
446 | where | 446 | , sendSessionPacket = sendMessage cryptonet |
447 | -- TODO: This send-only transport is obviated by it's two components. | 447 | , transportCrypto = crypto } |
448 | nc_combo = Transport | ||
449 | { sendMessage = \addr -> \case | ||
450 | NetCrypto x -> sendMessage cryptonet addr x | ||
451 | NetHandshake x -> sendMessage handshakes addr x | ||
452 | , awaitMessage = \_ -> throwIO (userError "oops: awaitMessage nc_combo") | ||
453 | , closeTransport = hPutStrLn stderr "oops: closeTransport nc_combo" | ||
454 | } | ||
455 | let dhtnet0 = layerTransportM (DHT.decrypt crypto) (DHT.encrypt crypto) dhtcrypt | 448 | let dhtnet0 = layerTransportM (DHT.decrypt crypto) (DHT.encrypt crypto) dhtcrypt |
456 | tbl4 = DHT.routing4 $ mkrouting (error "missing client") | 449 | tbl4 = DHT.routing4 $ mkrouting (error "missing client") |
457 | tbl6 = DHT.routing6 $ mkrouting (error "missing client") | 450 | tbl6 = DHT.routing6 $ mkrouting (error "missing client") |