summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/BitTorrent/DHT/Query.hs6
1 files changed, 5 insertions, 1 deletions
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
72 case fromSockAddr sockAddr of 72 case fromSockAddr sockAddr of
73 Nothing -> throwIO BadAddress 73 Nothing -> throwIO BadAddress
74 Just naddr -> do 74 Just naddr -> do
75 insertNode (NodeInfo remoteId naddr) 75 insertNode (NodeInfo remoteId naddr) -- TODO need to block. why?
76 Response <$> asks thisNodeId <*> action naddr q 76 Response <$> asks thisNodeId <*> action naddr q
77 77
78-- | Default 'Ping' handler.
78pingH :: Address ip => NodeHandler ip 79pingH :: Address ip => NodeHandler ip
79pingH = nodeHandler $ \ _ Ping -> do 80pingH = nodeHandler $ \ _ Ping -> do
80 return Ping 81 return Ping
81 82
83-- | Default 'FindNode' handler.
82findNodeH :: Address ip => NodeHandler ip 84findNodeH :: Address ip => NodeHandler ip
83findNodeH = nodeHandler $ \ _ (FindNode nid) -> do 85findNodeH = nodeHandler $ \ _ (FindNode nid) -> do
84 NodeFound <$> getClosest nid 86 NodeFound <$> getClosest nid
85 87
88-- | Default 'GetPeers' handler.
86getPeersH :: Address ip => NodeHandler ip 89getPeersH :: Address ip => NodeHandler ip
87getPeersH = nodeHandler $ \ naddr (GetPeers ih) -> do 90getPeersH = nodeHandler $ \ naddr (GetPeers ih) -> do
88 GotPeers <$> getPeerList ih <*> grantToken naddr 91 GotPeers <$> getPeerList ih <*> grantToken naddr
89 92
93-- | Default 'Announce' handler.
90announceH :: Address ip => NodeHandler ip 94announceH :: Address ip => NodeHandler ip
91announceH = nodeHandler $ \ naddr @ NodeAddr {..} (Announce {..}) -> do 95announceH = nodeHandler $ \ naddr @ NodeAddr {..} (Announce {..}) -> do
92 valid <- checkToken naddr sessionToken 96 valid <- checkToken naddr sessionToken