summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Core/PeerAddr.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-03-20 03:19:14 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-03-20 03:19:14 +0400
commit95f519df298c98d966c6408cac33cdd57b8e8a03 (patch)
treee6b0fb3ba6dafd6771cfc5084fcb3f7b1a7e26da /src/Network/BitTorrent/Core/PeerAddr.hs
parent17949276fbd32ab75bcb18016210b6947df54ed1 (diff)
Add instance ToJSON TrackerEntry
Diffstat (limited to 'src/Network/BitTorrent/Core/PeerAddr.hs')
-rw-r--r--src/Network/BitTorrent/Core/PeerAddr.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Core/PeerAddr.hs b/src/Network/BitTorrent/Core/PeerAddr.hs
index b62cb945..adf64c7f 100644
--- a/src/Network/BitTorrent/Core/PeerAddr.hs
+++ b/src/Network/BitTorrent/Core/PeerAddr.hs
@@ -34,6 +34,7 @@ module Network.BitTorrent.Core.PeerAddr
34import Control.Applicative 34import Control.Applicative
35import Control.Monad 35import Control.Monad
36import Data.Aeson (ToJSON, FromJSON) 36import Data.Aeson (ToJSON, FromJSON)
37import Data.Aeson.TH
37import Data.BEncode as BS 38import Data.BEncode as BS
38import Data.BEncode.BDict (BKey) 39import Data.BEncode.BDict (BKey)
39import Data.ByteString.Char8 as BS8 40import Data.ByteString.Char8 as BS8
@@ -57,6 +58,7 @@ import Text.Read (readMaybe)
57import qualified Text.ParserCombinators.ReadP as RP 58import qualified Text.ParserCombinators.ReadP as RP
58 59
59import Data.Torrent.InfoHash 60import Data.Torrent.InfoHash
61import Data.Torrent.JSON
60import Network.BitTorrent.Core.PeerId 62import Network.BitTorrent.Core.PeerId
61 63
62 64
@@ -206,6 +208,8 @@ data PeerAddr a = PeerAddr
206 , peerPort :: {-# UNPACK #-} !PortNumber 208 , peerPort :: {-# UNPACK #-} !PortNumber
207 } deriving (Show, Eq, Ord, Typeable, Functor) 209 } deriving (Show, Eq, Ord, Typeable, Functor)
208 210
211$(deriveJSON omitRecordPrefix ''PeerAddr)
212
209peer_ip_key, peer_id_key, peer_port_key :: BKey 213peer_ip_key, peer_id_key, peer_port_key :: BKey
210peer_ip_key = "ip" 214peer_ip_key = "ip"
211peer_id_key = "peer id" 215peer_id_key = "peer id"