putWord32be 0
putWord32be 10
putWord16be $ fromIntegral port
- put (ScrapeReq _ _ _) = undefined
+ put ScrapeReq {} = undefined
get = undefined
instance Binary UDPResponse where
ip <- toIP <$> getByteString 4
port <- toPort <$> getByteString 2
ipportpairs <- getIPPortPairs
- return $ (Peer ip port) : ipportpairs
+ return $ Peer ip port : ipportpairs
startSession :: String -> Port -> IO UDPTrackerHandle
startSession host port = do
let (SockAddrInet p ip) = addrAddress $ head addrinfos
putStrLn "connected to tracker"
return UDPTrackerHandle { sock = s
- , addr = (SockAddrInet (fromIntegral port) ip) }
+ , addr = SockAddrInet (fromIntegral port) ip }
closeSession :: UDPTrackerHandle -> IO ()
closeSession (UDPTrackerHandle s _) = close s
t1 <- connectRequest
cid <- connectResponse t1
t2 <- announceRequest cid infohash peerId (fromIntegral up) (fromIntegral down) (fromIntegral (left tstate)) (fromIntegral sport)
- stats <- announceResponse t2
- return stats
+ announceResponse t2