diff options
author | joe <joe@jerkface.net> | 2017-11-04 22:21:24 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-11-04 22:21:24 -0400 |
commit | 8903c7e0b9eea11dbf229747e7f9729bfe5d2f7b (patch) | |
tree | a15d464c97bbad2a9f256f5fb52c8375b11ca9d3 /src/Network/Tox | |
parent | f045f7e473b534cbe4dff70420e4cc0184465e54 (diff) |
Quieter output and some bug fixes.
Diffstat (limited to 'src/Network/Tox')
-rw-r--r-- | src/Network/Tox/DHT/Handlers.hs | 10 | ||||
-rw-r--r-- | src/Network/Tox/Onion/Transport.hs | 6 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/Network/Tox/DHT/Handlers.hs b/src/Network/Tox/DHT/Handlers.hs index 89f3d442..fc28e2d2 100644 --- a/src/Network/Tox/DHT/Handlers.hs +++ b/src/Network/Tox/DHT/Handlers.hs | |||
@@ -383,12 +383,20 @@ isCookieRequest _ _ = Left "Bad cookie request" | |||
383 | mkCookie :: TransactionId -> NodeInfo -> NodeInfo -> Cookie -> DHTMessage ((,) Nonce8) | 383 | mkCookie :: TransactionId -> NodeInfo -> NodeInfo -> Cookie -> DHTMessage ((,) Nonce8) |
384 | mkCookie (TransactionId n8 n24) src dst cookie = DHTCookie n24 (n8,cookie) | 384 | mkCookie (TransactionId n8 n24) src dst cookie = DHTCookie n24 (n8,cookie) |
385 | 385 | ||
386 | isDHTRequest :: (f DHTRequest -> DHTRequest) -> DHTMessage f -> Either String DHTRequest | ||
387 | isDHTRequest unpack (DHTDHTRequest pubkey a) = Right $ unpack $ asymmData a | ||
388 | isDHTRequest _ _ = Left "Bad dht relay request" | ||
389 | |||
390 | dhtRequestH :: NodeInfo -> DHTRequest -> IO () | ||
391 | dhtRequestH ni req = do | ||
392 | hPutStrLn stderr $ "Unhandled DHT Request: " ++ show req | ||
386 | 393 | ||
387 | handlers :: TransportCrypto -> Routing -> PacketKind -> Maybe Handler | 394 | handlers :: TransportCrypto -> Routing -> PacketKind -> Maybe Handler |
388 | handlers _ routing PingType = Just $ MethodHandler (isPing snd) mkPong $ pingH | 395 | handlers _ routing PingType = Just $ MethodHandler (isPing snd) mkPong $ pingH |
389 | handlers _ routing GetNodesType = Just $ MethodHandler (isGetNodes snd) mkSendNodes $ getNodesH routing | 396 | handlers _ routing GetNodesType = Just $ MethodHandler (isGetNodes snd) mkSendNodes $ getNodesH routing |
390 | handlers crypto _ CookieRequestType = Just $ MethodHandler (isCookieRequest snd) mkCookie $ cookieRequestH crypto | 397 | handlers crypto _ CookieRequestType = Just $ MethodHandler (isCookieRequest snd) mkCookie $ cookieRequestH crypto |
391 | handlers _ _ _ = error "TODO handlers" | 398 | handlers _ _ DHTRequestType = Just $ NoReply (isDHTRequest snd) $ dhtRequestH |
399 | handlers _ _ typ = error $ "TODO DHT handlers " ++ show typ | ||
392 | 400 | ||
393 | nodeSearch :: Client -> Search NodeId (IP,PortNumber) () NodeInfo NodeInfo | 401 | nodeSearch :: Client -> Search NodeId (IP,PortNumber) () NodeInfo NodeInfo |
394 | nodeSearch client = Search | 402 | nodeSearch client = Search |
diff --git a/src/Network/Tox/Onion/Transport.hs b/src/Network/Tox/Onion/Transport.hs index 39ea8c46..5b7aad0b 100644 --- a/src/Network/Tox/Onion/Transport.hs +++ b/src/Network/Tox/Onion/Transport.hs | |||
@@ -247,8 +247,8 @@ encodeOnionAddr getRoute (msg,OnionDestination _ ni (Just rid)) = do | |||
247 | , nodeAddr $ routeNodeA route) | 247 | , nodeAddr $ routeNodeA route) |
248 | mapM' f x = do | 248 | mapM' f x = do |
249 | let _ = x :: Maybe OnionRoute | 249 | let _ = x :: Maybe OnionRoute |
250 | hPutStrLn stderr $ "ONION encode sending to " ++ show ni | 250 | -- hPutStrLn stderr $ "ONION encode sending to " ++ show ni |
251 | hPutStrLn stderr $ "ONION encode getRoute -> " ++ show (fmap (\y -> map ($ y) [routeNodeA,routeNodeB,routeNodeC]) x) | 251 | -- hPutStrLn stderr $ "ONION encode getRoute -> " ++ show (fmap (\y -> map ($ y) [routeNodeA,routeNodeB,routeNodeC]) x) |
252 | mapM f x -- ONION encode getRoute -> Nothing | 252 | mapM f x -- ONION encode getRoute -> Nothing |
253 | getRoute ni rid >>= mapM' go | 253 | getRoute ni rid >>= mapM' go |
254 | 254 | ||
@@ -846,7 +846,7 @@ parseDataToRoute crypto (OnionToRouteResponse dta, od) = do | |||
846 | (Left (dataFromKey dtr, dataToRoute dtr)) | 846 | (Left (dataFromKey dtr, dataToRoute dtr)) |
847 | return (pk,dtr,omsg) | 847 | return (pk,dtr,omsg) |
848 | 848 | ||
849 | eInner = foldr1 (<|>) eInners | 849 | eInner = foldr (<|>) (Left "no user key") eInners |
850 | 850 | ||
851 | e = do | 851 | e = do |
852 | (pk,dtr,omsg) <- eInner | 852 | (pk,dtr,omsg) <- eInner |