summaryrefslogtreecommitdiff
path: root/src/Network/Tox.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox.hs')
-rw-r--r--src/Network/Tox.hs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs
index d42f447d..ef74b9c6 100644
--- a/src/Network/Tox.hs
+++ b/src/Network/Tox.hs
@@ -294,7 +294,7 @@ newToxOverTransport keydb addr onNewSession suppliedDHTKey udp tcp = do
294 let dhtnet0 = layerTransportM (DHT.decrypt crypto) (DHT.encrypt crypto) dhtcrypt 294 let dhtnet0 = layerTransportM (DHT.decrypt crypto) (DHT.encrypt crypto) dhtcrypt
295 tbl4 = DHT.routing4 $ mkrouting (error "missing client") 295 tbl4 = DHT.routing4 $ mkrouting (error "missing client")
296 tbl6 = DHT.routing6 $ mkrouting (error "missing client") 296 tbl6 = DHT.routing6 $ mkrouting (error "missing client")
297 updateOnion bkts tr = hookBucketList DHT.toxSpace bkts orouter tr 297 updateOnion bkts tr = hookBucketList DHT.toxSpace bkts orouter (trampolinesUDP orouter) tr
298 dhtclient <- newClient drg dhtnet0 DHT.classify (myAddr tbl4 tbl6) (DHT.handlers crypto . mkrouting) id 298 dhtclient <- newClient drg dhtnet0 DHT.classify (myAddr tbl4 tbl6) (DHT.handlers crypto . mkrouting) id
299 $ \client net -> onInbound (DHT.updateRouting client (mkrouting client) updateOnion) net 299 $ \client net -> onInbound (DHT.updateRouting client (mkrouting client) updateOnion) net
300 300
@@ -306,6 +306,8 @@ newToxOverTransport keydb addr onNewSession suppliedDHTKey udp tcp = do
306 , spOnNewSession = onNewSession roster addr 306 , spOnNewSession = onNewSession roster addr
307 } 307 }
308 308
309 -- TODO: Refactor so that these threads are forked when 'forkTox' is invoked.
310 -- This function should only initialize state.
309 orouter' <- forkRouteBuilder orouter 311 orouter' <- forkRouteBuilder orouter
310 $ \nid ni -> fmap (\(_,ns,_)->ns) 312 $ \nid ni -> fmap (\(_,ns,_)->ns)
311 <$> DHT.getNodes dhtclient (DHT.nodesOfInterest $ mkrouting dhtclient) nid ni 313 <$> DHT.getNodes dhtclient (DHT.nodesOfInterest $ mkrouting dhtclient) nid ni
@@ -332,7 +334,7 @@ newToxOverTransport keydb addr onNewSession suppliedDHTKey udp tcp = do
332 , toxRouting = mkrouting dhtclient 334 , toxRouting = mkrouting dhtclient
333 , toxTokens = toks 335 , toxTokens = toks
334 , toxAnnouncedKeys = keydb 336 , toxAnnouncedKeys = keydb
335 , toxOnionRoutes = orouter 337 , toxOnionRoutes = orouter' -- TODO: see above
336 , toxContactInfo = roster 338 , toxContactInfo = roster
337 , toxAnnounceToLan = return () 339 , toxAnnounceToLan = return ()
338 , toxBindAddress = addr 340 , toxBindAddress = addr
@@ -375,11 +377,6 @@ forkTox tox with_avahi = do
375 quitDHT <- forkListener "toxDHT" (clientNet $ toxDHT tox) 377 quitDHT <- forkListener "toxDHT" (clientNet $ toxDHT tox)
376 quitNC <- forkListener "toxCrypto" (toxCrypto tox) 378 quitNC <- forkListener "toxCrypto" (toxCrypto tox)
377 quitTCP <- forkListener "relay-client" (clientNet $ tcpClient $ tcpKademliaClient $ toxOnionRoutes tox) 379 quitTCP <- forkListener "relay-client" (clientNet $ tcpClient $ tcpKademliaClient $ toxOnionRoutes tox)
378 tcpKademlia <- forkPollForRefresh (tcpBucketRefresher $ toxOnionRoutes tox)
379 tcpprobe <- forkIO $ runProbeQueue (tcpProber $ toxOnionRoutes tox)
380 (tcpClient $ tcpKademliaClient $ toxOnionRoutes tox)
381 12
382 labelThread tcpprobe "tcp-probe"
383 quitAvahi <- if with_avahi then do 380 quitAvahi <- if with_avahi then do
384 forkPollForRefresh (DHT.refresher4 $ toxRouting tox) 381 forkPollForRefresh (DHT.refresher4 $ toxRouting tox)
385 forkPollForRefresh (DHT.refresher6 $ toxRouting tox) 382 forkPollForRefresh (DHT.refresher6 $ toxRouting tox)
@@ -396,8 +393,7 @@ forkTox tox with_avahi = do
396 quitDHT 393 quitDHT
397 quitOnion 394 quitOnion
398 quitTCP 395 quitTCP
399 killThread tcpKademlia 396 quitRouteBuilder (toxOnionRoutes tox)
400 killThread tcpprobe
401 quitToRoute 397 quitToRoute
402 quitHs 398 quitHs
403 , bootstrap (DHT.refresher4 $ toxRouting tox) 399 , bootstrap (DHT.refresher4 $ toxRouting tox)