Bint Integer
| Bstr BC.ByteString
| Blist [BVal]
- | Bdict (M.Map BVal BVal)
+ | Bdict InfoDict
deriving (Ord, Eq)
+type InfoDict = M.Map BVal BVal
+
instance Show BVal where
show (Bint i) = show i
show (Bstr s) = "\"" ++ BC.unpack s ++ "\""
}
-handShakeMsg :: M.Map Benc.BVal Benc.BVal -> String -> BC.ByteString
+handShakeMsg :: Benc.InfoDict -> String -> BC.ByteString
handShakeMsg m peer_id = let pstrlen = BC.concat $ BL.toChunks $ Bin.encode (19 :: DI.Int8)
pstr = BC.pack "BitTorrent protocol"
reserved = BC.replicate 8 '\0'
import Data.Char
type Url = String
-type InfoDict = M.Map Benc.BVal Benc.BVal
-- | urlEncodeHash
--
infoHash m = let info = m M.! Benc.Bstr (BC.pack "info")
in (SHA1.hash . BC.pack . Benc.encode) info
-prepareRequest :: InfoDict -> String -> Integer -> String
+prepareRequest :: Benc.InfoDict -> String -> Integer -> String
prepareRequest d peer_id len =
let p = [("info_hash", urlEncodeHash ((B16.encode . infoHash) d)),
("peer_id", HB.urlEncode peer_id),