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.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs
index ddb22d50..b22cfdf3 100644
--- a/src/Network/Tox.hs
+++ b/src/Network/Tox.hs
@@ -271,10 +271,11 @@ newTox :: TVar Onion.AnnouncedKeys -- ^ Store of announced keys we are a rende
271 -> SockAddr -- ^ Bind-address to listen on. 271 -> SockAddr -- ^ Bind-address to listen on.
272 -> ( ContactInfo extra -> SockAddr -> Session -> IO () ) 272 -> ( ContactInfo extra -> SockAddr -> Session -> IO () )
273 -> Maybe SecretKey -- ^ Optional DHT secret key to use. 273 -> Maybe SecretKey -- ^ Optional DHT secret key to use.
274 -> ( Int -> Onion.OnionResponse Onion.N1 -> IO () ) -- ^ TCP-bound onion responses.
274 -> IO (Tox extra) 275 -> IO (Tox extra)
275newTox keydb addr onsess suppliedDHTKey = do 276newTox keydb addr onsess suppliedDHTKey tcp = do
276 (udp,sock) <- {- addVerbosity <$> -} udpTransport' addr 277 (udp,sock) <- {- addVerbosity <$> -} udpTransport' addr
277 tox <- newToxOverTransport keydb addr onsess suppliedDHTKey udp 278 tox <- newToxOverTransport keydb addr onsess suppliedDHTKey udp tcp
278 return tox { toxAnnounceToLan = announceToLan sock (key2id $ transportPublic $ toxCryptoKeys tox) } 279 return tox { toxAnnounceToLan = announceToLan sock (key2id $ transportPublic $ toxCryptoKeys tox) }
279 280
280-- | This version of 'newTox' is useful for automated tests using 'testPairTransport'. 281-- | This version of 'newTox' is useful for automated tests using 'testPairTransport'.
@@ -283,8 +284,9 @@ newToxOverTransport :: TVar Onion.AnnouncedKeys
283 -> ( ContactInfo extra -> SockAddr -> Session -> IO () ) 284 -> ( ContactInfo extra -> SockAddr -> Session -> IO () )
284 -> Maybe SecretKey 285 -> Maybe SecretKey
285 -> Onion.UDPTransport 286 -> Onion.UDPTransport
287 -> ( Int -> Onion.OnionResponse Onion.N1 -> IO () ) -- ^ TCP-bound onion responses.
286 -> IO (Tox extra) 288 -> IO (Tox extra)
287newToxOverTransport keydb addr onNewSession suppliedDHTKey udp = do 289newToxOverTransport keydb addr onNewSession suppliedDHTKey udp tcp = do
288 roster <- newContactInfo 290 roster <- newContactInfo
289 crypto0 <- newCrypto 291 crypto0 <- newCrypto
290 let -- patch in supplied DHT key 292 let -- patch in supplied DHT key
@@ -306,7 +308,7 @@ newToxOverTransport keydb addr onNewSession suppliedDHTKey udp = do
306 308
307 mkrouting <- DHT.newRouting addr crypto updateIP updateIP 309 mkrouting <- DHT.newRouting addr crypto updateIP updateIP
308 orouter <- newOnionRouter $ dput XRoutes 310 orouter <- newOnionRouter $ dput XRoutes
309 (cryptonet,dhtcrypt,onioncrypt,dtacrypt,handshakes) <- toxTransport crypto orouter lookupClose udp 311 (cryptonet,dhtcrypt,onioncrypt,dtacrypt,handshakes) <- toxTransport crypto orouter lookupClose udp tcp
310 sessions <- initSessions (sendMessage cryptonet) 312 sessions <- initSessions (sendMessage cryptonet)
311 313
312 let dhtnet0 = layerTransportM (DHT.decrypt crypto) (DHT.encrypt crypto) dhtcrypt 314 let dhtnet0 = layerTransportM (DHT.decrypt crypto) (DHT.encrypt crypto) dhtcrypt