summaryrefslogtreecommitdiff
path: root/dht
diff options
context:
space:
mode:
Diffstat (limited to 'dht')
-rw-r--r--dht/examples/dhtd.hs1
-rw-r--r--dht/src/Network/Tox.hs8
2 files changed, 8 insertions, 1 deletions
diff --git a/dht/examples/dhtd.hs b/dht/examples/dhtd.hs
index da73159d..3b2f1698 100644
--- a/dht/examples/dhtd.hs
+++ b/dht/examples/dhtd.hs
@@ -1843,6 +1843,7 @@ main = do
1843 stopAnnouncer announcer 1843 stopAnnouncer announcer
1844 quitBt 1844 quitBt
1845 quitTox 1845 quitTox
1846 quitToxChat
1846 1847
1847 swarmsdb <- atomically $ readTVar (Mainline.contactInfo swarms) 1848 swarmsdb <- atomically $ readTVar (Mainline.contactInfo swarms)
1848 forM_ (Map.toList dhts) $ \(netname,dht) -> do 1849 forM_ (Map.toList dhts) $ \(netname,dht) -> do
diff --git a/dht/src/Network/Tox.hs b/dht/src/Network/Tox.hs
index b396c2ea..97b97bad 100644
--- a/dht/src/Network/Tox.hs
+++ b/dht/src/Network/Tox.hs
@@ -52,6 +52,7 @@ import System.Global6
52import Network.Address (WantIP (..),IP,getBindAddress) 52import Network.Address (WantIP (..),IP,getBindAddress)
53import qualified Network.Kademlia.Routing as R 53import qualified Network.Kademlia.Routing as R
54import Network.QueryResponse 54import Network.QueryResponse
55import Network.StreamServer (ServerHandle,quitListening)
55import Crypto.Tox 56import Crypto.Tox
56import Data.Word64Map (fitsInInt) 57import Data.Word64Map (fitsInInt)
57import qualified Data.Word64Map (empty) 58import qualified Data.Word64Map (empty)
@@ -183,6 +184,7 @@ data Tox extra = Tox
183 , toxContactInfo :: ContactInfo extra 184 , toxContactInfo :: ContactInfo extra
184 , toxAnnounceToLan :: IO () 185 , toxAnnounceToLan :: IO ()
185 , toxBindAddress :: SockAddr 186 , toxBindAddress :: SockAddr
187 , toxRelayServer :: Maybe ServerHandle
186 } 188 }
187 189
188 190
@@ -291,7 +293,9 @@ newTox keydb bindspecs onsess suppliedDHTKey tcp = do
291 addr <- getSocketName sock 293 addr <- getSocketName sock
292 (relay,sendTCP) <- tcpRelay addr (\a x -> sendMessage udp a $ S.runPut $ Onion.putRequest x) 294 (relay,sendTCP) <- tcpRelay addr (\a x -> sendMessage udp a $ S.runPut $ Onion.putRequest x)
293 tox <- newToxOverTransport keydb addr onsess suppliedDHTKey udp sendTCP 295 tox <- newToxOverTransport keydb addr onsess suppliedDHTKey udp sendTCP
294 return tox { toxAnnounceToLan = announceToLan sock (key2id $ transportPublic $ toxCryptoKeys tox) } 296 return tox { toxAnnounceToLan = announceToLan sock (key2id $ transportPublic $ toxCryptoKeys tox)
297 , toxRelayServer = Just relay
298 }
295 299
296-- | This version of 'newTox' is useful for automated tests using 'testPairTransport'. 300-- | This version of 'newTox' is useful for automated tests using 'testPairTransport'.
297newToxOverTransport :: TVar Onion.AnnouncedKeys 301newToxOverTransport :: TVar Onion.AnnouncedKeys
@@ -375,6 +379,7 @@ newToxOverTransport keydb addr onNewSession suppliedDHTKey udp tcp = do
375 , toxContactInfo = roster 379 , toxContactInfo = roster
376 , toxAnnounceToLan = return () 380 , toxAnnounceToLan = return ()
377 , toxBindAddress = addr 381 , toxBindAddress = addr
382 , toxRelayServer = Nothing
378 } 383 }
379 384
380onionTimeout :: Tox extra -> DHT.TransactionId -> Onion.OnionDestination RouteId -> STM (Onion.OnionDestination RouteId, Int) 385onionTimeout :: Tox extra -> DHT.TransactionId -> Onion.OnionDestination RouteId -> STM (Onion.OnionDestination RouteId, Int)
@@ -435,6 +440,7 @@ forkTox tox with_avahi = do
435 quitRouteBuilder (toxOnionRoutes tox) 440 quitRouteBuilder (toxOnionRoutes tox)
436 quitToRoute 441 quitToRoute
437 quitHs 442 quitHs
443 mapM_ quitListening (toxRelayServer tox)
438 , bootstrap (DHT.refresher4 $ toxRouting tox) 444 , bootstrap (DHT.refresher4 $ toxRouting tox)
439 , bootstrap (DHT.refresher6 $ toxRouting tox) 445 , bootstrap (DHT.refresher6 $ toxRouting tox)
440 ) 446 )