diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-05-29 03:36:02 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-05-29 03:36:02 +0000 |
commit | 1c65905502df013ab0076726aa919b91c14d7a4c (patch) | |
tree | 1d8eb5d891cc9a3d618d3de3ffcfaa40c28a75f6 /src/Network/Tox/Onion | |
parent | 89f012de3884c56ed48932091ebe9c5d5a291d27 (diff) |
dput: suppressible debug prints
Diffstat (limited to 'src/Network/Tox/Onion')
-rw-r--r-- | src/Network/Tox/Onion/Handlers.hs | 5 | ||||
-rw-r--r-- | src/Network/Tox/Onion/Transport.hs | 7 |
2 files changed, 7 insertions, 5 deletions
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 | |||
43 | import Data.Bits | 43 | import Data.Bits |
44 | import Data.Ord | 44 | import Data.Ord |
45 | import Data.Functor.Identity | 45 | import Data.Functor.Identity |
46 | import DPut | ||
46 | 47 | ||
47 | type Client r = QR.Client String PacketKind TransactionId (OnionDestination r) Message | 48 | type Client r = QR.Client String PacketKind TransactionId (OnionDestination r) Message |
48 | type Message = OnionMessage Identity | 49 | type Message = OnionMessage Identity |
@@ -77,7 +78,7 @@ announceH routing toks keydb oaddr req = do | |||
77 | _ -> let Nonce32 bs = announcePingId req | 78 | _ -> let Nonce32 bs = announcePingId req |
78 | tok = fromPaddedByteString 32 bs | 79 | tok = fromPaddedByteString 32 bs |
79 | in checkToken toks (onionNodeInfo oaddr) tok >>= go | 80 | in checkToken toks (onionNodeInfo oaddr) tok >>= go |
80 | `catch` (\(SomeException e) -> hPutStrLn stderr ("announceH Exception! "++show e) >> throw e) | 81 | `catch` (\(SomeException e) -> dput XAnnounce ("announceH Exception! "++show e) >> throw e) |
81 | where | 82 | where |
82 | go withTok = do | 83 | go withTok = do |
83 | let naddr = onionNodeInfo oaddr | 84 | let naddr = onionNodeInfo oaddr |
@@ -87,7 +88,7 @@ announceH routing toks keydb oaddr req = do | |||
87 | let storing = case oaddr of | 88 | let storing = case oaddr of |
88 | OnionToOwner _ pth -> guard (nodeId naddr == announceSeeking req) >> Just pth | 89 | OnionToOwner _ pth -> guard (nodeId naddr == announceSeeking req) >> Just pth |
89 | _ -> Nothing | 90 | _ -> Nothing |
90 | hPutStrLn stderr $ unlines [ "announceH: nodeId = " ++ show (nodeId naddr) | 91 | dput XAnnounce $ unlines [ "announceH: nodeId = " ++ show (nodeId naddr) |
91 | , " announceSeeking = " ++ show (announceSeeking req) | 92 | , " announceSeeking = " ++ show (announceSeeking req) |
92 | , " withTok = " ++ show withTok | 93 | , " withTok = " ++ show withTok |
93 | , " storing = " ++ maybe "False" (const "True") storing | 94 | , " 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 | |||
79 | import System.IO | 79 | import System.IO |
80 | import qualified Text.ParserCombinators.ReadP as RP | 80 | import qualified Text.ParserCombinators.ReadP as RP |
81 | import Data.Hashable | 81 | import Data.Hashable |
82 | import DPut | ||
82 | 83 | ||
83 | type HandleLo a = Maybe (Either String (ByteString, SockAddr)) -> IO a | 84 | type HandleLo a = Maybe (Either String (ByteString, SockAddr)) -> IO a |
84 | 85 | ||
@@ -481,17 +482,17 @@ handleOnionRequest :: forall a proxy n. | |||
481 | ) => proxy n -> TransportCrypto -> SockAddr -> UDPTransport -> IO a -> OnionRequest n -> IO a | 482 | ) => proxy n -> TransportCrypto -> SockAddr -> UDPTransport -> IO a -> OnionRequest n -> IO a |
482 | handleOnionRequest proxy crypto saddr udp kont (OnionRequest nonce msg rpath) = do | 483 | handleOnionRequest proxy crypto saddr udp kont (OnionRequest nonce msg rpath) = do |
483 | let n = peanoVal rpath | 484 | let n = peanoVal rpath |
484 | hPutStrLn stderr $ "handleOnionRequest " ++ show n | 485 | dput XOnion $ "handleOnionRequest " ++ show n |
485 | (sym, snonce) <- atomically ( (,) <$> transportSymmetric crypto | 486 | (sym, snonce) <- atomically ( (,) <$> transportSymmetric crypto |
486 | <*> transportNewNonce crypto ) | 487 | <*> transportNewNonce crypto ) |
487 | peeled <- peelOnion crypto nonce msg | 488 | peeled <- peelOnion crypto nonce msg |
488 | case peeled of | 489 | case peeled of |
489 | Left e -> do | 490 | Left e -> do |
490 | -- todo report encryption error | 491 | -- todo report encryption error |
491 | hPutStrLn stderr $ unwords [ "peelOnion:", show n, either show show (either4or6 saddr), e] | 492 | dput XOnion $ unwords [ "peelOnion:", show n, either show show (either4or6 saddr), e] |
492 | kont | 493 | kont |
493 | Right (Addressed dst msg') -> do | 494 | Right (Addressed dst msg') -> do |
494 | hPutStrLn stderr $ unwords [ "peelOnion:", show n, either show show (either4or6 saddr), "-->", either show show (either4or6 dst), "SUCCESS"] | 495 | dput XOnion $ unwords [ "peelOnion:", show n, either show show (either4or6 saddr), "-->", either show show (either4or6 dst), "SUCCESS"] |
495 | sendMessage udp dst (runPut $ putRequest $ OnionRequest nonce msg' $ wrapSymmetric sym snonce saddr rpath) | 496 | sendMessage udp dst (runPut $ putRequest $ OnionRequest nonce msg' $ wrapSymmetric sym snonce saddr rpath) |
496 | kont | 497 | kont |
497 | 498 | ||