summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2018-05-29 04:34:26 +0000
committerJames Crayne <jim.crayne@gmail.com>2018-05-29 04:34:26 +0000
commit15a8a7270fc35f0a7e77b09d82c1aaded8d44885 (patch)
treedaac121221a81bae59c6671e0052d9ba10000005 /src
parent514d0cad3f2ccaf0e89aadb4ab3067884ec20a6c (diff)
more dput stuff
Diffstat (limited to 'src')
-rw-r--r--src/DPut.hs2
-rw-r--r--src/Network/Tox/DHT/Handlers.hs15
2 files changed, 9 insertions, 8 deletions
diff --git a/src/DPut.hs b/src/DPut.hs
index abf926b5..11bcc2d0 100644
--- a/src/DPut.hs
+++ b/src/DPut.hs
@@ -6,7 +6,7 @@ import System.IO (stderr,hPutStrLn)
6import Data.Maybe 6import Data.Maybe
7import System.IO.Unsafe (unsafePerformIO) 7import System.IO.Unsafe (unsafePerformIO)
8 8
9data DebugTag = XAnnounce | XDHT | XOnion | XNetCrypto | XMisc 9data DebugTag = XAnnounce | XDHT | XOnion | XNetCrypto | XPing | XMisc
10 deriving (Eq,Ord,Show,Read) 10 deriving (Eq,Ord,Show,Read)
11 11
12{-# NOINLINE verbosityMap #-} 12{-# NOINLINE verbosityMap #-}
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)
37import Data.Word 37import Data.Word
38import Data.List 38import Data.List
39import System.IO 39import System.IO
40import DPut
40 41
41data TransactionId = TransactionId 42data TransactionId = TransactionId
42 { transactionKey :: Nonce8 -- ^ Used to lookup pending query. 43 { transactionKey :: Nonce8 -- ^ Used to lookup pending query.
@@ -230,16 +231,16 @@ createCookie crypto ni remoteUserKey = do
230 , dhtKey = transportPublic crypto 231 , dhtKey = transportPublic crypto
231 } 232 }
232 edta = encryptSymmetric sym n24 dta 233 edta = encryptSymmetric sym n24 dta
233 hPutStrLn stderr $ "Created cookie with n24 = 0x" ++ show n24 ++ "\n sym=" ++ show sym 234 dput XNetCrypto $ "Created cookie with n24 = 0x" ++ show n24 ++ "\n sym=" ++ show sym
234 return $ Cookie n24 edta 235 return $ Cookie n24 edta
235 236
236cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie 237cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie
237cookieRequestH crypto ni (CookieRequest remoteUserKey) = do 238cookieRequestH crypto ni (CookieRequest remoteUserKey) = do
238 hPutStrLn stderr $ unlines 239 dput XNetCrypto $ unlines
239 [ "CookieRequest! remoteUserKey=" ++ show (key2id remoteUserKey) 240 [ "CookieRequest! remoteUserKey=" ++ show (key2id remoteUserKey)
240 , " sender=" ++ show ni ] 241 , " sender=" ++ show ni ]
241 x <- createCookie crypto ni remoteUserKey 242 x <- createCookie crypto ni remoteUserKey
242 hPutStrLn stderr $ "CookieRequest! responding to " ++ show (key2id remoteUserKey) 243 dput XNetCrypto $ "CookieRequest! responding to " ++ show (key2id remoteUserKey)
243 return x 244 return x
244 245
245lanDiscoveryH :: Client -> NodeInfo -> NodeInfo -> IO (Maybe (Message -> Message)) 246lanDiscoveryH :: Client -> NodeInfo -> NodeInfo -> IO (Maybe (Message -> Message))
@@ -285,9 +286,9 @@ showHex bs = C8.unpack $ Base16.encode $ BA.convert bs
285 286
286ping :: Client -> NodeInfo -> IO Bool 287ping :: Client -> NodeInfo -> IO Bool
287ping client addr = do 288ping client addr = do
288 hPutStrLn stderr $ show addr ++ " <-- ping" 289 dput XPing $ show addr ++ " <-- ping"
289 reply <- QR.sendQuery client (serializer PingType DHTPing unpong) Ping addr 290 reply <- QR.sendQuery client (serializer PingType DHTPing unpong) Ping addr
290 hPutStrLn stderr $ show addr ++ " -pong-> " ++ show reply 291 dput XPing $ show addr ++ " -pong-> " ++ show reply
291 maybe (return False) (\Pong -> return True) $ join reply 292 maybe (return False) (\Pong -> return True) $ join reply
292 293
293 294
@@ -323,10 +324,10 @@ cookieRequest crypto client localUserKey addr = do
323 } 324 }
324 cookieRequest = CookieRequest localUserKey 325 cookieRequest = CookieRequest localUserKey
325 atomically $ saveCookieKey (pendingCookies crypto) sockAddr nid 326 atomically $ saveCookieKey (pendingCookies crypto) sockAddr nid
326 hPutStrLn stderr $ show addr ++ " <-- cookieRequest" 327 dput XNetCrypto $ show addr ++ " <-- cookieRequest"
327 reply <- QR.sendQuery client cookieSerializer cookieRequest addr 328 reply <- QR.sendQuery client cookieSerializer cookieRequest addr
328 atomically $ loseCookieKey (pendingCookies crypto) sockAddr nid 329 atomically $ loseCookieKey (pendingCookies crypto) sockAddr nid
329 hPutStrLn stderr $ show addr ++ " -cookieResponse-> " ++ show reply 330 dput XNetCrypto $ show addr ++ " -cookieResponse-> " ++ show reply
330 return $ join reply 331 return $ join reply
331 332
332unCookie :: DHTMessage t -> Maybe (t Cookie) 333unCookie :: DHTMessage t -> Maybe (t Cookie)