summaryrefslogtreecommitdiff
path: root/examples/dhtd.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r--examples/dhtd.hs12
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
45import GHC.Conc (labelThread) 45import GHC.Conc (labelThread)
46#endif 46#endif
47 47
48import Crypto.Tox (zeros32,SecretKey,PublicKey, generateSecretKey, toPublic, encodeSecret, decodeSecret) 48import Crypto.Tox (zeros32,SecretKey,PublicKey, generateSecretKey, toPublic, encodeSecret, decodeSecret, userKeys)
49import Network.UPNP as UPNP 49import Network.UPNP as UPNP
50import Network.Address hiding (NodeId, NodeInfo(..)) 50import Network.Address hiding (NodeId, NodeInfo(..))
51import Network.Kademlia.Search 51import 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")