diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dhtd.hs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index badea2b1..67dece2e 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -16,6 +16,8 @@ | |||
16 | {-# LANGUAGE TypeFamilies #-} | 16 | {-# LANGUAGE TypeFamilies #-} |
17 | {-# LANGUAGE TypeOperators #-} | 17 | {-# LANGUAGE TypeOperators #-} |
18 | 18 | ||
19 | module Main where | ||
20 | |||
19 | import Control.Arrow | 21 | import Control.Arrow |
20 | import Control.Applicative | 22 | import Control.Applicative |
21 | import Control.Concurrent.STM | 23 | import Control.Concurrent.STM |
@@ -525,6 +527,16 @@ clientSession s@Session{..} sock cnum h = do | |||
525 | , ("node-id", show $ thisNode bkts) | 527 | , ("node-id", show $ thisNode bkts) |
526 | , ("network", netname) ] | 528 | , ("network", netname) ] |
527 | 529 | ||
530 | -- TODO: online documentation. | ||
531 | -- | ||
532 | -- k - manage key-pairs | ||
533 | -- | ||
534 | -- k (list keys) | ||
535 | -- k gen (generate new key and list keys) | ||
536 | -- k add <secret-key> (input a specific secret key) | ||
537 | -- k del <secret-key> | ||
538 | -- k secrets (list key pairs, including secret keys) | ||
539 | |||
528 | ("k", s) | "" <- strp s -> cmd0 $ do | 540 | ("k", s) | "" <- strp s -> cmd0 $ do |
529 | ks <- atomically $ readTVar userkeys | 541 | ks <- atomically $ readTVar userkeys |
530 | hPutClient h $ unlines $ map (mappend " " . show . Tox.key2id . snd) ks | 542 | hPutClient h $ unlines $ map (mappend " " . show . Tox.key2id . snd) ks |
@@ -607,6 +619,30 @@ clientSession s@Session{..} sock cnum h = do | |||
607 | goQuery | 619 | goQuery |
608 | $ Map.lookup method dhtQuery | 620 | $ Map.lookup method dhtQuery |
609 | 621 | ||
622 | -- TODO: Online help. | ||
623 | -- | ||
624 | -- p - put/publish a single given datum on a single given node. | ||
625 | -- | ||
626 | -- When destination address (node-addr) is optional, it's absense means to | ||
627 | -- publish information in the local node's own database. | ||
628 | -- | ||
629 | -- Bittorrent: (peer) publish yourself as peer in swarm. | ||
630 | -- (port) set your current bittorrent listen port. | ||
631 | -- | ||
632 | -- p peer <infohash> <token> [node-addr] | ||
633 | -- | ||
634 | -- p port <num> | ||
635 | -- | ||
636 | -- Tox: (toxid) publish a rendezvous onion route to dht node. | ||
637 | -- (friend) send a friend-request over a rendezvous point. | ||
638 | -- (dhtkey) send your dht node-id over a rendezvous point. | ||
639 | -- | ||
640 | -- p toxid <key> <token> <node-addr> | ||
641 | -- | ||
642 | -- p friend <key> <nospam> <rendezvous-addr> <text> | ||
643 | -- | ||
644 | -- p dhtkey <key> - <rendezvous-addr> | ||
645 | |||
610 | ("p", s) | Just DHT{..} <- Map.lookup netname dhts | 646 | ("p", s) | Just DHT{..} <- Map.lookup netname dhts |
611 | -> cmd0 $ do | 647 | -> cmd0 $ do |
612 | -- arguments: method | 648 | -- arguments: method |
@@ -635,6 +671,28 @@ clientSession s@Session{..} sock cnum h = do | |||
635 | goTarget | 671 | goTarget |
636 | $ Map.lookup method dhtAnnouncables | 672 | $ Map.lookup method dhtAnnouncables |
637 | 673 | ||
674 | -- TODO: Online documentation. | ||
675 | -- | ||
676 | -- a - announce, like put/publish but automatically selects nodes to publish on | ||
677 | -- and periodically refreshes them. | ||
678 | -- | ||
679 | -- The method name is preceded with a + to start or a - to stop a given | ||
680 | -- recurring publication. | ||
681 | -- | ||
682 | -- BitTorrent: (peer) Every minute, announce you are participating | ||
683 | -- in a torrent swarm. | ||
684 | -- | ||
685 | -- a +peer <infohash> a -peer <infohash> | ||
686 | -- | ||
687 | -- Tox: (toxid) Every 15 seconds, announce your tox identity to the | ||
688 | -- DHT so friends can find you. | ||
689 | -- | ||
690 | -- a +toxid <key> | ||
691 | -- a -toxid <key> | ||
692 | -- | ||
693 | -- These probably don't work: | ||
694 | -- (experimental) a +friend <nospam> <text> | ||
695 | -- (experimental) a +dhtkey | ||
638 | ("a", s) | Just DHT{..} <- Map.lookup netname dhts | 696 | ("a", s) | Just DHT{..} <- Map.lookup netname dhts |
639 | , not (null s) | 697 | , not (null s) |
640 | -> cmd0 $ do | 698 | -> cmd0 $ do |