diff options
author | Joe Crayne <joe@jerkface.net> | 2018-08-22 20:50:23 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-09-07 13:18:43 -0400 |
commit | fb3d30fd7fb1e68623b3bffc9f42ecb2adabce66 (patch) | |
tree | 1de81c6bc6319e3889951d354adc71b104c5437b /src/Network/Tox.hs | |
parent | 9dded0e540876c9e928cfcb3c69666ce00b5852c (diff) |
Removed obsolete Connection.Tox.
Diffstat (limited to 'src/Network/Tox.hs')
-rw-r--r-- | src/Network/Tox.hs | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs index 515f155d..1bf6efc5 100644 --- a/src/Network/Tox.hs +++ b/src/Network/Tox.hs | |||
@@ -47,7 +47,6 @@ import System.Endian | |||
47 | import Network.BitTorrent.DHT.Token as Token | 47 | import Network.BitTorrent.DHT.Token as Token |
48 | 48 | ||
49 | import Connection | 49 | import Connection |
50 | import Connection.Tox | ||
51 | import Crypto.Tox | 50 | import Crypto.Tox |
52 | import Data.Word64Map (fitsInInt) | 51 | import Data.Word64Map (fitsInInt) |
53 | import qualified Data.Word64Map (empty) | 52 | import qualified Data.Word64Map (empty) |
@@ -207,7 +206,6 @@ data Tox extra = Tox | |||
207 | , toxOnionRoutes :: OnionRouter | 206 | , toxOnionRoutes :: OnionRouter |
208 | , toxContactInfo :: ContactInfo extra | 207 | , toxContactInfo :: ContactInfo extra |
209 | , toxAnnounceToLan :: IO () | 208 | , toxAnnounceToLan :: IO () |
210 | , toxMgr :: Manager ToxProgress Key | ||
211 | } | 209 | } |
212 | 210 | ||
213 | -- | initiate a netcrypto session, blocking | 211 | -- | initiate a netcrypto session, blocking |
@@ -438,25 +436,22 @@ newToxOverTransport keydb addr mbSessionsState suppliedDHTKey udp = do | |||
438 | tbl6 = DHT.routing6 $ mkrouting (error "missing client") | 436 | tbl6 = DHT.routing6 $ mkrouting (error "missing client") |
439 | dhtclient <- newClient drg dhtnet0 DHT.classify (myAddr tbl4 tbl6) (DHT.handlers crypto . mkrouting) id | 437 | dhtclient <- newClient drg dhtnet0 DHT.classify (myAddr tbl4 tbl6) (DHT.handlers crypto . mkrouting) id |
440 | $ \client net -> onInbound (DHT.updateRouting client (mkrouting client) orouter) net | 438 | $ \client net -> onInbound (DHT.updateRouting client (mkrouting client) orouter) net |
441 | -- TODO: Refactor so this recursive do is unnecessary. | 439 | |
442 | rec (mgr,sessionsState) <- do | 440 | let sessionsState = sessionsState0 { sendHandshake = sendMessage handshakes |
443 | mgr <- toxManager (Parameters { dhtRouting = mkrouting dhtclient | 441 | , sendSessionPacket = sendMessage cryptonet |
444 | , roster = roster | 442 | , transportCrypto = crypto |
445 | , sessions = sessionsState | 443 | -- ToxContact -> STM Policy |
446 | , dhtClient = dhtclient | 444 | , netCryptoPolicyByKey = policylookup |
447 | , onToxSession = return () -- TODO | 445 | } |
448 | }) | 446 | policylookup (ToxContact me them) = do |
449 | let policylookup key = do | 447 | macnt <- HashMap.lookup me <$> readTVar (accounts roster) |
450 | mp <- connections mgr | 448 | case macnt of |
451 | case Map.lookup key mp of | 449 | Nothing -> return RefusingToConnect |
452 | Nothing -> return OpenToConnect | 450 | Just acnt -> do |
453 | Just conn -> Connection.connPolicy conn | 451 | mc <- HashMap.lookup them <$> readTVar (contacts acnt) |
454 | 452 | case mc of | |
455 | return (mgr, sessionsState0 { sendHandshake = sendMessage handshakes | 453 | Nothing -> return RefusingToConnect |
456 | , sendSessionPacket = sendMessage cryptonet | 454 | Just c -> fromMaybe RefusingToConnect <$> readTVar (contactPolicy c) |
457 | , transportCrypto = crypto | ||
458 | , netCryptoPolicyByKey = policylookup | ||
459 | }) | ||
460 | 455 | ||
461 | orouter' <- forkRouteBuilder orouter | 456 | orouter' <- forkRouteBuilder orouter |
462 | $ \nid ni -> fmap (\(_,ns,_)->ns) | 457 | $ \nid ni -> fmap (\(_,ns,_)->ns) |
@@ -487,7 +482,6 @@ newToxOverTransport keydb addr mbSessionsState suppliedDHTKey udp = do | |||
487 | , toxOnionRoutes = orouter | 482 | , toxOnionRoutes = orouter |
488 | , toxContactInfo = roster | 483 | , toxContactInfo = roster |
489 | , toxAnnounceToLan = return () | 484 | , toxAnnounceToLan = return () |
490 | , toxMgr = mgr | ||
491 | } | 485 | } |
492 | 486 | ||
493 | onionTimeout :: Tox extra -> DHT.TransactionId -> Onion.OnionDestination RouteId -> STM (Onion.OnionDestination RouteId, Int) | 487 | onionTimeout :: Tox extra -> DHT.TransactionId -> Onion.OnionDestination RouteId -> STM (Onion.OnionDestination RouteId, Int) |