diff options
author | joe <joe@jerkface.net> | 2018-06-24 20:18:43 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-06-24 20:18:43 -0400 |
commit | fab0ea6ff17b2109b20ebffcef9262b1684203ca (patch) | |
tree | 18b6081de307839178174916134bdde919038953 | |
parent | 505ccbbf01d341e6c53af7b005ba8affe956d358 (diff) |
* Prevent XMPP layer from sending pings to tox peer.
* Lookup node-id for specifying with "netcrypto" command-line.
-rw-r--r-- | examples/dhtd.hs | 17 |
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 | |||
62 | import qualified Data.Text as T | 62 | import qualified Data.Text as T |
63 | import qualified Data.Text.Encoding as T | 63 | import qualified Data.Text.Encoding as T |
64 | import System.Posix.Signals | 64 | import System.Posix.Signals |
65 | import qualified Data.Array | ||
66 | import qualified Data.Array.Unboxed as U | 65 | import qualified Data.Array.Unboxed as U |
67 | import qualified Data.Conduit as Conduit | 66 | import qualified Data.Conduit as Conduit |
68 | 67 | ||
@@ -102,7 +101,6 @@ import qualified Network.Tox.Crypto.Handlers as Tox | |||
102 | import Data.Typeable | 101 | import Data.Typeable |
103 | import Network.Tox.ContactInfo as Tox | 102 | import Network.Tox.ContactInfo as Tox |
104 | import OnionRouter | 103 | import OnionRouter |
105 | import PingMachine | ||
106 | import Data.PacketQueue | 104 | import Data.PacketQueue |
107 | import qualified Data.Word64Map as W64 | 105 | import qualified Data.Word64Map as W64 |
108 | import System.FilePath | 106 | import 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 |