diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dhtd.hs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 0b208362..1ab2778a 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -45,6 +45,7 @@ import Control.Concurrent.Lifted | |||
45 | import GHC.Conc (labelThread) | 45 | import GHC.Conc (labelThread) |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | import Crypto.Tox (zeros32) | ||
48 | import Network.UPNP as UPNP | 49 | import Network.UPNP as UPNP |
49 | import Network.Address hiding (NodeId, NodeInfo(..)) | 50 | import Network.Address hiding (NodeId, NodeInfo(..)) |
50 | import Network.Kademlia.Search | 51 | import Network.Kademlia.Search |
@@ -68,6 +69,7 @@ import Data.Ord | |||
68 | import Data.Time.Clock.POSIX | 69 | import Data.Time.Clock.POSIX |
69 | import qualified Network.Tox.DHT.Transport as Tox | 70 | import qualified Network.Tox.DHT.Transport as Tox |
70 | import qualified Network.Tox.DHT.Handlers as Tox | 71 | import qualified Network.Tox.DHT.Handlers as Tox |
72 | import qualified Network.Tox.Onion.Transport as Tox | ||
71 | import qualified Network.Tox.Onion.Handlers as Tox | 73 | import qualified Network.Tox.Onion.Handlers as Tox |
72 | import Data.Typeable | 74 | import Data.Typeable |
73 | 75 | ||
@@ -99,7 +101,7 @@ data DHTQuery nid ni = forall addr r tok. | |||
99 | , Typeable r | 101 | , Typeable r |
100 | )=> DHTQuery | 102 | )=> DHTQuery |
101 | { qsearch :: Search nid addr tok ni r | 103 | { qsearch :: Search nid addr tok ni r |
102 | , qhandler :: ni -> nid -> IO ([ni], [r], tok) | 104 | , qhandler :: ni -> nid -> IO ([ni], [r], tok) -- ^ Invoked on local node, when there is no query destination. |
103 | , qshowR :: r -> String | 105 | , qshowR :: r -> String |
104 | , qshowTok :: tok -> Maybe String | 106 | , qshowTok :: tok -> Maybe String |
105 | } | 107 | } |
@@ -585,8 +587,21 @@ main = do | |||
585 | (\ni -> fmap Tox.unwrapNodes | 587 | (\ni -> fmap Tox.unwrapNodes |
586 | . Tox.getNodesH (Tox.toxRouting tox) ni | 588 | . Tox.getNodesH (Tox.toxRouting tox) ni |
587 | . Tox.GetNodes) | 589 | . Tox.GetNodes) |
588 | show | 590 | show -- NodeInfo |
589 | (const Nothing)) | 591 | (const Nothing)) |
592 | , ("toxid", DHTQuery (Tox.toxidSearch (Tox.onionTimeout tox) $ Tox.toxOnion tox) | ||
593 | -- qhandler :: ni -> nid -> IO ([ni], [r], tok) | ||
594 | (\ni nid -> | ||
595 | -- _todo :: IO Tox.AnnounceResponse | ||
596 | -- -> IO ([Tox.NodeInfo], [Crypto.PubKey.Curve25519.PublicKey], b0) | ||
597 | Tox.unwrapAnnounceResponse | ||
598 | <$> Tox.announceH (Tox.toxRouting tox) | ||
599 | (Tox.toxTokens tox) | ||
600 | (Tox.toxAnnouncedKeys tox) | ||
601 | (Tox.OnionDestination ni Nothing) | ||
602 | (Tox.AnnounceRequest zeros32 nid Tox.zeroID)) | ||
603 | show -- PublicKey | ||
604 | (const Nothing)) -- TODO: show token | ||
590 | ] | 605 | ] |
591 | , dhtParseId = readEither :: String -> Either String Tox.NodeId | 606 | , dhtParseId = readEither :: String -> Either String Tox.NodeId |
592 | , dhtSearches = toxSearches | 607 | , dhtSearches = toxSearches |