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.hs18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs
index c14339e4..98c03b80 100644
--- a/src/Network/Tox.hs
+++ b/src/Network/Tox.hs
@@ -44,6 +44,7 @@ import Network.Socket
44import System.Endian 44import System.Endian
45import System.IO.Error 45import System.IO.Error
46 46
47import Data.TableMethods
47import qualified Data.Word64Map 48import qualified Data.Word64Map
48import Network.BitTorrent.DHT.Token as Token 49import Network.BitTorrent.DHT.Token as Token
49import qualified Data.Wrapper.PSQ as PSQ 50import qualified Data.Wrapper.PSQ as PSQ
@@ -159,12 +160,10 @@ newClient drg net classify selfAddr handlers modifytbl modifynet = do
159 let client = Client 160 let client = Client
160 { clientNet = addHandler (reportParseError eprinter) (handleMessage client) $ modifynet client net 161 { clientNet = addHandler (reportParseError eprinter) (handleMessage client) $ modifynet client net
161 , clientDispatcher = dispatch tbl var (handlers client) client 162 , clientDispatcher = dispatch tbl var (handlers client) client
162 , clientErrorReporter = eprinter { reportTimeout = reportTimeout ignoreErrors } 163 , clientErrorReporter = eprinter
163 , clientPending = var 164 , clientPending = var
164 , clientAddress = selfAddr 165 , clientAddress = selfAddr
165 , clientResponseId = genNonce24 var 166 , clientResponseId = genNonce24 var
166 , clientEnterQuery = \_ -> return ()
167 , clientLeaveQuery = \_ _ -> return ()
168 } 167 }
169 in client 168 in client
170 return $ either mkclient mkclient tblvar handlers 169 return $ either mkclient mkclient tblvar handlers
@@ -250,8 +249,8 @@ newOnionClient :: DRG g =>
250 -> TVar Onion.AnnouncedKeys 249 -> TVar Onion.AnnouncedKeys
251 -> OnionRouter 250 -> OnionRouter
252 -> TVar (g, Data.Word64Map.Word64Map a) 251 -> TVar (g, Data.Word64Map.Word64Map a)
253 -> (MVar Onion.Message -> a) 252 -> ((Maybe Onion.Message -> IO ()) -> a)
254 -> (a -> Onion.Message -> IO void) 253 -> (a -> Maybe Onion.Message -> IO void)
255 -> Client String 254 -> Client String
256 DHT.PacketKind 255 DHT.PacketKind
257 DHT.TransactionId 256 DHT.TransactionId
@@ -268,12 +267,10 @@ newOnionClient crypto net r toks keydb orouter map_var store load = c
268 , tableMethods = hookQueries orouter DHT.transactionKey 267 , tableMethods = hookQueries orouter DHT.transactionKey
269 $ transactionMethods' store load (contramap w64Key w64MapMethods) gen 268 $ transactionMethods' store load (contramap w64Key w64MapMethods) gen
270 } 269 }
271 , clientErrorReporter = eprinter { reportTimeout = reportTimeout ignoreErrors } 270 , clientErrorReporter = eprinter
272 , clientPending = map_var 271 , clientPending = map_var
273 , clientAddress = getOnionAlias crypto $ R.thisNode <$> readTVar (DHT.routing4 r) 272 , clientAddress = getOnionAlias crypto $ R.thisNode <$> readTVar (DHT.routing4 r)
274 , clientResponseId = genNonce24 map_var 273 , clientResponseId = genNonce24 map_var
275 , clientEnterQuery = \_ -> return ()
276 , clientLeaveQuery = \_ _ -> return ()
277 } 274 }
278 275
279newTox :: TVar Onion.AnnouncedKeys -- ^ Store of announced keys we are a rendezvous for. 276newTox :: TVar Onion.AnnouncedKeys -- ^ Store of announced keys we are a rendezvous for.
@@ -359,10 +356,9 @@ newToxOverTransport keydb addr onNewSession suppliedDHTKey udp tcp = do
359 let onionnet = layerTransportM (Onion.decrypt crypto) (Onion.encrypt crypto) onioncrypt 356 let onionnet = layerTransportM (Onion.decrypt crypto) (Onion.encrypt crypto) onioncrypt
360 let onionclient = newOnionClient crypto onionnet (mkrouting dhtclient) toks keydb orouter' otbl 357 let onionclient = newOnionClient crypto onionnet (mkrouting dhtclient) toks keydb orouter' otbl
361 Right $ \case 358 Right $ \case
362 Right v -> tryPutMVar v 359 Right v -> v
363 Left v -> \_ -> do 360 Left v -> \_ ->
364 dput XUnexpected "TCP-sent onion query got response over UDP?" 361 dput XUnexpected "TCP-sent onion query got response over UDP?"
365 return False
366 362
367 return Tox 363 return Tox
368 { toxDHT = dhtclient 364 { toxDHT = dhtclient