summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/dhtd.hs18
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index 89604919..6437e94f 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -105,6 +105,7 @@ import Network.Tox.ContactInfo as Tox
105import OnionRouter 105import OnionRouter
106import PingMachine 106import PingMachine
107import Data.PacketQueue 107import Data.PacketQueue
108import qualified Data.Word64Map as W64
108 109
109-- Presence imports. 110-- Presence imports.
110import ConsoleWriter 111import ConsoleWriter
@@ -818,16 +819,19 @@ clientSession s@Session{..} sock cnum h = do
818 tcnt <- readTVar $ trampolineCount onionRouter 819 tcnt <- readTVar $ trampolineCount onionRouter
819 icnt <- HashMap.size <$> readTVar (trampolineIds onionRouter) 820 icnt <- HashMap.size <$> readTVar (trampolineIds onionRouter)
820 rs <- mapM readTVar (pendingRoutes onionRouter) 821 rs <- mapM readTVar (pendingRoutes onionRouter)
821 let showRecord :: Int -> Bool -> [String] 822 pqs <- readTVar (pendingQueries onionRouter)
822 showRecord n True = [show n, "pending", ""] 823 let showRecord :: Int -> Int -> [String]
823 showRecord n False 824 showRecord n wanted_ver
824 | Just RouteRecord{responseCount,timeoutCount} <- IntMap.lookup n rm 825 | Just RouteRecord{responseCount,timeoutCount,routeVersion} <- IntMap.lookup n rm
825 = [show n, show responseCount, show timeoutCount] 826 = if routeVersion >= wanted_ver
827 then [show n, show responseCount, show timeoutCount, show (routeVersion,wanted_ver) ]
828 else [show n, show responseCount, show timeoutCount, show (routeVersion,wanted_ver) ++ "(pending)" ]
826 | otherwise = [show n, "error!",""] 829 | otherwise = [show n, "error!",""]
827 r = map (uncurry showRecord) $ IntMap.toAscList rs 830 r = map (uncurry showRecord) $ IntMap.toAscList rs
828 return $ do 831 return $ do
829 hPutClientChunk h $ "trampolines: " ++ show (IntMap.size ts,tcnt,icnt) ++ "\n" 832 hPutClientChunk h $ unlines [ "trampolines: " ++ show (IntMap.size ts,tcnt,icnt)
830 hPutClient h $ showColumns $ ["","responses","timeouts"]:r 833 , "pending: " ++ show (W64.size pqs) ]
834 hPutClient h $ showColumns $ ["","responses","timeouts", "version"]:r
831 835
832 -- necrypto <FRIEND-TOXID> 836 -- necrypto <FRIEND-TOXID>
833 -- establish a netcrypto session with specified person 837 -- establish a netcrypto session with specified person