summaryrefslogtreecommitdiff
path: root/src/Network/Tox
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-10 02:21:13 -0400
committerjoe <joe@jerkface.net>2018-06-10 02:21:28 -0400
commite27ad4390a27011b9cec04769e92020089e8c302 (patch)
treeb451b27fe89d390c2725064ec279dfb96c9bcd09 /src/Network/Tox
parent2313073b3e85ed2479ac4246de29e8867f51603b (diff)
Tox: improved data-to-route and onion debug prints.
Diffstat (limited to 'src/Network/Tox')
-rw-r--r--src/Network/Tox/Crypto/Transport.hs4
-rw-r--r--src/Network/Tox/Onion/Transport.hs11
2 files changed, 9 insertions, 6 deletions
diff --git a/src/Network/Tox/Crypto/Transport.hs b/src/Network/Tox/Crypto/Transport.hs
index bc112078..73143e35 100644
--- a/src/Network/Tox/Crypto/Transport.hs
+++ b/src/Network/Tox/Crypto/Transport.hs
@@ -86,8 +86,8 @@ encodeCrypto :: (CryptoPacket Encrypted, SockAddr) -> Maybe (ByteString, SockAdd
86encodeCrypto (x,saddr) = Just (B.cons 0x1b (runPut $ put x),saddr) 86encodeCrypto (x,saddr) = Just (B.cons 0x1b (runPut $ put x),saddr)
87 87
88parseHandshakes :: ByteString -> SockAddr -> Either String (Handshake Encrypted, SockAddr) 88parseHandshakes :: ByteString -> SockAddr -> Either String (Handshake Encrypted, SockAddr)
89parseHandshakes (B.uncons -> Just (0x1a,pkt)) saddr = left ("parseNetCrypto: "++) $ (,saddr) <$> runGet get pkt 89parseHandshakes (B.uncons -> Just (0x1a,pkt)) saddr = left ("parseHandshakes: "++) $ (,saddr) <$> runGet get pkt
90parseHandshakes _ _ = Left "parseHandshakes_: ?" 90parseHandshakes bs _ = Left $ "parseHandshakes_: " ++ show (B.unpack $ B.take 1 bs)
91 91
92encodeHandshakes :: Handshake Encrypted -> SockAddr -> (ByteString, SockAddr) 92encodeHandshakes :: Handshake Encrypted -> SockAddr -> (ByteString, SockAddr)
93encodeHandshakes x saddr = (B.cons 0x1a (runPut $ put x),saddr) 93encodeHandshakes x saddr = (B.cons 0x1a (runPut $ put x),saddr)
diff --git a/src/Network/Tox/Onion/Transport.hs b/src/Network/Tox/Onion/Transport.hs
index d604a5c8..864e831f 100644
--- a/src/Network/Tox/Onion/Transport.hs
+++ b/src/Network/Tox/Onion/Transport.hs
@@ -891,12 +891,15 @@ parseDataToRoute crypto (OnionToRouteResponse dta, od) = do
891 $ Rendezvous (rendezvousPublic crypto) $ onionNodeInfo od ) 891 $ Rendezvous (rendezvousPublic crypto) $ onionNodeInfo od )
892 r = either (const $ Right (OnionToRouteResponse dta,od)) Left e 892 r = either (const $ Right (OnionToRouteResponse dta,od)) Left e
893 -- parseDataToRoute OnionToRouteResponse decipherAndAuth: auth fail 893 -- parseDataToRoute OnionToRouteResponse decipherAndAuth: auth fail
894 case e of
895 Left _ -> hPutStrLn stderr $ "Failed keys: " ++ show (map (key2id . snd) ks)
896 Right _ -> return ()
894 hPutStrLn stderr $ unlines 897 hPutStrLn stderr $ unlines
895 [ "parseDataToRoute " ++ either id (const "Right") e 898 [ "parseDataToRoute " ++ either id (const "Right") e
896 , " crypto inner.me =" ++ either id (\(pk,_,_) -> show $ key2id pk) eInner 899 , " crypto inner.me = " ++ either id (\(pk,_,_) -> show $ key2id pk) eInner
897 , " inner.you=" ++ either id (show . key2id . dataFromKey) eOuter 900 , " inner.them = " ++ either id (show . key2id . dataFromKey) eOuter
898 , " outer.me =" ++ show (key2id $ rendezvousPublic crypto) 901 , " outer.me = " ++ show (key2id $ rendezvousPublic crypto)
899 , " outer.you=" ++ show (key2id $ senderKey dta) 902 , " outer.them = " ++ show (key2id $ senderKey dta)
900 ] 903 ]
901 return r 904 return r
902parseDataToRoute _ msg = return $ Right msg 905parseDataToRoute _ msg = return $ Right msg