diff options
Diffstat (limited to 'src/Network/BitTorrent')
-rw-r--r-- | src/Network/BitTorrent/MainlineDHT.hs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/Network/BitTorrent/MainlineDHT.hs b/src/Network/BitTorrent/MainlineDHT.hs index 847d820b..626f980f 100644 --- a/src/Network/BitTorrent/MainlineDHT.hs +++ b/src/Network/BitTorrent/MainlineDHT.hs | |||
@@ -87,6 +87,7 @@ import qualified Data.Aeson as JSON | |||
87 | import Text.Read | 87 | import Text.Read |
88 | import System.Global6 | 88 | import System.Global6 |
89 | import Control.TriadCommittee | 89 | import Control.TriadCommittee |
90 | import DPut | ||
90 | 91 | ||
91 | newtype NodeId = NodeId ByteString | 92 | newtype NodeId = NodeId ByteString |
92 | deriving (Eq,Ord,ByteArrayAccess, Bits, Hashable) | 93 | deriving (Eq,Ord,ByteArrayAccess, Bits, Hashable) |
@@ -431,10 +432,10 @@ addVerbosity :: Transport err SockAddr ByteString -> Transport err SockAddr Byte | |||
431 | addVerbosity tr = | 432 | addVerbosity tr = |
432 | tr { awaitMessage = \kont -> awaitMessage tr $ \m -> do | 433 | tr { awaitMessage = \kont -> awaitMessage tr $ \m -> do |
433 | forM_ m $ mapM_ $ \(msg,addr) -> do | 434 | forM_ m $ mapM_ $ \(msg,addr) -> do |
434 | hPutStrLn stderr (showPacket id addr " --> " msg) | 435 | dput XBitTorrent (showPacket id addr " --> " msg) |
435 | kont m | 436 | kont m |
436 | , sendMessage = \addr msg -> do | 437 | , sendMessage = \addr msg -> do |
437 | hPutStrLn stderr (showPacket id addr " <-- " msg) | 438 | dput XBitTorrent (showPacket id addr " <-- " msg) |
438 | sendMessage tr addr msg | 439 | sendMessage tr addr msg |
439 | } | 440 | } |
440 | 441 | ||
@@ -642,18 +643,18 @@ newClient swarms addr = do | |||
642 | fork $ fix $ \again -> do | 643 | fork $ fix $ \again -> do |
643 | myThreadId >>= flip labelThread "addr4" | 644 | myThreadId >>= flip labelThread "addr4" |
644 | (addr, ns) <- atomically $ readTChan addr4 | 645 | (addr, ns) <- atomically $ readTChan addr4 |
645 | hPutStrLn stderr $ "External IPv4: "++show (addr, length ns) | 646 | dput XBitTorrent $ "External IPv4: "++show (addr, length ns) |
646 | forM_ ns $ \n -> do | 647 | forM_ ns $ \n -> do |
647 | hPutStrLn stderr $ "Change IP, ping: "++show n | 648 | dput XBitTorrent $ "Change IP, ping: "++show n |
648 | ping outgoingClient n | 649 | ping outgoingClient n |
649 | -- TODO: trigger bootstrap ipv4 | 650 | -- TODO: trigger bootstrap ipv4 |
650 | again | 651 | again |
651 | fork $ fix $ \again -> do | 652 | fork $ fix $ \again -> do |
652 | myThreadId >>= flip labelThread "addr6" | 653 | myThreadId >>= flip labelThread "addr6" |
653 | (addr,ns) <- atomically $ readTChan addr6 | 654 | (addr,ns) <- atomically $ readTChan addr6 |
654 | hPutStrLn stderr $ "External IPv6: "++show (addr, length ns) | 655 | dput XBitTorrent $ "External IPv6: "++show (addr, length ns) |
655 | forM_ ns $ \n -> do | 656 | forM_ ns $ \n -> do |
656 | hPutStrLn stderr $ "Change IP, ping: "++show n | 657 | dput XBitTorrent $ "Change IP, ping: "++show n |
657 | ping outgoingClient n | 658 | ping outgoingClient n |
658 | -- TODO: trigger bootstrap ipv6 | 659 | -- TODO: trigger bootstrap ipv6 |
659 | again | 660 | again |
@@ -734,7 +735,7 @@ mainlineKademlia client committee refresher | |||
734 | return $ do | 735 | return $ do |
735 | io1 >> io2 | 736 | io1 >> io2 |
736 | {- noisy (timestamp updates are currently reported as transitions to Accepted) | 737 | {- noisy (timestamp updates are currently reported as transitions to Accepted) |
737 | hPutStrLn stderr $ unwords | 738 | dput XBitTorrent $ unwords |
738 | [ show (transitionedTo tr) | 739 | [ show (transitionedTo tr) |
739 | , show (transitioningNode tr) | 740 | , show (transitioningNode tr) |
740 | ] -} | 741 | ] -} |
@@ -753,7 +754,7 @@ transitionCommittee :: TriadCommittee NodeId SockAddr -> RoutingTransition NodeI | |||
753 | transitionCommittee committee (RoutingTransition ni Stranger) = do | 754 | transitionCommittee committee (RoutingTransition ni Stranger) = do |
754 | delVote committee (nodeId ni) | 755 | delVote committee (nodeId ni) |
755 | return $ do | 756 | return $ do |
756 | hPutStrLn stderr $ "delVote "++show (nodeId ni) | 757 | dput XBitTorrent $ "delVote "++show (nodeId ni) |
757 | transitionCommittee committee _ = return $ return () | 758 | transitionCommittee committee _ = return $ return () |
758 | 759 | ||
759 | updateRouting :: MainlineClient -> Routing -> NodeInfo -> Message BValue -> IO () | 760 | updateRouting :: MainlineClient -> Routing -> NodeInfo -> Message BValue -> IO () |
@@ -768,7 +769,7 @@ updateRouting client routing naddr msg = do | |||
768 | case msg of | 769 | case msg of |
769 | R { rspReflectedIP = Just sockaddr } | 770 | R { rspReflectedIP = Just sockaddr } |
770 | -> do | 771 | -> do |
771 | -- hPutStrLn stderr $ "External: "++show (nodeId naddr,sockaddr) | 772 | -- dput XBitTorrent $ "External: "++show (nodeId naddr,sockaddr) |
772 | atomically $ addVote committee (nodeId naddr) sockaddr | 773 | atomically $ addVote committee (nodeId naddr) sockaddr |
773 | _ -> return () | 774 | _ -> return () |
774 | insertNode (mainlineKademlia client committee refresher) naddr | 775 | insertNode (mainlineKademlia client committee refresher) naddr |