summaryrefslogtreecommitdiff
path: root/dht/examples/dhtd.hs
diff options
context:
space:
mode:
Diffstat (limited to 'dht/examples/dhtd.hs')
-rw-r--r--dht/examples/dhtd.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/dht/examples/dhtd.hs b/dht/examples/dhtd.hs
index 0f95f562..bd12821a 100644
--- a/dht/examples/dhtd.hs
+++ b/dht/examples/dhtd.hs
@@ -35,6 +35,7 @@ import Data.Bits (xor)
35import Data.Char 35import Data.Char
36import Data.Conduit as C 36import Data.Conduit as C
37import qualified Data.Conduit.List as C 37import qualified Data.Conduit.List as C
38import Data.Dependent.Sum
38import Data.Function 39import Data.Function
39import Data.Functor.Identity 40import Data.Functor.Identity
40import Data.Hashable 41import Data.Hashable
@@ -66,6 +67,7 @@ import Announcer.Tox
66import ToxManager 67import ToxManager
67import Codec.AsciiKey256 68import Codec.AsciiKey256
68import Crypto.Tox -- (zeros32,SecretKey,PublicKey, generateSecretKey, toPublic, encodeSecret, decodeSecret, userKeys) 69import Crypto.Tox -- (zeros32,SecretKey,PublicKey, generateSecretKey, toPublic, encodeSecret, decodeSecret, userKeys)
70import qualified Data.Tox.DHT.Multi as Multi
69import DebugUtil 71import DebugUtil
70import Network.UPNP as UPNP 72import Network.UPNP as UPNP
71import Network.Address hiding (NodeId, NodeInfo(..)) 73import Network.Address hiding (NodeId, NodeInfo(..))
@@ -1417,7 +1419,7 @@ initTox opts ssvar keysdb mbxmpp invc = case porttox opts of
1417 { dhtBuckets = bkts (Tox.toxRouting tox) 1419 { dhtBuckets = bkts (Tox.toxRouting tox)
1418 , dhtPing = Map.fromList 1420 , dhtPing = Map.fromList
1419 [ ("ping", DHTPing 1421 [ ("ping", DHTPing
1420 { pingQuery = noArgPing $ fmap (bool Nothing (Just ())) . Tox.ping (Tox.toxDHT tox) 1422 { pingQuery = noArgPing $ fmap (bool Nothing (Just ())) . Tox.pingUDP (Tox.toxDHT tox)
1421 , pingShowResult = show 1423 , pingShowResult = show
1422 }) 1424 })
1423 , ("cookie", DHTPing 1425 , ("cookie", DHTPing
@@ -1426,6 +1428,7 @@ initTox opts ssvar keysdb mbxmpp invc = case porttox opts of
1426 -> Tox.cookieRequest (Tox.toxCryptoKeys tox) 1428 -> Tox.cookieRequest (Tox.toxCryptoKeys tox)
1427 (Tox.toxDHT tox) 1429 (Tox.toxDHT tox)
1428 (Tox.id2key mykey) 1430 (Tox.id2key mykey)
1431 . (Multi.UDP ==>)
1429 _ -> const $ return Nothing 1432 _ -> const $ return Nothing
1430 , pingShowResult = show 1433 , pingShowResult = show
1431 })] 1434 })]
@@ -1434,7 +1437,7 @@ initTox opts ssvar keysdb mbxmpp invc = case porttox opts of
1434 { qsearch = Tox.nodeSearch (Tox.toxDHT tox) 1437 { qsearch = Tox.nodeSearch (Tox.toxDHT tox)
1435 (Tox.nodesOfInterest $ Tox.toxRouting tox) 1438 (Tox.nodesOfInterest $ Tox.toxRouting tox)
1436 , qhandler = (\ni -> fmap Tox.unwrapNodes 1439 , qhandler = (\ni -> fmap Tox.unwrapNodes
1437 . Tox.getNodesH (Tox.toxRouting tox) ni 1440 . Tox.getNodesH (Tox.toxRouting tox) (Multi.UDP ==> ni)
1438 . Tox.GetNodes) 1441 . Tox.GetNodes)
1439 , qshowR = show -- NodeInfo 1442 , qshowR = show -- NodeInfo
1440 , qshowTok = (const Nothing) 1443 , qshowTok = (const Nothing)
@@ -1444,7 +1447,8 @@ initTox opts ssvar keysdb mbxmpp invc = case porttox opts of
1444 , qhandler = -- qhandler :: ni -> nid -> IO ([ni], [r], tok) 1447 , qhandler = -- qhandler :: ni -> nid -> IO ([ni], [r], tok)
1445 (\ni nid -> 1448 (\ni nid ->
1446 Tox.unwrapAnnounceResponse Nothing 1449 Tox.unwrapAnnounceResponse Nothing
1447 <$> clientAddress (Tox.toxDHT tox) Nothing 1450 <$> fmap (fromJust . Multi.udpNode)
1451 (clientAddress (Tox.toxDHT tox) Nothing)
1448 <*> Tox.announceH (Tox.toxRouting tox) 1452 <*> Tox.announceH (Tox.toxRouting tox)
1449 (Tox.toxTokens tox) 1453 (Tox.toxTokens tox)
1450 (Tox.toxAnnouncedKeys tox) 1454 (Tox.toxAnnouncedKeys tox)
@@ -1800,7 +1804,7 @@ main = do
1800 let defaultToxData = do 1804 let defaultToxData = do
1801 rster <- Tox.newContactInfo 1805 rster <- Tox.newContactInfo
1802 crypto <- newCrypto 1806 crypto <- newCrypto
1803 (orouter,_) <- newOnionRouter crypto (dput XMisc) (enableTCPDHT opts) 1807 (orouter,_,_) <- newOnionRouter crypto (dput XMisc) False -- (enableTCPDHT opts)
1804 return (rster, orouter) 1808 return (rster, orouter)
1805 (rstr,orouter) <- fromMaybe defaultToxData $ do 1809 (rstr,orouter) <- fromMaybe defaultToxData $ do
1806 tox <- mbtox 1810 tox <- mbtox