diff options
author | joe <joe@jerkface.net> | 2018-06-10 02:21:13 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-06-10 02:21:28 -0400 |
commit | e27ad4390a27011b9cec04769e92020089e8c302 (patch) | |
tree | b451b27fe89d390c2725064ec279dfb96c9bcd09 /src/Network/Tox | |
parent | 2313073b3e85ed2479ac4246de29e8867f51603b (diff) |
Tox: improved data-to-route and onion debug prints.
Diffstat (limited to 'src/Network/Tox')
-rw-r--r-- | src/Network/Tox/Crypto/Transport.hs | 4 | ||||
-rw-r--r-- | src/Network/Tox/Onion/Transport.hs | 11 |
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 | |||
86 | encodeCrypto (x,saddr) = Just (B.cons 0x1b (runPut $ put x),saddr) | 86 | encodeCrypto (x,saddr) = Just (B.cons 0x1b (runPut $ put x),saddr) |
87 | 87 | ||
88 | parseHandshakes :: ByteString -> SockAddr -> Either String (Handshake Encrypted, SockAddr) | 88 | parseHandshakes :: ByteString -> SockAddr -> Either String (Handshake Encrypted, SockAddr) |
89 | parseHandshakes (B.uncons -> Just (0x1a,pkt)) saddr = left ("parseNetCrypto: "++) $ (,saddr) <$> runGet get pkt | 89 | parseHandshakes (B.uncons -> Just (0x1a,pkt)) saddr = left ("parseHandshakes: "++) $ (,saddr) <$> runGet get pkt |
90 | parseHandshakes _ _ = Left "parseHandshakes_: ?" | 90 | parseHandshakes bs _ = Left $ "parseHandshakes_: " ++ show (B.unpack $ B.take 1 bs) |
91 | 91 | ||
92 | encodeHandshakes :: Handshake Encrypted -> SockAddr -> (ByteString, SockAddr) | 92 | encodeHandshakes :: Handshake Encrypted -> SockAddr -> (ByteString, SockAddr) |
93 | encodeHandshakes x saddr = (B.cons 0x1a (runPut $ put x),saddr) | 93 | encodeHandshakes 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 |
902 | parseDataToRoute _ msg = return $ Right msg | 905 | parseDataToRoute _ msg = return $ Right msg |