diff options
author | joe <joe@jerkface.net> | 2017-11-04 22:21:24 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-11-04 22:21:24 -0400 |
commit | 8903c7e0b9eea11dbf229747e7f9729bfe5d2f7b (patch) | |
tree | a15d464c97bbad2a9f256f5fb52c8375b11ca9d3 /src/Network/Tox.hs | |
parent | f045f7e473b534cbe4dff70420e4cc0184465e54 (diff) |
Quieter output and some bug fixes.
Diffstat (limited to 'src/Network/Tox.hs')
-rw-r--r-- | src/Network/Tox.hs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs index 9f41fbe5..7179e3c2 100644 --- a/src/Network/Tox.hs +++ b/src/Network/Tox.hs | |||
@@ -284,24 +284,31 @@ getOnionAlias crypto dhtself remoteNode = atomically $ do | |||
284 | 284 | ||
285 | newTox :: TVar Onion.AnnouncedKeys -> SockAddr -> Maybe NetCryptoSessions -> Maybe SecretKey -> IO Tox | 285 | newTox :: TVar Onion.AnnouncedKeys -> SockAddr -> Maybe NetCryptoSessions -> Maybe SecretKey -> IO Tox |
286 | newTox keydb addr mbSessionsState suppliedDHTKey = do | 286 | newTox keydb addr mbSessionsState suppliedDHTKey = do |
287 | udp <- addVerbosity <$> udpTransport addr | 287 | udp <- {- addVerbosity <$> -} udpTransport addr |
288 | (crypto,sessionsState) <- case mbSessionsState of | 288 | (crypto0,sessionsState) <- case mbSessionsState of |
289 | Nothing -> do | 289 | Nothing -> do |
290 | crypto0 <- newCrypto | 290 | crypto <- newCrypto |
291 | let crypto = fromMaybe crypto0 $do | ||
292 | k <- suppliedDHTKey | ||
293 | return crypto0 | ||
294 | { transportSecret = k | ||
295 | , transportPublic = toPublic k | ||
296 | } | ||
297 | sessionsState <- newSessionsState crypto defaultUnRecHook defaultCryptoDataHooks | 291 | sessionsState <- newSessionsState crypto defaultUnRecHook defaultCryptoDataHooks |
298 | return (crypto,sessionsState) | 292 | return (crypto,sessionsState) |
299 | Just s -> return (transportCrypto s, s) | 293 | Just s -> return (transportCrypto s, s) |
294 | |||
295 | let crypto = fromMaybe crypto0 $do | ||
296 | k <- suppliedDHTKey | ||
297 | return crypto0 | ||
298 | { transportSecret = k | ||
299 | , transportPublic = toPublic k | ||
300 | } | ||
301 | forM_ suppliedDHTKey $ \k -> do | ||
302 | maybe (hPutStrLn stderr "failed to encode suppliedDHTKey") | ||
303 | (C8.hPutStrLn stderr . C8.append "Using suppliedDHTKey: ") | ||
304 | $ encodeSecret k | ||
305 | |||
300 | drg <- drgNew | 306 | drg <- drgNew |
301 | let lookupClose _ = return Nothing | 307 | let lookupClose _ = return Nothing |
302 | 308 | ||
303 | routing <- DHT.newRouting addr crypto updateIP updateIP | 309 | routing <- DHT.newRouting addr crypto updateIP updateIP |
304 | orouter <- newOnionRouter | 310 | let ignoreErrors _ = return () -- Set this to (hPutStrLn stderr) to debug onion route building. |
311 | orouter <- newOnionRouter ignoreErrors | ||
305 | (dhtcrypt,onioncrypt,dtacrypt,cryptonet) <- toxTransport crypto orouter lookupClose udp | 312 | (dhtcrypt,onioncrypt,dtacrypt,cryptonet) <- toxTransport crypto orouter lookupClose udp |
306 | let dhtnet0 = layerTransport (DHT.decrypt crypto) (DHT.encrypt crypto) dhtcrypt | 313 | let dhtnet0 = layerTransport (DHT.decrypt crypto) (DHT.encrypt crypto) dhtcrypt |
307 | dhtclient <- newClient drg dhtnet0 DHT.classify (myAddr routing) (DHT.handlers crypto routing) id | 314 | dhtclient <- newClient drg dhtnet0 DHT.classify (myAddr routing) (DHT.handlers crypto routing) id |