source: branches/0.9x/doc/ipcproto.txt

Last change on this file was 3925, checked in by charles, 10 years ago

Change the default port from 9090 to 51413 to get in compliance with IANA's port number assignment scheme. (1024 through 49151 are reserved)

File size: 22.3 KB
Line 
1It is assumed the reader is familiar with bencoding, as described in
2the BitTorrent protocol specification at
3http://www.bittorrent.org/protocol.html
4
5Dictionary keys used below will be enclosed in quotation marks, these
6are used for clarity and are not part of the actual key.
7
8The IPC protocol is used to allow processes to control or retrieve
9information from Transmission frontend, such as transmission-daemon,
10or the GTK+ or Mac OS X frontends.  This communication is done
11over a unix-domain socket file such as
12~/.transmission/daemon/socket. In this document the Transmission
13frontend will be referred to as the server and the process connecting
14to it as the client.
15
16Once a client connects to the server's socket, messages may be
17exchanged until either end closes the connection. Messages contain an
1832-bit payload length, encoded as 8 bytes of ASCII hexadecimal,
19followed by the payload. Upper, lower, or mixed case for the length
20are all acceptable and must be handled correctly. Payload lengths
21greater than 2^31 - 8 (ie: 2147483640 decimal, 7FFFFFF8 hex) are not
22allowed.
23
24Bencoded messages will additionally be shown in the following format
25for better readability:
26str  - "this is a string"
27num  - 38795
28list - ("wheeee", 435, "writing docs is boring")
29dict - {"name": "Josh", "beverage": "coffee", "quantity": "too damn much" }
30
31For version 1, the message payload is a bencoded dictionary, the
32valid keys and value formats for which are described below. Multiple
33keys may be used in one message.
34
35An example version 1 message:
36
370000000Ed4:porti51413ee
38        {"port": 51413}
39
40For version 2 the message payload is a bencoded list containing a
41message id string followed by a bencoded value, the format of which is
42the same for version 1. The value may be followed by an optional
43bencoded integer, this is a message tag and is described in more
44detail below.
45
46An example version 2 message:
47
480000001El12:get-info-alll4:hashee
49        ("get-info-all", ("hash"))
50
51The same message with a tag:
52
5300000021l12:get-info-alll4:hashei5ee
54        ("get-info-all", ("hash"), 5)
55
56Once the connection is made both the client and server must send a
57version 1 style message (ie: the payload is a dictionary and may not
58contain a tag) with the dictionary key "version" and a value formatted
59as described below. The version should be the first but not
60necessarily only key in the dictionary. Any other keys should be
61ignored and not processed as messages. Neither the client nor the
62server should wait to receive a version message before sending one, it
63must be sent immediately. No other messages should be sent until the
64version is received.
65
66The version value should be a bencoded dictionary containing two keys,
67"max" and "min". These are the minimum and maximum supported protocol
68versions, respectively. Communication will take place using the
69highest protocol version supported by both the client and the server,
70and is not possible at all if there is no common version. A client may
71receive a version value that is an integer instead of a dictionary
72with "min" and "max" keys. This deprecated version format indicates
73the only version supported by the server.
74
75The version dictionary may optionally contain a key "label". This is a
76human-readable name for the software, it is not machine-readable and
77neither servers nor clients should attempt to parse it.
78
79An example message containing minimum and maximum versions 1 and 2:
80
810000001Dd7:versiond3:mini1e3:maxi2eee
82        {"version": {"min": 1, "max": 2}}
83
84Tagged messages, only supported in version 2, allow a client to tag a
85message with a positive non-zero integer. The server is then required
86to send a response to the message even if none would normally be
87required, and to tag the response with the same integer. When the
88server receives a tagged message it must send exactly one message back
89with the same tag. The client is allowed to use the same tag for
90multiple messages, even if a response to the first is not received
91before the second it sent. If a tagged message does not normally
92require a response then a "succeeded", "failed", "not-supported" or
93"bad-format" message will be sent back.
94
95An example tagged message and response:
96
9700000010l5:startli8eei15ee
98        ("start", (8), 15)
9900000011l8:succeeded0:i15ee
100        ("succeeded", "", 15)
101
102Some example sessions, including version handshake, are found at the
103end of this file.
104
105Dictionary keys are encoded in UTF-8 and case sensitive. Any character
106except a NUL (0x00) is valid. A server or client need not support
107every possible key and should silently ignore any that it does not
108understand.
109
110If a reference to a boolean is seen, it should be taken to mean an
111integer with a value of 0 representing false, 1 representing true, and
112any other value undefined.
113
114Individual torrents are identified by a unique integer. This integer
115is only valid for the current connection and may be invalid or refer
116to another torrent in a future connection. If a torrent is closed it's
117ID will never be reused to refer to another torrent for at least the
118duration of the connection. Negative integers or 0 are not valid IDs.
119
120A list of keys and the format of their values follows. Also listed is
121the minimum protocol version that the key may be used with.
122
123
124Key:     "addfiles"
125Version: 1
126Format:  list of strings
127Replies: "succeeded", "failed", "not-supported", "bad-format", "info"
128Example: 8:addfilesl21:/torrents/foo.torrent20:/home/me/bar.torrente
129         "addfiles", ("/torrents/foo.torrent", /home/me/bar.torrent")
130Details: Each string is the absolute path to a torrent metainfo file
131         for the server to add. Note that whether or not the torrent
132         metainfo file is copied (allowing the original to be moved or
133         deleted safely) is implementation dependent and may not
134         currently be known or changed with this protocol.
135
136Key:     "addfile-detailed"
137Version: 2
138Format:  dict
139Replies: "succeeded", "failed", "not-supported", "bad-format", "info"
140Example: 16:addfile-detailedd4:file19:/tor/wooble.torrente
141         "addfile-detailed", {"file": "/tor/wooble.torrent"}
142Details: Dictionary containing information about a torrent for the
143         server to add. Valid keys include:
144           "file"       string, filename of torrent metainfo file
145           "data"       string, contents of a torrent metainfo file
146           "directory"  string, directory for data files for the torrent
147           "autostart"  boolean, start the torrent automatically
148         Either "file" or "data" is required, but both are not allowed.
149
150Key:     "automap"
151Version: 2
152Format:  boolean
153Replies: "succeeded", "failed", "not-supported", "bad-format"
154Example: 7:automapi1e
155         "automap", 1
156Details: Enable (1) or disable (0) automatic port mapping on the server.
157
158Key:     "autostart"
159Version: 2
160Format:  boolean
161Replies: "succeeded", "failed", "not-supported", "bad-format"
162Example: 9:autostarti0e
163         "autostart", 0
164Details: Enable (1) or disable (0) automatic starting of new torrents
165         added via "addfiles" or "addfiles-detailed" messages.
166
167Key:     "bad-format"
168Version: 2
169Format:  value is ignored
170Replies: N/A
171Example: 10:bad-format0:
172         "bad-format", ""
173Details: Sent in response to a tagged message which was structured
174         incorrectly. For example, an "autostart" message with a
175         string value might cause this message to be returned.
176
177Key:     "directory"
178Version: 2
179Format:  string
180Replies: "succeeded", "failed", "not-supported", "bad-format"
181Example: 9:directory21:/home/roger/downloads
182         "directory", "/home/roger/downloads"
183Details: Set the default directory used for any torrents added in the future.
184
185Key:     "downlimit"
186Version: 2
187Format:  int
188Replies: "succeeded", "failed", "not-supported", "bad-format"
189Example: 9:downlimiti100e
190         "downlimit", 100
191Details: Set the server's download limit in kilobytes per second.
192         Negative values are interpreted as no limit.
193
194Key:     "failed"
195Version: 2
196Format:  string
197Replies: N/A
198Example: 6:failed17:permission denied
199         "failed", "permission denied"
200Details: Sent in response to a tagged message to indicate failure.
201
202Key:     "get-automap"
203Version: 2
204Format:  value is ignored
205Replies: "failed", "not-supported", "bad-format", "automap"
206Example: 11:get-automap0:
207         "get-automap", ""
208Details: Requests that an "automap" message be sent back.
209
210Key:     "get-autostart"
211Version: 2
212Format:  value is ignored
213Replies: "failed", "not-supported", "bad-format", "autostart"
214Example: 13:get-autostart0:
215         "get-autostart", ""
216Details: Requests that an "autostart" message be sent back.
217
218Key:     "get-directory"
219Version: 2
220Format:  value is ignored
221Replies: "failed", "not-supported", "bad-format", "directory"
222Example: 13:get-directory0:
223         "get-directory", ""
224Details: Requests that an "directory" message be sent back.
225
226Key:     "get-downlimit"
227Version: 2
228Format:  value is ignored
229Replies: "failed", "not-supported", "bad-format", "downlimit"
230Example: 13:get-downlimit0:
231         "get-downlimit", ""
232Details: Requests that a "downlimit" message be sent back.
233
234Key:     "get-info"
235Version: 2
236Format:  dict with keys "id" and "type" for lists of ints and strings
237Replies: "failed", "not-supported", "bad-format", "info"
238Example: 8:get-infod2:idli4ei7ei2ee4:typel4:hash4:nameee
239         "get-info", {"id": (4, 7, 2), "type": ("hash", "name")}
240Details: Requests that the server send back an "info" message with
241         info on all the torrent IDs in "id". The "type" key requests
242         what info will be returned. See below for valid values to use
243         here. Since the torrent ID is always included in an "info"
244         message an empty or missing "type" key will cause only the ID
245         to be returned. An "info" message will always be sent back,
246         even if it is empty.
247
248Key:     "get-info-all"
249Version: 2
250Format:  list of strings
251Replies: "failed", "not-supported", "bad-format", "info"
252Example: 12:get-info-alll4:hash4:namee
253         "get-info-all", ("hash", "name")
254Details: Same as "getinfo" message with all torrent IDs specified.
255
256Key:     "get-pex"
257Version: 2
258Format:  value is ignored
259Replies: "failed", "not-supported", "bad-format", "pex"
260Example: 7:get-pex0:
261         "get-pex", ""
262Details: Requests that a "pex" message be sent back.
263
264Key:     "get-port"
265Version: 2
266Format:  value is ignored
267Replies: "failed", "not-supported", "bad-format", "port"
268Example: 8:get-port0:
269         "get-port", ""
270Details: Requests that a "port" message be sent back.
271
272Key:     "get-status"
273Version: 2
274Format:  dict with keys "id" and "type" for lists of ints and strings
275Replies: "failed", "not-supported", "bad-format", "status"
276Example: 10:get-statusd2:idli4ei7ei2ee4:typel5:state9:completedee
277         "get-status", {"id": (4, 7, 4), "type": ("state", "completed")}
278Details: Same as "get-info" message except status type strings are used
279         instead and the server sends back a "status" message.
280
281Key:     "get-status-all"
282Version: 2
283Format:  list of strings
284Replies: "failed", "not-supported", "bad-format", "status"
285Example: 14:get-status-alll5:state9:completede
286         "get-status-all", ("state", "completed")
287Details: Same as "get-status" message with all torrent IDs specified.
288
289Key:     "get-supported"
290Version: 2
291Format:  list of strings
292Replies: "failed", "not-supported", "bad-format", "supported"
293Example: 13:get-supportedl6:lookup8:get-port16:addfile-detailede
294         "get-supported", ("lookup", "get-port", "addfile-detailed")
295Details: Request that a "supported" message be returned with whichever
296         of the given message keys are supported.
297
298Key:     "get-uplimit"
299Version: 2
300Format:  value is ignored
301Replies: "failed", "not-supported", "bad-format", "uplimit"
302Example: 11:get-uplimit0:
303         "get-uplimit", ""
304Details: Requests that an "uplimit" message be sent back.
305
306Key:     "lookup"
307Version: 2
308Format:  list of strings
309Replies: "failed", "not-supported", "bad-format", "info"
310Example: 6:lookupl40:0f16ea6965ee5133ea4dbb1e7f516e9fcf3d899ee
311         "lookup", ("0f16ea6965ee5133ea4dbb1e7f516e9fcf3d899e")
312Details: Request that the server send back an "info" message with "id"
313         and "hash" keys for any torrents with the given hashes.
314
315Key:     "info"
316Version: 2
317Format:  list of dictionaries
318Replies: N/A
319Example: 4:infold2:idi3e4:name3:fooed2:idi9e4:name3:baree
320         "info", ({"id": 4, "name": "foo"}, {"id": 9, "name": "bar"})
321Details: A list containing information for several torrents. The
322         dictionaries always contain at least an "id" key with the
323         integer ID for the torrent, other possible values are listed
324         below.
325
326Key:     "noop"
327Version: 2
328Format:  value is ignored
329Replies: "succeeded", "failed", "not-supported", "bad-format"
330Example: 4:noop0:
331         "noop", ""
332Details: This does nothing but keep the connection alive. With a tag
333         it may be used as a ping.
334
335Key:     "not-supported"
336Version: 2
337Format:  value is ignored
338Replies: N/A
339Example: 13:not-supported0:
340         "not-supported", ""
341Details: Sent in response to a tagged message to indicated that the
342         message was not supported.
343
344Key:     "pex"
345Version: 2
346Format:  boolean
347Replies: "succeeded", "failed", "not-supported", "bad-format"
348Example: 3:pexi0e
349         "pex", 0
350Details: Enables or disables peer exchange.
351
352Key:     "port"
353Version: 2
354Format:  int between 0 and 65535
355Replies: "succeeded", "failed", "not-supported", "bad-format"
356Example: 4:porti51413e
357         "port", 51413
358Details: Change the port the server uses to listen for incoming peer
359         connections.
360
361Key:     "quit"
362Version: 1
363Format:  value is ignored
364Replies: "succeeded", "failed", "not-supported", "bad-format"
365Example: 4:quit0:
366         "quit", ""
367Details: Cause the server to quit. Note that the connection might be
368         closed without a response being sent.
369
370Key:     "remove"
371Version: 2
372Format:  list of torrent ID ints
373Replies: "succeeded", "failed", "not-supported", "bad-format"
374Example: 5:removeli3ei8ei6ee
375         "remove", (3, 8, 6)
376Details: Stop and remove the specified torrents. Note that whether or
377         not the downloaded data or the original torrent files will be
378         removed is implementation dependent and may not currently be
379         known or changed with this protocol. If a saved copy of the
380         torrent file has been made then it will always be deleted.
381
382Key:     "remove-all"
383Version: 2
384Format:  value is ignored
385Replies: "succeeded", "failed", "not-supported", "bad-format"
386Example: 10:remove-all0:
387         "remove-all", ""
388Details: Like "remove" with all torrent IDs specified.
389
390Key:     "start"
391Version: 2
392Format:  list of torrent ID ints
393Replies: "succeeded", "failed", "not-supported", "bad-format"
394Example: 5:startli3ei8ei6ee
395         "start", (3, 8, 6)
396Details: List of torrent IDs to start.
397
398Key:     "start-all"
399Version: 2
400Format:  value is ignored
401Replies: "succeeded", "failed", "not-supported", "bad-format"
402Example: 9:start-all0:
403         "start-all", ""
404Details: Start all torrents.
405
406Key:     "status"
407Version: 2
408Format:  list of dictionaries
409Replies: N/A
410Example: 4:infold2:idi3e5:state7:seedinged2:idi9e5:state6:pausedee
411         "info", ({"id": 3, "state": "seeding"}, {"id": 9, "state" : "paused"})
412Details: Same as "info" message except status type keys are used.
413
414Key:     "stop"
415Version: 2
416Format:  list of torrent ID ints
417Replies: "succeeded", "failed", "not-supported", "bad-format"
418Example: 4:stopli3ei8ei6ee
419         "stop", (3, 8, 6)
420Details: List of torrent IDs to stop.
421
422Key:     "stop-all"
423Version: 2
424Format:  value is ignored
425Replies: "succeeded", "failed", "not-supported", "bad-format"
426Example: 8:stop-all0:
427         "stop-all", ""
428Details: Stop all torrents.
429
430Key:     "succeeded"
431Version: 2
432Format:  value is ignored
433Replies: N/A
434Example: 8:succeeded0:
435         "succeeded", ""
436Details: This is used to indicate that a tagged message was processed
437         successfully.
438
439Key:     "supported"
440Version: 2
441Format:  list of strings
442Replies: N/A
443Example: 9:supportedl8:get-port6:lookupe
444         "supported", ("get-port", "lookup")
445Details: Sent in response to a "get-supported" message, indicates that
446         the given messages ate supported.
447
448Key:     "uplimit"
449Version: 2
450Format:  int
451Replies: "succeeded", "failed", "not-supported", "bad-format"
452Example: 7:uplimiti20e
453         "uplimit", 20
454Details: Set the server's upload limit in kilobytes per second.
455         Negative values are interpreted as no limit.
456
457
458Info types for "get-info" and "info" messages. The only type for which
459support is mandatory is "id".
460
461"id"       integer, torrent's ID for this connection
462"hash"     SHA-1 info hash as a 40-char hex string
463"name"     string, torrent name
464"path"     string, path to .torrent file
465"saved"    boolean, true if a copy of this torrent was saved
466"private"  boolean, true if the torrent is private
467"trackers" a list of lists of dictionaries containing tracker info:
468             "address"  string, hostname or ip address of tracker
469             "port"     integer, port for tracker
470             "announce" string, announce url on tracker
471             "scrape"   string, scrape url on tracker, may be absent
472"comment"  string, comment from torrent file
473"creator"  string, creator of torrent file
474"date"     integer, date of torrent creation (unix time_t format)
475"size"     integer, total size of all files in bytes
476"files"    list of dictionaries for the files in this torrent:
477             "name" string, name of file
478             "size" integer, size of file in bytes
479
480
481Status types for "get-status" and "status" messages. The only type for
482which support is mandatory is "id".
483
484"completed"         integer, bytes of data downloaded and verified
485"download-speed"    integer, download speed in bytes per second
486"download-total"    integer, total bytes downloaded so far
487"error"             string, one of the following:
488                      "assert"          something happened that shouldn't
489                      "io-parent"       missing parent directory
490                      "io-permissions"  filesystem permission error
491                      "io-space"        not enough free space in filesystem
492                      "io-resource"     insufficient resources
493                      "io-other"        other filesystem i/o error
494                      "tracker-error"   tracker returned error message
495                      "tracker-warning" tracker returned warning message
496                      "other"           other error
497                      zero-length or missing string indicates no error
498"error-message"     string, printable error message
499"eta"               integer, estimated seconds until downloading is finished
500"id"                integer, torrent's ID for this connection
501"peers-downloading" integer, peers downloading from us
502"peers-from"        dict with the following int keys, peer connection sources:
503                      "incoming"    peers connected to our listening port
504                      "tracker"     peers discovered from tracker
505                      "cache"       peers retrieved from on-disk cache
506                      "pex"         peers discovered via peer exchange
507"peers-total"       integer, total connected peers
508"peers-uploading"   integer, peers uploading to us
509"running"           boolean, false if torrent is stopped or stopping
510"state"             string, one of the following:
511                      "checking"    performing hash check on file data
512                      "downloading" downloading file data
513                      "seeding"     seeding file data to peers
514                      "stopping"    contacting tracker to send 'stopped' event
515                      "paused"      torrent is not active
516                      "waiting to checking"
517                                    torrent is queued for hash check.
518                                    yes, this it really is called that.
519"swarm-speed"       integer, swarm speed in bytes per second
520"tracker"           dict with the following keys, current active tracker
521                      "address"     string, hostname or ip address of tracker
522                      "port"        integer, port for tracker
523                      "announce"    string, tracker announce url
524                      "scrape"      string, tracker scrape url, may be absent
525"scrape-completed"  integer, total completed peers as reported by tracker
526"scrape-leechers"   integer, current leechers as reported by tracker
527"scrape-seeders"    integer, current, seeders as reported by tracker
528"upload-speed"      integer, upload speed in bytes per second
529"upload-total"      integer, total bytes uploaded so far
530
531
532Examples:
533
534Data from the client to the server is prefixed with >>> and from
535server to client with <<<. These prefixes and newlines are added for
536clarity, they are not actually sent over the socket.
537
538Quit the server. Note that this is a version 1 client and so version 1
539messages are used.
540>>> 0000001Dd7:versiond3:mini1e3:maxi1eee
541            {"version", {"min": 1, "max": 1"}}
542<<< 0000001Dd7:versiond3:mini1e3:maxi2eee
543            {"version", {"min": 1, "max": 2"}}
544>>> 0000000Bd4:quit0:e
545            {"quit": ""}
546
547Pause all torrents and disable automapping. Note the server happens to
548have sent it's version before the client. The value for the stop-all
549message here is 5:fnord instead of 0: as used above, since the value
550is unused anything is allowed.
551<<< 0000001Dd7:versiond3:mini1e3:maxi2eee
552            {"version", {"min": 1, "max": 2"}}
553>>> 0000001Dd7:versiond3:mini1e3:maxi2eee
554            {"version", {"min": 1, "max": 2"}}
555>>> 0000000El8:stop-all5:fnorde
556            ("stop-all", "fnord")
557
558Change upload and download limits with tagged responses.
559>>> 0000001Dd7:versiond3:mini1e3:maxi2eee
560            {"version", {"min": 1, "max": 2"}}
561<<< 0000001Dd7:versiond3:mini1e3:maxi2eee
562            {"version", {"min": 1, "max": 2"}}
563>>> 00000017l9:downlimiti100ei47el
564            ("downlimit", 100, 47)
565>>> 00000017l9:uplimiti20ei48ee
566            ("uplimit", 20, 48)
567<<< 00000014l8:succeeded0:i47ee
568            ("succeeded", "", 47)
569<<< 00000014l8:succeeded0:i48ee
570            (succeeded"", "", 48)
571
572Retrieve the upload and download limits. Note that the server has
573returned the responses in a different order than the requests were
574sent. The server is allowed to do this, a client should use tags if
575this is a concern.
576>>> 0000001Dd7:versiond3:mini1e3:maxi2eee
577            {"version", {"min": 1, "max": 2"}}
578<<< 0000001Dd7:versiond3:mini1e3:maxi2eee
579            {"version", {"min": 1, "max": 2"}}
580>>> 00000015l13:get-downlimiti0ee00000013l13:get-uplimiti0ee
581            ("get-downlimit", 0)
582            ("get-uplimit", 0)
583<<< 0000000Fl9:uplimiti20ee00000012l9:downlimiti100ee
584            ("uplimit", 20)
585            ("downlimit", 100)
Note: See TracBrowser for help on using the repository browser.