diff options
author | joe <joe@jerkface.net> | 2017-01-22 18:11:58 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-01-22 18:11:58 -0500 |
commit | e7c2f98454a4e52b7e7b62b49f91b59cfc77a91b (patch) | |
tree | 40ae4586e590f88c56a4d4d4e8a8d669f9b23944 /src/Network/BitTorrent/DHT/Message.hs | |
parent | 8cf4de73d77197032fd8ebfc4e4f3a00b287e0e7 (diff) |
PSQ instead of list for peer set. Also: dhtd "swarms" command.
Diffstat (limited to 'src/Network/BitTorrent/DHT/Message.hs')
-rw-r--r-- | src/Network/BitTorrent/DHT/Message.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/DHT/Message.hs b/src/Network/BitTorrent/DHT/Message.hs index 9d66741f..d31cce82 100644 --- a/src/Network/BitTorrent/DHT/Message.hs +++ b/src/Network/BitTorrent/DHT/Message.hs | |||
@@ -86,6 +86,7 @@ module Network.BitTorrent.DHT.Message | |||
86 | import Control.Applicative | 86 | import Control.Applicative |
87 | import Data.BEncode as BE | 87 | import Data.BEncode as BE |
88 | import Data.BEncode.BDict | 88 | import Data.BEncode.BDict |
89 | import Data.ByteString (ByteString) | ||
89 | import Data.List as L | 90 | import Data.List as L |
90 | import Data.Monoid | 91 | import Data.Monoid |
91 | import Data.Serialize as S | 92 | import Data.Serialize as S |
@@ -251,6 +252,9 @@ peers_key = "values" | |||
251 | token_key :: BKey | 252 | token_key :: BKey |
252 | token_key = "token" | 253 | token_key = "token" |
253 | 254 | ||
255 | name_key :: BKey | ||
256 | name_key = "name" | ||
257 | |||
254 | instance (Typeable ip, Serialize ip) => BEncode (GotPeers ip) where | 258 | instance (Typeable ip, Serialize ip) => BEncode (GotPeers ip) where |
255 | toBEncode GotPeers {..} = toDict $ | 259 | toBEncode GotPeers {..} = toDict $ |
256 | case peers of | 260 | case peers of |
@@ -295,11 +299,17 @@ data Announce = Announce | |||
295 | -- | infohash of the torrent; | 299 | -- | infohash of the torrent; |
296 | , topic :: InfoHash | 300 | , topic :: InfoHash |
297 | 301 | ||
302 | -- | some clients announce the friendly name of the torrent here. | ||
303 | , announcedName :: Maybe ByteString | ||
304 | |||
298 | -- | the port /this/ peer is listening; | 305 | -- | the port /this/ peer is listening; |
299 | , port :: PortNumber | 306 | , port :: PortNumber |
300 | 307 | ||
308 | -- TODO: optional boolean "seed" key | ||
309 | |||
301 | -- | received in response to a previous get_peers query. | 310 | -- | received in response to a previous get_peers query. |
302 | , sessionToken :: Token | 311 | , sessionToken :: Token |
312 | |||
303 | } deriving (Show, Eq, Typeable) | 313 | } deriving (Show, Eq, Typeable) |
304 | 314 | ||
305 | port_key :: BKey | 315 | port_key :: BKey |
@@ -312,6 +322,7 @@ instance BEncode Announce where | |||
312 | toBEncode Announce {..} = toDict $ | 322 | toBEncode Announce {..} = toDict $ |
313 | implied_port_key .=? flagField impliedPort | 323 | implied_port_key .=? flagField impliedPort |
314 | .: info_hash_key .=! topic | 324 | .: info_hash_key .=! topic |
325 | .: name_key .=? announcedName | ||
315 | .: port_key .=! port | 326 | .: port_key .=! port |
316 | .: token_key .=! sessionToken | 327 | .: token_key .=! sessionToken |
317 | .: endDict | 328 | .: endDict |
@@ -321,6 +332,7 @@ instance BEncode Announce where | |||
321 | fromBEncode = fromDict $ do | 332 | fromBEncode = fromDict $ do |
322 | Announce <$> (boolField <$> optional (field (req implied_port_key))) | 333 | Announce <$> (boolField <$> optional (field (req implied_port_key))) |
323 | <*>! info_hash_key | 334 | <*>! info_hash_key |
335 | <*>? name_key | ||
324 | <*>! port_key | 336 | <*>! port_key |
325 | <*>! token_key | 337 | <*>! token_key |
326 | where | 338 | where |