From 15a8a7270fc35f0a7e77b09d82c1aaded8d44885 Mon Sep 17 00:00:00 2001 From: James Crayne Date: Tue, 29 May 2018 04:34:26 +0000 Subject: more dput stuff --- src/Network/Tox/DHT/Handlers.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/Network/Tox/DHT') diff --git a/src/Network/Tox/DHT/Handlers.hs b/src/Network/Tox/DHT/Handlers.hs index e2dc8eba..08801cc7 100644 --- a/src/Network/Tox/DHT/Handlers.hs +++ b/src/Network/Tox/DHT/Handlers.hs @@ -37,6 +37,7 @@ import Data.Serialize (Serialize) import Data.Word import Data.List import System.IO +import DPut data TransactionId = TransactionId { transactionKey :: Nonce8 -- ^ Used to lookup pending query. @@ -230,16 +231,16 @@ createCookie crypto ni remoteUserKey = do , dhtKey = transportPublic crypto } edta = encryptSymmetric sym n24 dta - hPutStrLn stderr $ "Created cookie with n24 = 0x" ++ show n24 ++ "\n sym=" ++ show sym + dput XNetCrypto $ "Created cookie with n24 = 0x" ++ show n24 ++ "\n sym=" ++ show sym return $ Cookie n24 edta cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie cookieRequestH crypto ni (CookieRequest remoteUserKey) = do - hPutStrLn stderr $ unlines + dput XNetCrypto $ unlines [ "CookieRequest! remoteUserKey=" ++ show (key2id remoteUserKey) , " sender=" ++ show ni ] x <- createCookie crypto ni remoteUserKey - hPutStrLn stderr $ "CookieRequest! responding to " ++ show (key2id remoteUserKey) + dput XNetCrypto $ "CookieRequest! responding to " ++ show (key2id remoteUserKey) return x lanDiscoveryH :: Client -> NodeInfo -> NodeInfo -> IO (Maybe (Message -> Message)) @@ -285,9 +286,9 @@ showHex bs = C8.unpack $ Base16.encode $ BA.convert bs ping :: Client -> NodeInfo -> IO Bool ping client addr = do - hPutStrLn stderr $ show addr ++ " <-- ping" + dput XPing $ show addr ++ " <-- ping" reply <- QR.sendQuery client (serializer PingType DHTPing unpong) Ping addr - hPutStrLn stderr $ show addr ++ " -pong-> " ++ show reply + dput XPing $ show addr ++ " -pong-> " ++ show reply maybe (return False) (\Pong -> return True) $ join reply @@ -323,10 +324,10 @@ cookieRequest crypto client localUserKey addr = do } cookieRequest = CookieRequest localUserKey atomically $ saveCookieKey (pendingCookies crypto) sockAddr nid - hPutStrLn stderr $ show addr ++ " <-- cookieRequest" + dput XNetCrypto $ show addr ++ " <-- cookieRequest" reply <- QR.sendQuery client cookieSerializer cookieRequest addr atomically $ loseCookieKey (pendingCookies crypto) sockAddr nid - hPutStrLn stderr $ show addr ++ " -cookieResponse-> " ++ show reply + dput XNetCrypto $ show addr ++ " -cookieResponse-> " ++ show reply return $ join reply unCookie :: DHTMessage t -> Maybe (t Cookie) -- cgit v1.2.3