From 1c65905502df013ab0076726aa919b91c14d7a4c Mon Sep 17 00:00:00 2001 From: James Crayne Date: Tue, 29 May 2018 03:36:02 +0000 Subject: dput: suppressible debug prints --- src/Network/Tox/Onion/Handlers.hs | 5 +++-- src/Network/Tox/Onion/Transport.hs | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/Network/Tox/Onion') diff --git a/src/Network/Tox/Onion/Handlers.hs b/src/Network/Tox/Onion/Handlers.hs index 8c3a9a86..94ece8ab 100644 --- a/src/Network/Tox/Onion/Handlers.hs +++ b/src/Network/Tox/Onion/Handlers.hs @@ -43,6 +43,7 @@ import Data.Maybe import Data.Bits import Data.Ord import Data.Functor.Identity +import DPut type Client r = QR.Client String PacketKind TransactionId (OnionDestination r) Message type Message = OnionMessage Identity @@ -77,7 +78,7 @@ announceH routing toks keydb oaddr req = do _ -> let Nonce32 bs = announcePingId req tok = fromPaddedByteString 32 bs in checkToken toks (onionNodeInfo oaddr) tok >>= go - `catch` (\(SomeException e) -> hPutStrLn stderr ("announceH Exception! "++show e) >> throw e) + `catch` (\(SomeException e) -> dput XAnnounce ("announceH Exception! "++show e) >> throw e) where go withTok = do let naddr = onionNodeInfo oaddr @@ -87,7 +88,7 @@ announceH routing toks keydb oaddr req = do let storing = case oaddr of OnionToOwner _ pth -> guard (nodeId naddr == announceSeeking req) >> Just pth _ -> Nothing - hPutStrLn stderr $ unlines [ "announceH: nodeId = " ++ show (nodeId naddr) + dput XAnnounce $ unlines [ "announceH: nodeId = " ++ show (nodeId naddr) , " announceSeeking = " ++ show (announceSeeking req) , " withTok = " ++ show withTok , " storing = " ++ maybe "False" (const "True") storing diff --git a/src/Network/Tox/Onion/Transport.hs b/src/Network/Tox/Onion/Transport.hs index 23fd369b..550a7730 100644 --- a/src/Network/Tox/Onion/Transport.hs +++ b/src/Network/Tox/Onion/Transport.hs @@ -79,6 +79,7 @@ import Network.Socket import System.IO import qualified Text.ParserCombinators.ReadP as RP import Data.Hashable +import DPut type HandleLo a = Maybe (Either String (ByteString, SockAddr)) -> IO a @@ -481,17 +482,17 @@ handleOnionRequest :: forall a proxy n. ) => proxy n -> TransportCrypto -> SockAddr -> UDPTransport -> IO a -> OnionRequest n -> IO a handleOnionRequest proxy crypto saddr udp kont (OnionRequest nonce msg rpath) = do let n = peanoVal rpath - hPutStrLn stderr $ "handleOnionRequest " ++ show n + dput XOnion $ "handleOnionRequest " ++ show n (sym, snonce) <- atomically ( (,) <$> transportSymmetric crypto <*> transportNewNonce crypto ) peeled <- peelOnion crypto nonce msg case peeled of Left e -> do -- todo report encryption error - hPutStrLn stderr $ unwords [ "peelOnion:", show n, either show show (either4or6 saddr), e] + dput XOnion $ unwords [ "peelOnion:", show n, either show show (either4or6 saddr), e] kont Right (Addressed dst msg') -> do - hPutStrLn stderr $ unwords [ "peelOnion:", show n, either show show (either4or6 saddr), "-->", either show show (either4or6 dst), "SUCCESS"] + dput XOnion $ unwords [ "peelOnion:", show n, either show show (either4or6 saddr), "-->", either show show (either4or6 dst), "SUCCESS"] sendMessage udp dst (runPut $ putRequest $ OnionRequest nonce msg' $ wrapSymmetric sym snonce saddr rpath) kont -- cgit v1.2.3