aboutsummaryrefslogtreecommitdiff
path: root/P2P
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-12-09 16:55:48 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-12-09 16:55:48 -0400
commitb20938878096e97cd4bd54df23ebc35b09414b35 (patch)
treeb084fc750bd7648564b4fcd664d870d35d243457 /P2P
parent6d8573254fef83aa42f3305208c412517b57d5c0 (diff)
avoid exposing auth tokens in debug
Diffstat (limited to 'P2P')
-rw-r--r--P2P/IO.hs18
1 files changed, 13 insertions, 5 deletions
diff --git a/P2P/IO.hs b/P2P/IO.hs
index 72202c2a2..bb93528a6 100644
--- a/P2P/IO.hs
+++ b/P2P/IO.hs
@@ -98,7 +98,7 @@ runNet conn runner f = case f of
SendMessage m next -> do
v <- liftIO $ tryNonAsync $ do
let l = unwords (formatMessage m)
- debugM "p2p" ("P2P > " ++ l)
+ debugMessage "P2P >" m
hPutStrLn (connOhdl conn) l
hFlush (connOhdl conn)
case v of
@@ -109,10 +109,10 @@ runNet conn runner f = case f of
case v of
Left e -> return (Left (show e))
Right Nothing -> return (Left "protocol error")
- Right (Just l) -> do
- liftIO $ debugM "p2p" ("P2P < " ++ l)
- case parseMessage l of
- Just m -> runner (next m)
+ Right (Just l) -> case parseMessage l of
+ Just m -> do
+ liftIO $ debugMessage "P2P <" m
+ runner (next m)
Nothing -> runner $ do
let e = ERROR $ "protocol parse error: " ++ show l
net $ sendMessage e
@@ -150,6 +150,14 @@ runNet conn runner f = case f of
-- all Proto actions.
runnerio = runNetProto conn
+debugMessage :: String -> Message -> IO ()
+debugMessage prefix m = debugM "p2p" $
+ prefix ++ " " ++ unwords (formatMessage safem)
+ where
+ safem = case m of
+ AUTH u _ -> AUTH u nullAuthToken
+ _ -> m
+
-- Send exactly the specified number of bytes or returns False.
--
-- The ByteString can be larger or smaller than the specified length.