diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/MainlineDHT.hs | 9 | ||||
-rw-r--r-- | src/Network/Tox.hs | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/Network/BitTorrent/MainlineDHT.hs b/src/Network/BitTorrent/MainlineDHT.hs index 3e7a0eda..47d5b3e1 100644 --- a/src/Network/BitTorrent/MainlineDHT.hs +++ b/src/Network/BitTorrent/MainlineDHT.hs | |||
@@ -538,7 +538,12 @@ mkNodeInfo nid addr = NodeInfo | |||
538 | , nodePort = fromMaybe 0 $ sockAddrPort addr | 538 | , nodePort = fromMaybe 0 $ sockAddrPort addr |
539 | } | 539 | } |
540 | 540 | ||
541 | newClient :: SwarmsDatabase -> SockAddr -> IO (MainlineClient, Routing) | 541 | newClient :: SwarmsDatabase -> SockAddr |
542 | -> IO ( MainlineClient | ||
543 | , Routing | ||
544 | , [NodeInfo] -> [NodeInfo] -> IO () | ||
545 | , [NodeInfo] -> [NodeInfo] -> IO () | ||
546 | ) | ||
542 | newClient swarms addr = do | 547 | newClient swarms addr = do |
543 | udp <- udpTransport addr | 548 | udp <- udpTransport addr |
544 | nid <- NodeId <$> getRandomBytes 20 | 549 | nid <- NodeId <$> getRandomBytes 20 |
@@ -651,7 +656,7 @@ newClient swarms addr = do | |||
651 | refresh_thread4 <- forkPollForRefresh $ refresher4 routing | 656 | refresh_thread4 <- forkPollForRefresh $ refresher4 routing |
652 | refresh_thread6 <- forkPollForRefresh $ refresher6 routing | 657 | refresh_thread6 <- forkPollForRefresh $ refresher6 routing |
653 | 658 | ||
654 | return (client, routing) | 659 | return (client, routing, bootstrap (refresher4 routing), bootstrap (refresher6 routing)) |
655 | 660 | ||
656 | -- | Modifies a purely random 'NodeId' to one that is related to a given | 661 | -- | Modifies a purely random 'NodeId' to one that is related to a given |
657 | -- routable address in accordance with BEP 42. | 662 | -- routable address in accordance with BEP 42. |
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs index 5f691ef3..37802e3c 100644 --- a/src/Network/Tox.hs +++ b/src/Network/Tox.hs | |||
@@ -88,7 +88,7 @@ import GHC.TypeLits | |||
88 | import Crypto.Tox | 88 | 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.Kademlia.Bootstrap (forkPollForRefresh) | 91 | import Network.Kademlia.Bootstrap (forkPollForRefresh, bootstrap) |
92 | import Network.Tox.Crypto.Transport (NetCrypto) | 92 | import Network.Tox.Crypto.Transport (NetCrypto) |
93 | import Network.Tox.Crypto.Handlers (cryptoNetHandler, newSessionsState, defaultUnRecHook, defaultCryptoDataHooks, NetCryptoSessions(..)) | 93 | import Network.Tox.Crypto.Handlers (cryptoNetHandler, newSessionsState, defaultUnRecHook, defaultCryptoDataHooks, NetCryptoSessions(..)) |
94 | import qualified Network.Tox.DHT.Handlers as DHT | 94 | import qualified Network.Tox.DHT.Handlers as DHT |
@@ -354,7 +354,7 @@ newTox keydb addr mbSessionsState suppliedDHTKey = do | |||
354 | onionTimeout :: Tox -> DHT.TransactionId -> Onion.OnionDestination RouteId -> STM (Onion.OnionDestination RouteId, Int) | 354 | onionTimeout :: Tox -> DHT.TransactionId -> Onion.OnionDestination RouteId -> STM (Onion.OnionDestination RouteId, Int) |
355 | onionTimeout Tox { toxOnionRoutes = or } (DHT.TransactionId n8 _) od = lookupTimeout or n8 od | 355 | onionTimeout Tox { toxOnionRoutes = or } (DHT.TransactionId n8 _) od = lookupTimeout or n8 od |
356 | 356 | ||
357 | forkTox :: Tox -> IO (IO ()) | 357 | forkTox :: Tox -> IO (IO (), [NodeInfo] -> [NodeInfo] -> IO (), [NodeInfo] -> [NodeInfo] -> IO ()) |
358 | forkTox tox = do | 358 | forkTox tox = do |
359 | _ <- forkListener "toxCrypto" (toxCrypto tox) | 359 | _ <- forkListener "toxCrypto" (toxCrypto tox) |
360 | _ <- forkListener "toxToRoute" (toxToRoute tox) | 360 | _ <- forkListener "toxToRoute" (toxToRoute tox) |
@@ -362,5 +362,8 @@ forkTox tox = do | |||
362 | quit <- forkListener "toxDHT" (clientNet $ toxDHT tox) | 362 | quit <- forkListener "toxDHT" (clientNet $ toxDHT tox) |
363 | forkPollForRefresh (DHT.refresher4 $ toxRouting tox) | 363 | forkPollForRefresh (DHT.refresher4 $ toxRouting tox) |
364 | forkPollForRefresh (DHT.refresher6 $ toxRouting tox) | 364 | forkPollForRefresh (DHT.refresher6 $ toxRouting tox) |
365 | return quit | 365 | return ( quit |
366 | , bootstrap (DHT.refresher4 $ toxRouting tox) | ||
367 | , bootstrap (DHT.refresher6 $ toxRouting tox) | ||
368 | ) | ||
366 | 369 | ||