diff options
author | Joe Crayne <joe@jerkface.net> | 2019-10-18 14:37:47 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 19:56:13 -0500 |
commit | afe571b7b663cd7f4b95d2c18ebf64c090875e9d (patch) | |
tree | 9228ad2fb786860fd9e0c4a2112eb1f2bf70d8a6 /dht/src/Network | |
parent | 687e06b39529bef04ecd49fc5e5b1b502a41b28d (diff) |
Shutdown Tox TCP Relay.
Diffstat (limited to 'dht/src/Network')
-rw-r--r-- | dht/src/Network/Tox.hs | 8 |
1 files changed, 7 insertions, 1 deletions
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 | |||
52 | import Network.Address (WantIP (..),IP,getBindAddress) | 52 | import Network.Address (WantIP (..),IP,getBindAddress) |
53 | import qualified Network.Kademlia.Routing as R | 53 | import qualified Network.Kademlia.Routing as R |
54 | import Network.QueryResponse | 54 | import Network.QueryResponse |
55 | import Network.StreamServer (ServerHandle,quitListening) | ||
55 | import Crypto.Tox | 56 | import Crypto.Tox |
56 | import Data.Word64Map (fitsInInt) | 57 | import Data.Word64Map (fitsInInt) |
57 | import qualified Data.Word64Map (empty) | 58 | import 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'. |
297 | newToxOverTransport :: TVar Onion.AnnouncedKeys | 301 | newToxOverTransport :: 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 | ||
380 | onionTimeout :: Tox extra -> DHT.TransactionId -> Onion.OnionDestination RouteId -> STM (Onion.OnionDestination RouteId, Int) | 385 | onionTimeout :: 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 | ) |