From 55533838c0089fb94dd4f007d4e3f0b676a8ffc4 Mon Sep 17 00:00:00 2001 From: James Crayne Date: Tue, 29 May 2018 23:32:01 +0000 Subject: netcrypto command should not use dhtParseId --- examples/dhtd.hs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 6b8954d1..ec6c89f1 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs @@ -401,6 +401,7 @@ data Session = Session , onionRouter :: OnionRouter , announcer :: Announcer , signalQuit :: IO () + , mbTox :: Maybe Tox.Tox } exceptionsToClient :: ClientHandle -> IO () -> IO () @@ -784,14 +785,22 @@ clientSession s@Session{..} sock cnum h = do Nothing -> hPutClient h "No key is selected, see k command." Just mypubkey -> do let nidstr = strp s - goParse = either (hPutClient h . ("Bad netcrypto target: "++)) - goTarget - $ dhtParseId nidstr + goParse = either + (hPutClient h . ("Bad netcrypto target: "++)) + (goTarget . Tox.id2key) + $ readEither nidstr goTarget nid = do msec <- atomically $ do ks <- map swap <$> readKeys userkeys (accounts roster) return $ Data.List.lookup mypubkey ks - hPutClient h "TODO: convert selected public key to private, call netCrypto.." + case mbTox of + Nothing -> hPutClient h "Requires Tox enabled." + Just tox-> do + case msec of + Nothing -> hPutClient h "Error getting secret key" + Just sec -> do + Tox.netCrypto tox sec nid + hPutClient h "Handshake sent" goParse ("g", s) | Just DHT{..} <- Map.lookup netname dhts -> cmd0 $ do @@ -1715,6 +1724,7 @@ main = runResourceT $ liftBaseWith $ \resT -> do , onionRouter = orouter , externalAddresses = liftM2 (++) btips toxips , announcer = announcer + , mbTox = mbtox } srv <- streamServer (withSession session) (SockAddrUnix "dht.sock") return ( do atomically $ readTVar signalQuit >>= check -- cgit v1.2.3