summaryrefslogtreecommitdiff
path: root/examples/dhtd.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-24 20:18:43 -0400
committerjoe <joe@jerkface.net>2018-06-24 20:18:43 -0400
commitfab0ea6ff17b2109b20ebffcef9262b1684203ca (patch)
tree18b6081de307839178174916134bdde919038953 /examples/dhtd.hs
parent505ccbbf01d341e6c53af7b005ba8affe956d358 (diff)
* Prevent XMPP layer from sending pings to tox peer.
* Lookup node-id for specifying with "netcrypto" command-line.
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r--examples/dhtd.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index efd51e6d..fefec650 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -62,7 +62,6 @@ import qualified Data.HashMap.Strict as HashMap
62import qualified Data.Text as T 62import qualified Data.Text as T
63import qualified Data.Text.Encoding as T 63import qualified Data.Text.Encoding as T
64import System.Posix.Signals 64import System.Posix.Signals
65import qualified Data.Array
66import qualified Data.Array.Unboxed as U 65import qualified Data.Array.Unboxed as U
67import qualified Data.Conduit as Conduit 66import qualified Data.Conduit as Conduit
68 67
@@ -102,7 +101,6 @@ import qualified Network.Tox.Crypto.Handlers as Tox
102import Data.Typeable 101import Data.Typeable
103import Network.Tox.ContactInfo as Tox 102import Network.Tox.ContactInfo as Tox
104import OnionRouter 103import OnionRouter
105import PingMachine
106import Data.PacketQueue 104import Data.PacketQueue
107import qualified Data.Word64Map as W64 105import qualified Data.Word64Map as W64
108import System.FilePath 106import System.FilePath
@@ -1376,7 +1374,13 @@ netcrypto (Just (DHT {..})) (Just mypubkey) h roster (Just tox) exes paramStr =
1376 Nothing -> hPutClient h "Unable to find account for selected key" 1374 Nothing -> hPutClient h "Unable to find account for selected key"
1377 Just account -> do 1375 Just account -> do
1378 now <- getPOSIXTime 1376 now <- getPOSIXTime
1379 atomically $ setContactAddr now their_pub (_fixme their_addr) account 1377 atomically $ do
1378 mcontact <- HashMap.lookup (Tox.nodeId userkey_nodeinfo) <$> readTVar (contacts account)
1379 forM_ mcontact $ \contact -> do
1380 mnid <- fmap (Tox.key2id . Tox.dhtpk . snd) <$> readTVar (contactKeyPacket contact)
1381 forM_ mnid $ \nid -> do
1382 forM_ (Tox.nodeInfo nid their_addr) $ \their_ni -> do
1383 setContactAddr now their_pub their_ni account
1380 sessions <- Tox.netCrypto tox sec their_pub 1384 sessions <- Tox.netCrypto tox sec their_pub
1381 exeDir <- takeDirectory <$> getExecutablePath 1385 exeDir <- takeDirectory <$> getExecutablePath
1382 forM_ sessions $ \session -> do 1386 forM_ sessions $ \session -> do
@@ -1970,11 +1974,10 @@ main = do
1970 let sockAddr = Tox.ncSockAddr netcrypto 1974 let sockAddr = Tox.ncSockAddr netcrypto
1971 pubKey = Tox.ncTheirPublicKey netcrypto 1975 pubKey = Tox.ncTheirPublicKey netcrypto
1972 tmchan <- atomically newTMChan 1976 tmchan <- atomically newTMChan
1973 mbPingMaching <- atomically $ readTVar (Tox.ncPingMachine netcrypto) 1977 let pingflag = return False -- XMPPServer should never send pings.
1974 let Just pingMachine = mbPingMaching 1978 -- This is taken care of by the tox layer.
1975 pingflag = readTVar (pingFlag pingMachine)
1976 receiveCrypto = atomically $ readTMChan tmchan 1979 receiveCrypto = atomically $ readTMChan tmchan
1977 onEOF = return () -- TODO: Update toxContactInfo, not connected. 1980 onEOF = return () -- setTerminate is called elsewhere.
1978 xmppSrc = ioToSource receiveCrypto onEOF 1981 xmppSrc = ioToSource receiveCrypto onEOF
1979 xmppSink = newXmmpSink netcrypto 1982 xmppSink = newXmmpSink netcrypto
1980 forM_ msv $ \sv -> do 1983 forM_ msv $ \sv -> do