Node.js的BT下载
近来想用Node.js做一个BT下载的程序,于是研究了一下BT下载相关的知识。
一、BT文件解析用了那么久的bt下载,都知道下载前,都是先解析种子文件(.torrent)的吧。种子文件使用的是BEncode(B编码)保存数据,这种编码有四种数据结构:
1.string(字符串)string的编码为 <string length>:<string>
例: 7:example, 表示字符串 'example'2.integer(整数)integer的编码为 i<integer>e
例: i123456e, 表示整数 1234563.list(列表)list的编码为 l<BEncode>e
例: l6:stringi123ee, 表示数组 ['string', 123]4.dictionary(字典)dictionary的编码为 d<BEcode的string><BEncode>e,即d<key><value>e,key为BEcode的string,value为BEncode
例:d3:key5:value4:testi123ee, 表示{key:'value', test:12...阅读全文
一、BT文件解析用了那么久的bt下载,都知道下载前,都是先解析种子文件(.torrent)的吧。种子文件使用的是BEncode(B编码)保存数据,这种编码有四种数据结构:
1.string(字符串)string的编码为 <string length>:<string>
例: 7:example, 表示字符串 'example'2.integer(整数)integer的编码为 i<integer>e
例: i123456e, 表示整数 1234563.list(列表)list的编码为 l<BEncode>e
例: l6:stringi123ee, 表示数组 ['string', 123]4.dictionary(字典)dictionary的编码为 d<BEcode的string><BEncode>e,即d<key><value>e,key为BEcode的string,value为BEncode
例:d3:key5:value4:testi123ee, 表示{key:'value', test:12...阅读全文