From 60f38ddcf742883f4028c659e2abdb245e8e473a Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Wed, 19 Feb 2014 23:34:58 +0400 Subject: Link query handlers to the underlying messages in documentation --- src/Network/BitTorrent/DHT/Query.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Network/BitTorrent/DHT/Query.hs') diff --git a/src/Network/BitTorrent/DHT/Query.hs b/src/Network/BitTorrent/DHT/Query.hs index 9c52220e..4ba88b46 100644 --- a/src/Network/BitTorrent/DHT/Query.hs +++ b/src/Network/BitTorrent/DHT/Query.hs @@ -72,21 +72,25 @@ nodeHandler action = handler $ \ sockAddr (Query remoteId q) -> do case fromSockAddr sockAddr of Nothing -> throwIO BadAddress Just naddr -> do - insertNode (NodeInfo remoteId naddr) + insertNode (NodeInfo remoteId naddr) -- TODO need to block. why? Response <$> asks thisNodeId <*> action naddr q +-- | Default 'Ping' handler. pingH :: Address ip => NodeHandler ip pingH = nodeHandler $ \ _ Ping -> do return Ping +-- | Default 'FindNode' handler. findNodeH :: Address ip => NodeHandler ip findNodeH = nodeHandler $ \ _ (FindNode nid) -> do NodeFound <$> getClosest nid +-- | Default 'GetPeers' handler. getPeersH :: Address ip => NodeHandler ip getPeersH = nodeHandler $ \ naddr (GetPeers ih) -> do GotPeers <$> getPeerList ih <*> grantToken naddr +-- | Default 'Announce' handler. announceH :: Address ip => NodeHandler ip announceH = nodeHandler $ \ naddr @ NodeAddr {..} (Announce {..}) -> do valid <- checkToken naddr sessionToken -- cgit v1.2.3