summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/dhtd.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index b3c60015..918df327 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -449,12 +449,16 @@ clientSession s@Session{..} sock cnum h = do
449 mkrow _ = error (concat ["Assertion fail in 'mkrow' function at ", __FILE__, ":", show __LINE__]) 449 mkrow _ = error (concat ["Assertion fail in 'mkrow' function at ", __FILE__, ":", show __LINE__])
450 sessionCommands :: [[String]] 450 sessionCommands :: [[String]]
451 sessionCommands = 451 sessionCommands =
452 [ ["stop"] 452 [ ["ping"] -- pinglike
453 , ["cookie"] -- pinglike
454 , ["stop"]
455 , ["throw"]
453 , ["quit"] 456 , ["quit"]
454 , ["pid"] 457 , ["pid"]
455 , ["external-ip"] 458 , ["external-ip"]
456 , ["threads"] 459 , ["threads"]
457 , ["mem"] 460 , ["mem"]
461 , ["nid"]
458 , ["ls"] 462 , ["ls"]
459 , ["k"] 463 , ["k"]
460 , ["roster"] 464 , ["roster"]
@@ -471,7 +475,6 @@ clientSession s@Session{..} sock cnum h = do
471 , ["toxids"] 475 , ["toxids"]
472 , ["c"] 476 , ["c"]
473 , ["help"] 477 , ["help"]
474 , ["throw"]
475 ] 478 ]
476 case (map toLower c,args) of 479 case (map toLower c,args) of
477 (n, _) | n `elem` Map.keys dhts -> switchNetwork n 480 (n, _) | n `elem` Map.keys dhts -> switchNetwork n
@@ -550,6 +553,16 @@ clientSession s@Session{..} sock cnum h = do
550 else hPutClient h "Run with +RTS -T to obtain live memory-usage information." 553 else hPutClient h "Run with +RTS -T to obtain live memory-usage information."
551 _ -> hPutClient h "error." 554 _ -> hPutClient h "error."
552 555
556 ("nid", s) | Just DHT{dhtParseId} <- Map.lookup netname dhts
557 -> cmd0 $ do
558 hPutClient h $ case dhtParseId s of
559 Left e ->
560 -- HACK: split nospam from hex toxid
561 case dhtParseId (take 64 s) of
562 Left e -> "Error: " ++ e
563 Right nid -> show nid ++ " nospam:" ++ drop 64 s
564 Right nid -> show nid
565
553 ("ls", _) | Just DHT{dhtBuckets} <- Map.lookup netname dhts 566 ("ls", _) | Just DHT{dhtBuckets} <- Map.lookup netname dhts
554 -> cmd0 $ do 567 -> cmd0 $ do
555 bkts <- atomically $ readTVar dhtBuckets 568 bkts <- atomically $ readTVar dhtBuckets