putWord32be $ fromIntegral (eventToInteger event)
putWord32be 0
putWord32be 0
- putWord32be 20
+ putWord32be 10
putWord16be $ fromIntegral port
put (ScrapeReq _ _ _) = undefined
get = undefined
sendRequest :: UDPTrackerHandle -> ByteString -> IO ()
sendRequest h req = do
n <- sendTo (sock h) req (addr h)
- print $ BC.length req
-- sanity check with n?
return ()
connectResponse tid = do
h <- ask
resp <- liftIO $ recvResponse h
- liftIO $ print resp
-- check if nbytes is at least 16 bytes long
case resp of
(ConnectResp tidr cid) ->
if empty
then return []
else do
- ip <- toIP <$> getByteString 6
+ ip <- toIP <$> getByteString 4
port <- toPort <$> getByteString 2
ipportpairs <- getIPPortPairs
return $ (ip, port) : ipportpairs
t1 <- connectRequest
cid <- connectResponse t1
liftIO $ print "connected: connect id"
- liftIO $ print cid
t2 <- announceRequest cid infohash peerId (fromIntegral up) (fromIntegral down) (fromIntegral (left tstate)) (fromIntegral sport)
- liftIO $ print "announce request"
- liftIO $ print t2
liftIO $ print "waiting for announce response"
stats <- announceResponse t2
liftIO $ print stats