summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/dhtd.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 96cfbe0e..b4198c1d 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -72,6 +72,7 @@ import DebugUtil
72import Network.UPNP as UPNP 72import Network.UPNP as UPNP
73import Network.Address hiding (NodeId, NodeInfo(..)) 73import Network.Address hiding (NodeId, NodeInfo(..))
74import Network.QueryResponse 74import Network.QueryResponse
75import qualified Network.QueryResponse.TCP as TCP
75import Network.StreamServer 76import Network.StreamServer
76import Network.Kademlia.Bootstrap (refreshBuckets,bootstrap) 77import Network.Kademlia.Bootstrap (refreshBuckets,bootstrap)
77import Network.Kademlia.CommonAPI 78import Network.Kademlia.CommonAPI
@@ -399,6 +400,7 @@ clientSession s@Session{..} sock cnum h = do
399 , ["sessions"] 400 , ["sessions"]
400 , ["session"] 401 , ["session"]
401 , ["netcrypto"] 402 , ["netcrypto"]
403 , ["tcp"]
402 , ["onion"] 404 , ["onion"]
403 , ["g"] 405 , ["g"]
404 , ["p"] 406 , ["p"]
@@ -673,6 +675,14 @@ clientSession s@Session{..} sock cnum h = do
673 setVerbose tag 675 setVerbose tag
674 hPutClient h $ "Showing " ++ show tag ++ " messages." 676 hPutClient h $ "Showing " ++ show tag ++ " messages."
675 677
678 ("tcp",s) | "" <- strp s
679 -> cmd0 $ join $ atomically $ do
680 tcps <- readTVar (TCP.lru $ tcpProberState onionRouter)
681 return $ do
682 now <- getPOSIXTime
683 forM (MM.toList tcps) $ \(MM.Binding (TCP.TCPAddress addr) tcp (Down tm)) -> do
684 hPutClientChunk h $ unwords [show addr, show (now - tm), TCP.showStat tcp] ++ "\n"
685 hPutClient h $ show (MM.size tcps) ++ " active or pending connections.\n"
676 686
677 ("onion", s) | "" <- strp $ map toLower s 687 ("onion", s) | "" <- strp $ map toLower s
678 -> cmd0 $ do 688 -> cmd0 $ do
@@ -692,6 +702,7 @@ clientSession s@Session{..} sock cnum h = do
692 tcp_cache <- readTVar (TCP.probeCache $ tcpProber onionRouter) 702 tcp_cache <- readTVar (TCP.probeCache $ tcpProber onionRouter)
693 tcp_queue <- readTVar (TCP.probeQueue $ tcpProber onionRouter) 703 tcp_queue <- readTVar (TCP.probeQueue $ tcpProber onionRouter)
694 tcpmode <- readTVar (tcpMode onionRouter) 704 tcpmode <- readTVar (tcpMode onionRouter)
705 tcps <- readTVar (TCP.lru $ tcpProberState onionRouter)
695 let showRecord :: Int -> Int -> [String] 706 let showRecord :: Int -> Int -> [String]
696 showRecord n wanted_ver 707 showRecord n wanted_ver
697 | Just RouteRecord{responseCount,timeoutCount,routeVersion,routeBirthTime 708 | Just RouteRecord{responseCount,timeoutCount,routeVersion,routeBirthTime
@@ -709,6 +720,7 @@ clientSession s@Session{..} sock cnum h = do
709 ++ if tcpmode then "" else " *" 720 ++ if tcpmode then "" else " *"
710 , "trampolines(TCP): " ++ show (IntMap.size tts,ttcnt,ticnt) 721 , "trampolines(TCP): " ++ show (IntMap.size tts,ttcnt,ticnt)
711 ++ if tcpmode then " *" else "" 722 ++ if tcpmode then " *" else ""
723 , "active TCP: " ++ show (MM.size tcps)
712 , "pending: " ++ show (W64.size pqs) 724 , "pending: " ++ show (W64.size pqs)
713 , "TCP spill,cache,queue: " 725 , "TCP spill,cache,queue: "
714 ++ show (PSQ.size tcp_spill, PSQ.size tcp_cache, PSQ.size tcp_queue)] 726 ++ show (PSQ.size tcp_spill, PSQ.size tcp_cache, PSQ.size tcp_queue)]