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/DHT | |
parent | f045f7e473b534cbe4dff70420e4cc0184465e54 (diff) |
Quieter output and some bug fixes.
Diffstat (limited to 'src/Network/Tox/DHT')
-rw-r--r-- | src/Network/Tox/DHT/Handlers.hs | 10 |
1 files changed, 9 insertions, 1 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 |