diff options
author | joe <joe@jerkface.net> | 2017-07-09 00:50:54 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-07-09 00:50:54 -0400 |
commit | 035e1ffb0a3b7dbed7af5b8e0c180b44f687a672 (patch) | |
tree | 582a3c9c8c564d0781486676dbd359de894dc6fa /examples/dhtd.hs | |
parent | 8fe93b8e1d1d968bdf0b8a35335b060d92a9d7d7 (diff) |
Initialize Tox secret key.
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r-- | examples/dhtd.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 993727b5..d9b02c41 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -69,6 +69,7 @@ import Data.Typeable | |||
69 | import GHC.Generics | 69 | import GHC.Generics |
70 | import Data.Bool | 70 | import Data.Bool |
71 | import System.Random | 71 | import System.Random |
72 | import Network.DatagramServer.Mainline (PacketDestination(..)) | ||
72 | 73 | ||
73 | mkNodeAddr :: SockAddr -> NodeAddr IPv4 | 74 | mkNodeAddr :: SockAddr -> NodeAddr IPv4 |
74 | mkNodeAddr addr = NodeAddr (fromJust $ fromSockAddr addr) | 75 | mkNodeAddr addr = NodeAddr (fromJust $ fromSockAddr addr) |
@@ -462,13 +463,11 @@ clientSession bt tox signalQuit isBt sock n h = do | |||
462 | let (hs,as) = second (dropWhile isSpace) $ break isSpace s | 463 | let (hs,as) = second (dropWhile isSpace) $ break isSpace s |
463 | parse = do ih <- readEither hs | 464 | parse = do ih <- readEither hs |
464 | a <- readEither as | 465 | a <- readEither as |
465 | -- XXX: using 'InfoHash' only because 'NodeId' currently | 466 | return (ih, a) -- :: NodeAddr IPv4) |
466 | -- has no 'Read' instance. | ||
467 | return (ih, a :: NodeAddr IPv4) | ||
468 | case parse of | 467 | case parse of |
469 | Right (ih,a) -> do | 468 | Right (ih,a) -> do |
470 | nodeIdType ih | 469 | nodeIdType ih |
471 | nodeAddrType a | 470 | -- nodeAddrType a |
472 | proxy <- dhtType | 471 | proxy <- dhtType |
473 | let fn = findNodeMessage proxy ih | 472 | let fn = findNodeMessage proxy ih |
474 | ipType fn | 473 | ipType fn |
@@ -484,10 +483,10 @@ clientSession bt tox signalQuit isBt sock n h = do | |||
484 | let (hs,as) = second (dropWhile isSpace) $ break isSpace s | 483 | let (hs,as) = second (dropWhile isSpace) $ break isSpace s |
485 | parse = do ih <- readEither hs | 484 | parse = do ih <- readEither hs |
486 | a <- readEither as | 485 | a <- readEither as |
487 | return (ih :: InfoHash, a :: NodeAddr IPv4) | 486 | return (ih :: InfoHash, a) |
488 | case parse of | 487 | case parse of |
489 | Right (ih,a) -> do | 488 | Right (ih,a) -> do |
490 | result <- try $ queryNode' (a ::NodeAddr IPv4) $ GetPeers ih | 489 | result <- try $ queryNode' a $ GetPeers ih |
491 | let rs = either (pure . ( (,) "error" ) . showQueryFail) reportPeers result | 490 | let rs = either (pure . ( (,) "error" ) . showQueryFail) reportPeers result |
492 | return $ do | 491 | return $ do |
493 | hPutClient h $ showReport rs | 492 | hPutClient h $ showReport rs |
@@ -591,7 +590,7 @@ main = do | |||
591 | () <- takeMVar signalQuit | 590 | () <- takeMVar signalQuit |
592 | quitListening srv | 591 | quitListening srv |
593 | 592 | ||
594 | bootstrap saved_nodes bs | 593 | bootstrap saved_nodes (map (MainlineNode . toSockAddr) bs) |
595 | 594 | ||
596 | b <- isBootstrapped | 595 | b <- isBootstrapped |
597 | tbl <- getTable | 596 | tbl <- getTable |