diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DPut.hs | 2 | ||||
-rw-r--r-- | src/Network/Tox/DHT/Handlers.hs | 15 |
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) | |||
6 | import Data.Maybe | 6 | import Data.Maybe |
7 | import System.IO.Unsafe (unsafePerformIO) | 7 | import System.IO.Unsafe (unsafePerformIO) |
8 | 8 | ||
9 | data DebugTag = XAnnounce | XDHT | XOnion | XNetCrypto | XMisc | 9 | data 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) | |||
37 | import Data.Word | 37 | import Data.Word |
38 | import Data.List | 38 | import Data.List |
39 | import System.IO | 39 | import System.IO |
40 | import DPut | ||
40 | 41 | ||
41 | data TransactionId = TransactionId | 42 | data 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 | ||
236 | cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie | 237 | cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie |
237 | cookieRequestH crypto ni (CookieRequest remoteUserKey) = do | 238 | cookieRequestH 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 | ||
245 | lanDiscoveryH :: Client -> NodeInfo -> NodeInfo -> IO (Maybe (Message -> Message)) | 246 | lanDiscoveryH :: Client -> NodeInfo -> NodeInfo -> IO (Maybe (Message -> Message)) |
@@ -285,9 +286,9 @@ showHex bs = C8.unpack $ Base16.encode $ BA.convert bs | |||
285 | 286 | ||
286 | ping :: Client -> NodeInfo -> IO Bool | 287 | ping :: Client -> NodeInfo -> IO Bool |
287 | ping client addr = do | 288 | ping 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 | ||
332 | unCookie :: DHTMessage t -> Maybe (t Cookie) | 333 | unCookie :: DHTMessage t -> Maybe (t Cookie) |