diff options
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r-- | examples/dhtd.hs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index d6049c13..45a2a682 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -351,6 +351,10 @@ clientSession0 s sock cnum h = do | |||
351 | parseDebugTag :: String -> Maybe DebugTag | 351 | parseDebugTag :: String -> Maybe DebugTag |
352 | parseDebugTag s' = readMaybe ('X':map toUpper (take 1 s') ++ drop 1 s') | 352 | parseDebugTag s' = readMaybe ('X':map toUpper (take 1 s') ++ drop 1 s') |
353 | 353 | ||
354 | showPolicy TryingToConnect = "*" | ||
355 | showPolicy OpenToConnect = "o" | ||
356 | showPolicy RefusingToConnect = "x" | ||
357 | |||
354 | clientSession :: Session -> t1 -> t -> ClientHandle -> IO () | 358 | clientSession :: Session -> t1 -> t -> ClientHandle -> IO () |
355 | clientSession s@Session{..} sock cnum h = do | 359 | clientSession s@Session{..} sock cnum h = do |
356 | line <- dropWhile isSpace <$> hGetClientLine h | 360 | line <- dropWhile isSpace <$> hGetClientLine h |
@@ -640,10 +644,7 @@ clientSession s@Session{..} sock cnum h = do | |||
640 | ca <- readTVar $ contactLastSeenAddr c | 644 | ca <- readTVar $ contactLastSeenAddr c |
641 | cf <- readTVar $ contactFriendRequest c | 645 | cf <- readTVar $ contactFriendRequest c |
642 | cp <- readTVar $ contactPolicy c | 646 | cp <- readTVar $ contactPolicy c |
643 | let showPolicy TryingToConnect = "*" | 647 | let summarizeNodeId | nosummary = id |
644 | showPolicy OpenToConnect = "o" | ||
645 | showPolicy RefusingToConnect = "x" | ||
646 | summarizeNodeId | nosummary = id | ||
647 | | otherwise = take 6 | 648 | | otherwise = take 6 |
648 | summarizeAddr | nosummary = id | 649 | summarizeAddr | nosummary = id |
649 | | otherwise = reverse . take 20 . reverse | 650 | | otherwise = reverse . take 20 . reverse |
@@ -1275,12 +1276,18 @@ clientSession s@Session{..} sock cnum h = do | |||
1275 | ("c", s) | Just (ConnectionManager mgr) <- connectionManager | 1276 | ("c", s) | Just (ConnectionManager mgr) <- connectionManager |
1276 | , "" <- strp s | 1277 | , "" <- strp s |
1277 | -> cmd0 $ join $ atomically $ do | 1278 | -> cmd0 $ join $ atomically $ do |
1278 | cmap <- connections mgr | 1279 | cs <- do |
1279 | cs <- Map.toList <$> mapM connStatus cmap | 1280 | ks <- connections mgr |
1280 | let mkrow = Connection.showKey mgr *** Connection.showStatus mgr | 1281 | forM ks $ \k -> do |
1281 | rs = map mkrow cs | 1282 | stat <- Connection.status mgr k |
1283 | return (k,stat) | ||
1284 | let mkrow (k,st) = [ Connection.showKey mgr k | ||
1285 | , Connection.showStatus mgr (connStatus st) | ||
1286 | , showPolicy (connPolicy st) | ||
1287 | ] | ||
1288 | rs = map mkrow cs | ||
1282 | return $ do | 1289 | return $ do |
1283 | hPutClient h $ showReport rs | 1290 | hPutClient h $ showColumns rs |
1284 | 1291 | ||
1285 | ("help", s) | Just DHT{..} <- Map.lookup netname dhts | 1292 | ("help", s) | Just DHT{..} <- Map.lookup netname dhts |
1286 | -> cmd0 $ do | 1293 | -> cmd0 $ do |