⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dht protocol.mht

📁 关于BT的协议文档
💻 MHT
📖 第 1 页 / 共 2 页
字号:
<P>Responses, or KRPC message dictionaries with a "y" value of "r", =
contain one=20
additional key "r". The value of "r" is a dictionary containing named =
return=20
values. Response messages are sent upon successful completion of a =
query.</P><A=20
name=3DErrors></A>
<H4>Errors</H4>
<P>Errors, or KRPC message dictionaries with a "y" value of "e", contain =
one=20
additional key "e". The value of "e" is a list. The first element is an =
integer=20
representing the error code. The second element is a string containing =
the error=20
message. Errors are sent when a query cannot be fulfilled. The following =
table=20
describes the possible error codes:</P>
<TABLE>
  <TBODY>
  <TR>
    <TD class=3Dshade>201</TD>
    <TD class=3Dshade>Generic Error</TD></TR>
  <TR>
    <TD>202</TD>
    <TD>Server Error</TD></TR>
  <TR>
    <TD class=3Dshade>203</TD>
    <TD class=3Dshade>Protocol Error, such as a malformed =
packet,<BR>invalid=20
      arguments, or bad token</TD></TR>
  <TR>
    <TD>204</TD>
    <TD>Method Unknown</TD></TR></TBODY></TABLE><A =
name=3DExample_Error_Packets></A>
<H5>Example Error Packets</H5>
<P><CODE>generic error =3D {'t':0, 'y':'e', 'e':[201, "A Generic Error =
Ocurred"]}=20
bencoded =3D d1:eli201e23:A Generic Error =
Ocurrede1:ti0e1:y1:ee</CODE></P><A=20
name=3DDHT_Queries></A>
<H3>DHT Queries</H3>
<P>All queries have an "id" key and value containing the node ID of the =
querying=20
node. All responses have an "id" key and value containing the node ID of =
the=20
responding node.</P><A name=3Dping></A>
<H4>ping</H4>
<P>The most basic query is a ping. "q" =3D "ping" A ping query has a =
single=20
argument, "id" the value is a 20-byte string containing the senders node =
ID in=20
network byte order. The appropriate response to a ping has a single key =
"id"=20
containing the node ID of the responding node.</P>
<P><CODE>arguments: {"id"&nbsp;: "&lt;querying nodes id&gt;"} response:=20
{"id"&nbsp;: "&lt;queried nodes id&gt;"}</CODE></P><A =
name=3Dexample_packets></A>
<H5>Example Packets</H5>
<P><CODE>ping Query =3D {"t":"0", "y":"q", "q":"ping",=20
"a":{"id":"abcdefghij0123456789"}} bencoded =3D=20
d1:ad2:id20:abcdefghij0123456789e1:q4:ping1:t1:01:y1:qe</CODE></P>
<P><CODE>Response =3D {"t":"0", "y":"r", "r": =
{"id":"mnopqrstuvwxyz123456"}}=20
bencoded =3D d1:rd2:id20:mnopqrstuvwxyz123456e1:t1:01:y1:re</CODE></P><A =

name=3Dfind_node></A>
<H4>find_node</H4>
<P>Find node is used to find the contact information for a node given =
its ID.=20
"q" =3D=3D "find_node" A find_node query has two arguments, "id" =
containing the node=20
ID of the querying node, and "target" containing the ID of the node =
sought by=20
the queryer. When a node receives a find_node query, it should respond =
with a=20
key "nodes" and value of a string containing the compact node info for =
the=20
target node or the K (8) closest good nodes in its own routing =
table.</P>
<P><CODE>arguments: {"id"&nbsp;: "&lt;querying nodes id&gt;", =
"target"&nbsp;:=20
"&lt;id of target node&gt;"} response: {"id"&nbsp;: "&lt;queried nodes =
id&gt;",=20
"nodes"&nbsp;: "&lt;compact node info&gt;"}</CODE></P><A=20
name=3Dexample_packets_2></A>
<H5>Example Packets</H5>
<P><CODE>find_node Query =3D {'t':0, 'y':'q', 'q':'find_node', 'a':=20
{'id':'abcdefghij0123456789', 'target':'mnopqrstuvwxyz123456'}} bencoded =
=3D=20
d1:ad2:id20:abcdefghij01234567896:target20:mnopqrstuvwxyz123456e1:q9:find=
_node1:ti0e1:y1:qe</CODE></P>
<P><CODE>Response =3D {'t':0, 'y':'r', 'r': =
{'id':'0123456789abcdefghij', 'nodes':=20
'def456...'}} bencoded =3D=20
d1:rd2:id20:0123456789abcdefghij5:nodes9:def456...e1:ti0e1:y1:re</CODE></=
P><A=20
name=3Dget_peers></A>
<H4>get_peers</H4>
<P>Get peers associated with a torrent infohash. "q" =3D "get_peers" A =
get_peers=20
query has two arguments, "id" containing the node ID of the querying =
node, and=20
"info_hash" containing the infohash of the torrent. If the queried node =
has=20
peers for the infohash, they are returned in a key "values" as a list =
with a=20
single string containing "compact" format peer information concatenated=20
together. If the queried node has no peers for the infohash, a key =
"nodes" is=20
returned containing the K nodes in the queried nodes routing table =
closest to=20
the infohash supplied in the query. In either case a "token" key is also =

included in the return value. The token value is a required argument for =
a=20
future announce_peer query.</P>
<P><CODE>arguments: {"id"&nbsp;: "&lt;querying nodes id&gt;", =
"info_hash"&nbsp;:=20
"&lt;20-byte infohash of target torrent&gt;"} response: {"id"&nbsp;:=20
"&lt;queried nodes id&gt;", "values"&nbsp;: ["&lt;compact peer info=20
string&gt;"]} or: {"id"&nbsp;: "&lt;queried nodes id&gt;", =
"nodes"&nbsp;:=20
"&lt;compact node info&gt;"}</CODE></P><A name=3Dexample_packets_3></A>
<H5>Example Packets</H5>
<P><CODE>get_peers Query =3D {'t':0, 'y':'q', 'q':'get_peers', 'a':=20
{'id':'abcdefghij0123456789', 'info_hash':'mnopqrstuvwxyz123456'}} =
bencoded =3D=20
d1:ad2:id20:abcdefghij01234567899:info_hash20:mnopqrstuvwxyz123456e1:q9:g=
et_peers1:ti0e1:y1:qe</CODE></P>
<P><CODE>Response with peers =3D {'t':0, 'y':'r', 'r':=20
{'id':'abcdefghij0123456789', 'token':'aoeusnth', 'values':=20
['axje.uidhtnmbrl']}} bencoded =3D=20
d1:rd2:id20:abcdefghij01234567895:token8:aoeusnth6:valuesl15:axje.uidhtnm=
brlee1:ti0e1:y1:re</CODE></P>
<P><CODE>Response with closest nodes =3D {'t':0, 'y':'r', 'r':=20
{'id':'abcdefghij0123456789', 'token':'aoeusnth', 'nodes': 'def456...'}} =

bencoded =3D=20
d1:rd2:id20:abcdefghij01234567895:nodes9:def456...5:token8:aoeusnthe1:ti0=
e1:y1:re</CODE></P><A=20
name=3Dannounce_peer></A>
<H4>announce_peer</H4>
<P>Announce that the peer controlling the querying node is downloading =
the a=20
torrent on a port. announce_peer has four arguments: "id" containing the =
node ID=20
of the querying node, "info_hash" containing the infohash of the =
torrent, "port"=20
containing the port as an integer, and the "token" received in response =
to a=20
previous get_peers query. The queried node must verify that the token =
was=20
previously sent to the same IP address as the querying node. Then the =
queried=20
node should store the IP address of the querying node and the supplied =
port=20
number under the infohash in its store of peer contact information.</P>
<P><CODE>arguments: {"id"&nbsp;: "&lt;querying nodes id&gt;", =
"info_hash"&nbsp;:=20
"&lt;20-byte infohash of target torrent&gt;", "port"&nbsp;: &lt;port =
number&gt;,=20
"token"&nbsp;: "&lt;opaque token&gt;"} response: {"id"&nbsp;: =
"&lt;queried nodes=20
id&gt;"}</CODE></P><A name=3Dexample_packets_4></A>
<H5>Example Packets</H5>
<P><CODE>announce_peers Query =3D {'t':0, 'y':'q', 'q':'announce_peers', =
'a':=20
{'id':'abcdefghij0123456789', 'info_hash':'mnopqrstuvwxyz123456', =
'port'&nbsp;:=20
6881, 'token'&nbsp;: 'aoeusnth'}} bencoded =3D=20
d1:ad2:id20:abcdefghij01234567899:info_hash20:<BR>mnopqrstuvwxyz1234564:p=
orti6881e5:token8:aoeusnthe1:q14:announce_peers1:ti0e1:y1:qe</CODE></P>
<P><CODE>Response =3D {"t":"0", "y":"r", "r": =
{"id":"mnopqrstuvwxyz123456"}}=20
bencoded =3D d1:rd2:id20:mnopqrstuvwxyz123456e1:t1:01:y1:re</CODE></P><A =

name=3DFootnotes></A>
<H3>Footnotes</H3>
<OL>
  <LI><A class=3D"external text"=20
  title=3Dhttp://www.cs.rice.edu/Conferences/IPTPS02/109.pdf=20
  href=3D"http://www.cs.rice.edu/Conferences/IPTPS02/109.pdf"=20
  rel=3Dnofollow>"Kademlia: A Peer-to-peer Information System Based on =
the XOR=20
  Metric"</A>,<BR>Petar Maymounkov and David Mazieres,=20
  <LI>Use SHA1 and plenty of entropy to ensure a unique ID =
</LI></OL></DIV><!-- ### End Content ### --></DIV></DIV>
<DIV id=3Dfooter>
<HR>

<P>Copyright =C2=A9 2006 BitTorrent.org</P></DIV></SPAN></BODY></HTML>

------=_NextPart_000_0000_01C7859D.3C5B8920
Content-Type: text/css;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.bittorrent.org/css/screen.css

BODY {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: =
0px; FONT: 10px/1.5em "Trebuchet MS",sans-serif; COLOR: #333; =
PADDING-TOP: 0px; BACKGROUND-COLOR: #666; TEXT-ALIGN: center
}
#upper {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: url(../img/bg.gif) =
#fff repeat-x 0px 0px; PADDING-BOTTOM: 60px; MARGIN: 0px; PADDING-TOP: =
60px
}
#wrap {
	MARGIN: 0px auto; WIDTH: 700px; TEXT-ALIGN: left
}
#header {
	MARGIN: 0px; WIDTH: 100%; BORDER-BOTTOM: #eee 2px solid
}
#nav {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0.5em; MARGIN: =
0px 0px 40px; PADDING-TOP: 0.5em; TEXT-ALIGN: right
}
#nav UL {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: =
0px; PADDING-TOP: 0px; LIST-STYLE-TYPE: none
}
#nav LI {
	PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FONT-WEIGHT: =
bold; FONT-SIZE: 1.5em; PADDING-BOTTOM: 0px; MARGIN-LEFT: 1em; =
PADDING-TOP: 0px
}
#nav LI SPAN {
	COLOR: #f60
}
#home-l UL {
	PADDING-RIGHT: 0px; PADDING-LEFT: 2px; PADDING-BOTTOM: 10px; MARGIN: =
0px 0px 1.5em; PADDING-TOP: 0px
}
#home-c UL {
	PADDING-RIGHT: 0px; PADDING-LEFT: 2px; PADDING-BOTTOM: 10px; MARGIN: =
0px 0px 1.5em; PADDING-TOP: 0px
}
#home-r UL {
	PADDING-RIGHT: 0px; PADDING-LEFT: 2px; PADDING-BOTTOM: 10px; MARGIN: =
0px 0px 1.5em; PADDING-TOP: 0px
}
#home-l LI {
	PADDING-RIGHT: 0px; PADDING-LEFT: 25px; FONT-SIZE: 1.5em; BACKGROUND: =
url(../img/li.gif) no-repeat 0px 0px; PADDING-BOTTOM: 0px; MARGIN: 1em =
0px; LINE-HEIGHT: 1.2em; PADDING-TOP: 0px; LIST-STYLE-TYPE: none
}
#home-c LI {
	PADDING-RIGHT: 0px; PADDING-LEFT: 25px; FONT-SIZE: 1.5em; BACKGROUND: =
url(../img/li.gif) no-repeat 0px 0px; PADDING-BOTTOM: 0px; MARGIN: 1em =
0px; LINE-HEIGHT: 1.2em; PADDING-TOP: 0px; LIST-STYLE-TYPE: none
}
#home-r LI {
	PADDING-RIGHT: 0px; PADDING-LEFT: 25px; FONT-SIZE: 1.5em; BACKGROUND: =
url(../img/li.gif) no-repeat 0px 0px; PADDING-BOTTOM: 0px; MARGIN: 1em =
0px; LINE-HEIGHT: 1.2em; PADDING-TOP: 0px; LIST-STYLE-TYPE: none
}
#second LI {
	FONT-SIZE: 10pt; MARGIN: 0.4em 0px; LINE-HEIGHT: 12pt
}
#second DT {
	FONT-SIZE: 10pt; MARGIN: 0.4em 0px; LINE-HEIGHT: 12pt
}
#second DD {
	FONT-SIZE: 1.2em; MARGIN-BOTTOM: 7px; LINE-HEIGHT: 1.5em
}
#intro {
	PADDING-RIGHT: 3em; PADDING-LEFT: 3em; FONT-SIZE: 2.5em; =
PADDING-BOTTOM: 0px; MARGIN: 0px 0px 2.5em; COLOR: #000; LINE-HEIGHT: =
1.2em; PADDING-TOP: 0px
}
#footer {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: url(../img/fbg.gif) =
repeat-x 0px 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; =
HEIGHT: 60px
}
#home-l {
	FLOAT: left; MARGIN: 0px 10px; WIDTH: 210px
}
#home-c {
	FLOAT: left; MARGIN: 0px 10px; WIDTH: 210px
}
#home-r {
	FLOAT: left; MARGIN: 0px 10px; WIDTH: 210px
}
#blog {
	PADDING-RIGHT: 7em; PADDING-LEFT: 7em; PADDING-BOTTOM: 0px; =
PADDING-TOP: 0px
}
H1 {
	FONT-WEIGHT: normal; FONT-SIZE: 3em; MARGIN: 0.3em 0px; LETTER-SPACING: =
-1px
}
H1 SPAN {
	FONT-WEIGHT: bold; COLOR: #09f
}
H2 {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 1.7em; =
PADDING-BOTTOM: 0.5em; MARGIN: 0px; PADDING-TOP: 0px; BORDER-BOTTOM: =
#ffc 2px solid
}
#second H2 {
	BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; PADDING-LEFT: =
0px; FONT-WEIGHT: normal; FONT-SIZE: 2em; PADDING-BOTTOM: 0.5em; MARGIN: =
0px; BORDER-LEFT: 0px; PADDING-TOP: 0px; BORDER-BOTTOM: 0px
}
#blog H2 {
	BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; PADDING-LEFT: =
0px; FONT-WEIGHT: normal; FONT-SIZE: 2em; PADDING-BOTTOM: 0.5em; MARGIN: =
0px; BORDER-LEFT: 0px; PADDING-TOP: 0px; BORDER-BOTTOM: 0px
}
H3 {
	FONT-SIZE: 1.5em; LINE-HEIGHT: 1.5em
}
H4 {
	FONT-SIZE: 1.2em; TEXT-TRANSFORM: uppercase
}
H5 {
	FONT-SIZE: 1.2em; COLOR: #666
}
#second P {
	FONT-SIZE: 1.3em; LINE-HEIGHT: 1.5em
}
#blog P {
	FONT-SIZE: 1.3em; LINE-HEIGHT: 1.5em
}
#footer P {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2em; MARGIN: =
0px; COLOR: #fff; PADDING-TOP: 2em
}
TABLE {
	BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: =
0px
}
TD {
	PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FONT-SIZE: 9pt; =
PADDING-BOTTOM: 10px; PADDING-TOP: 10px
}
TD.shade {
	BACKGROUND-COLOR: #eee
}
#blog .post {
	PADDING-RIGHT: 0px; BORDER-TOP: #ffc 2px solid; PADDING-LEFT: 0px; =
FONT-SIZE: 1em; PADDING-BOTTOM: 5px; COLOR: #999; PADDING-TOP: 5px
}
.clear:unknown {
	CLEAR: both; DISPLAY: block; FONT-SIZE: 0px; VISIBILITY: hidden; =
HEIGHT: 0px; content: "."
}
.clear {
=09
}
 HTML .clear {
	HEIGHT: 1%
}
.clear {
	DISPLAY: block
}
.img-r {
	FLOAT: right; PADDING-BOTTOM: 10px; MARGIN: 0px 0px 0px 20px; WIDTH: =
300px
}
.img-l {
	FLOAT: left; PADDING-BOTTOM: 10px; MARGIN: 0px 20px 0px 0px; WIDTH: =
300px
}
#second .img-l P {
	FONT-SIZE: 1.5em; COLOR: #09f; TEXT-ALIGN: center
}
#second .img-r P {
	FONT-SIZE: 1.5em; COLOR: #09f; TEXT-ALIGN: center
}
HR {
	DISPLAY: none
}
CODE {
	COLOR: #963
}
A {
	COLOR: #345; BORDER-BOTTOM: #eee 1px solid; TEXT-DECORATION: none
}
A:visited {
	COLOR: #678
}
#nav A:visited {
	COLOR: #345
}
A:hover {
	COLOR: #f60
}
#nav A:hover {
	COLOR: #f60
}
H1 A {
	BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; COLOR: #666; =
BORDER-BOTTOM: 0px
}
H1 A:visited {
	BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; COLOR: #666; =
BORDER-BOTTOM: 0px
}
H1 A:hover {
	BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; COLOR: #666; =
BORDER-BOTTOM: 0px
}
A IMG {
	BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: =
0px
}

------=_NextPart_000_0000_01C7859D.3C5B8920--

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -