summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/DHT/Query.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/DHT/Query.hs')
-rw-r--r--src/Network/BitTorrent/DHT/Query.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Network/BitTorrent/DHT/Query.hs b/src/Network/BitTorrent/DHT/Query.hs
index 44083d81..0bec867d 100644
--- a/src/Network/BitTorrent/DHT/Query.hs
+++ b/src/Network/BitTorrent/DHT/Query.hs
@@ -105,7 +105,7 @@ findNodeH = nodeHandler $ \ _ (FindNode nid) -> do
105 NodeFound <$> getClosest nid 105 NodeFound <$> getClosest nid
106 106
107-- | Default 'GetPeers' handler. 107-- | Default 'GetPeers' handler.
108getPeersH :: Address ip => NodeHandler ip 108getPeersH :: Ord ip => Address ip => NodeHandler ip
109getPeersH = nodeHandler $ \ naddr (GetPeers ih) -> do 109getPeersH = nodeHandler $ \ naddr (GetPeers ih) -> do
110 ps <- getPeerList ih 110 ps <- getPeerList ih
111 tok <- grantToken naddr 111 tok <- grantToken naddr
@@ -113,19 +113,19 @@ getPeersH = nodeHandler $ \ naddr (GetPeers ih) -> do
113 return $ GotPeers ps tok 113 return $ GotPeers ps tok
114 114
115-- | Default 'Announce' handler. 115-- | Default 'Announce' handler.
116announceH :: Address ip => NodeHandler ip 116announceH :: Ord ip => Address ip => NodeHandler ip
117announceH = nodeHandler $ \ naddr @ NodeAddr {..} (Announce {..}) -> do 117announceH = nodeHandler $ \ naddr @ NodeAddr {..} (Announce {..}) -> do
118 valid <- checkToken naddr sessionToken 118 valid <- checkToken naddr sessionToken
119 unless valid $ do 119 unless valid $ do
120 throwIO $ InvalidParameter "token" 120 throwIO $ InvalidParameter "token"
121 121
122 let annPort = if impliedPort then nodePort else port 122 let annPort = if impliedPort then nodePort else port
123 let peerAddr = PeerAddr Nothing nodeHost annPort 123 peerAddr = PeerAddr Nothing nodeHost annPort
124 insertPeer topic peerAddr 124 insertPeer topic announcedName peerAddr
125 return Announced 125 return Announced
126 126
127-- | Includes all default query handlers. 127-- | Includes all default query handlers.
128defaultHandlers :: Address ip => [NodeHandler ip] 128defaultHandlers :: Ord ip => Address ip => [NodeHandler ip]
129defaultHandlers = [pingH, findNodeH, getPeersH, announceH] 129defaultHandlers = [pingH, findNodeH, getPeersH, announceH]
130 130
131{----------------------------------------------------------------------- 131{-----------------------------------------------------------------------
@@ -168,7 +168,7 @@ announceQ ih p NodeInfo {..} = do
168 | False -> undefined -- TODO check if we can announce 168 | False -> undefined -- TODO check if we can announce
169 | otherwise -> return (Left ns) 169 | otherwise -> return (Left ns)
170 Right _ -> do -- TODO *probably* add to peer cache 170 Right _ -> do -- TODO *probably* add to peer cache
171 Announced <- Announce False ih p grantedToken <@> nodeAddr 171 Announced <- Announce False ih Nothing p grantedToken <@> nodeAddr
172 return (Right [nodeAddr]) 172 return (Right [nodeAddr])
173 173
174{----------------------------------------------------------------------- 174{-----------------------------------------------------------------------