diff options
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r-- | examples/dhtd.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index bd2df9db..1e2c1467 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -45,7 +45,7 @@ import Control.Concurrent.Lifted | |||
45 | import GHC.Conc (labelThread) | 45 | import GHC.Conc (labelThread) |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | import Crypto.Tox (zeros32,SecretKey,PublicKey, generateSecretKey, toPublic, encodeSecret, decodeSecret) | 48 | import Crypto.Tox (zeros32,SecretKey,PublicKey, generateSecretKey, toPublic, encodeSecret, decodeSecret, userKeys) |
49 | import Network.UPNP as UPNP | 49 | import Network.UPNP as UPNP |
50 | import Network.Address hiding (NodeId, NodeInfo(..)) | 50 | import Network.Address hiding (NodeId, NodeInfo(..)) |
51 | import Network.Kademlia.Search | 51 | import Network.Kademlia.Search |
@@ -669,8 +669,9 @@ main = do | |||
669 | 669 | ||
670 | keysdb <- Tox.newKeysDatabase | 670 | keysdb <- Tox.newKeysDatabase |
671 | 671 | ||
672 | (quitTox,toxdhts,toxips,taddrs) <- case porttox opts of | 672 | (toxids,quitTox,toxdhts,toxips,taddrs) <- case porttox opts of |
673 | "" -> return (return (), Map.empty, return [],[]) | 673 | "" -> do keys <- atomically $ newTVar [] |
674 | return (keys,return (), Map.empty, return [],[]) | ||
674 | toxport -> do | 675 | toxport -> do |
675 | addrTox <- getBindAddress toxport (ip6tox opts) | 676 | addrTox <- getBindAddress toxport (ip6tox opts) |
676 | tox <- Tox.newTox keysdb addrTox | 677 | tox <- Tox.newTox keysdb addrTox |
@@ -732,7 +733,7 @@ main = do | |||
732 | ips :: IO [SockAddr] | 733 | ips :: IO [SockAddr] |
733 | ips = readExternals Tox.nodeAddr [ Tox.routing4 $ Tox.toxRouting tox | 734 | ips = readExternals Tox.nodeAddr [ Tox.routing4 $ Tox.toxRouting tox |
734 | , Tox.routing6 $ Tox.toxRouting tox ] | 735 | , Tox.routing6 $ Tox.toxRouting tox ] |
735 | return (quitTox, dhts, ips, [addrTox]) | 736 | return (userKeys (Tox.toxCryptoKeys tox), quitTox, dhts, ips, [addrTox]) |
736 | 737 | ||
737 | _ <- UPNP.requestPorts "dht-client" $ map (Datagram,) $ baddrs ++ taddrs | 738 | _ <- UPNP.requestPorts "dht-client" $ map (Datagram,) $ baddrs ++ taddrs |
738 | 739 | ||
@@ -740,14 +741,13 @@ main = do | |||
740 | 741 | ||
741 | waitForSignal <- do | 742 | waitForSignal <- do |
742 | signalQuit <- newEmptyMVar | 743 | signalQuit <- newEmptyMVar |
743 | userkeys0 <- atomically (newTVar []) | ||
744 | let session = clientSession $ Session | 744 | let session = clientSession $ Session |
745 | { netname = concat $ take 1 $ Map.keys dhts -- initial default DHT | 745 | { netname = concat $ take 1 $ Map.keys dhts -- initial default DHT |
746 | , dhts = dhts -- all DHTs | 746 | , dhts = dhts -- all DHTs |
747 | , signalQuit = signalQuit | 747 | , signalQuit = signalQuit |
748 | , swarms = swarms | 748 | , swarms = swarms |
749 | , toxkeys = keysdb | 749 | , toxkeys = keysdb |
750 | , userkeys = userkeys0 | 750 | , userkeys = toxids |
751 | , externalAddresses = liftM2 (++) btips toxips | 751 | , externalAddresses = liftM2 (++) btips toxips |
752 | } | 752 | } |
753 | srv <- streamServer (withSession session) (SockAddrUnix "dht.sock") | 753 | srv <- streamServer (withSession session) (SockAddrUnix "dht.sock") |