summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Core/PeerAddr.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Core/PeerAddr.hs')
-rw-r--r--src/Network/BitTorrent/Core/PeerAddr.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Core/PeerAddr.hs b/src/Network/BitTorrent/Core/PeerAddr.hs
index d634716c..e3e09fd6 100644
--- a/src/Network/BitTorrent/Core/PeerAddr.hs
+++ b/src/Network/BitTorrent/Core/PeerAddr.hs
@@ -251,6 +251,13 @@ instance IsString (PeerAddr IPv4) where
251 = PeerAddr Nothing hostAddr portNum 251 = PeerAddr Nothing hostAddr portNum
252 | otherwise = error $ "fromString: unable to parse (PeerAddr IPv4): " ++ str 252 | otherwise = error $ "fromString: unable to parse (PeerAddr IPv4): " ++ str
253 253
254instance Read (PeerAddr IPv4) where
255 readsPrec i = RP.readP_to_S $ do
256 ipv4 <- RP.readS_to_P (readsPrec i)
257 _ <- RP.char ':'
258 port <- toEnum <$> RP.readS_to_P (readsPrec i)
259 return $ PeerAddr Nothing ipv4 port
260
254readsIPv6_port :: String -> [((IPv6, PortNumber), String)] 261readsIPv6_port :: String -> [((IPv6, PortNumber), String)]
255readsIPv6_port = RP.readP_to_S $ do 262readsIPv6_port = RP.readP_to_S $ do
256 ip <- RP.char '[' *> (RP.readS_to_P reads) <* RP.char ']' 263 ip <- RP.char '[' *> (RP.readS_to_P reads) <* RP.char ']'