2 .\" Copyright (C) 2004-2008 Richard Kettlewell
4 .\" This program is free software; you can redistribute it and/or modify
5 .\" it under the terms of the GNU General Public License as published by
6 .\" the Free Software Foundation; either version 2 of the License, or
7 .\" (at your option) any later version.
9 .\" This program is distributed in the hope that it will be useful, but
10 .\" WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 .\" General Public License for more details.
14 .\" You should have received a copy of the GNU General Public License
15 .\" along with this program; if not, write to the Free Software
16 .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 .TH disorder_protocol 5
21 disorder_protocol \- DisOrder communication protocol
23 The DisOrder client and server communicate via the protocol described
26 The protocol is liable to change without notice.
27 You are recommended to check the implementation before believing this document.
29 Everything is encoded using UTF-8.
31 .B "CHARACTER ENCODING"
32 below for more detail on character encoding issues.
34 Commands and responses consist of a line perhaps followed (depending on the
35 command or response) by a body.
37 The line syntax is the same as described in \fBdisorder_config\fR(5) except
38 that comments are prohibited.
40 Bodies borrow their syntax from RFC821; they consist of zero or more ordinary
41 lines, with any initial full stop doubled up, and are terminated by a line
42 consisting of a full stop and a line feed.
44 Commands only have a body if explicitly stated below.
45 If they do have a body then the body should always be sent immediately;
46 unlike (for instance) the SMTP "DATA" command there is no intermediate step
47 where the server asks for the body to be sent.
49 Replies also only have a body if stated below.
50 The presence of a reply body can always be inferred from the response code;
51 if the last digit is a 3 then a body is present, otherwise it is not.
53 Commands always have a command name as the first field of the line; responses
54 always have a 3-digit response code as the first field.
55 See below for more details about this field.
57 All commands require the connection to have been already authenticated unless
59 If not stated otherwise, the \fBread\fR right is sufficient to execute
62 .B adduser \fIUSERNAME PASSWORD \fR[\fIRIGHTS\fR]
63 Create a new user with the given username and password.
64 The new user's rights list can be specified; if it is not
65 then the \fBdefault_rights\fR setting applies instead.
66 Requires the \fBadmin\fR right, and only works on local
69 .B allfiles \fIDIRECTORY\fR [\fIREGEXP\fR]
70 List all the files and directories in \fIDIRECTORY\fR in a response body.
71 If \fIREGEXP\fR is present only matching files and directories are returned.
73 .B confirm \fICONFIRMATION
74 Confirm user registration.
75 \fICONFIRMATION\fR is as returned from \fBregister\fR below.
76 This command can be used without logging in.
79 Log a user back in using a cookie created with \fBmake\-cookie\fR.
80 The response contains the username.
82 .B deluser \fIUSERNAME
83 Delete the named user.
84 Requires the \fBadmin\fR right, and only works on local connections.
86 .B dirs \fIDIRECTORY\fR [\fIREGEXP\fR]
87 List all the directories in \fIDIRECTORY\fR in a response body.
88 If \fIREGEXP\fR is present only matching directories are returned.
90 .B disable \fR[\fBnow\fR]
91 Disable further playing.
92 If the optional \fBnow\fR argument is present then the current track
94 Requires the \fBglobal prefs\fR right.
96 .B edituser \fIUSERNAME PROPERTY VALUE
98 With the \fBadmin\fR right any username and property may be specified.
99 Otherwise the \fBuserinfo\fR right is required and only the
100 \fBemail\fR and \fBpassword\fR properties may be set.
102 User properties are syntax-checked before setting. For instance \fBemail\fR
103 must contain an "@" sign or you will get an error. (Setting an empty value for
104 \fBemail\fR is allowed and removes the property.)
107 Re-enable further playing, and is the opposite of \fBdisable\fR.
108 Requires the \fBglobal prefs\fR right.
111 Report whether playing is enabled.
112 The second field of the response line will be \fByes\fR or \fBno\fR.
114 .B exists \fITRACK\fR
115 Report whether the named track exists.
116 The second field of the response line will be \fByes\fR or \fBno\fR.
118 .B files \fIDIRECTORY\fR [\fIREGEXP\fR]
119 List all the files in \fIDIRECTORY\fR in a response body.
120 If \fIREGEXP\fR is present only matching files are returned.
122 .B get \fITRACK\fR \fIPREF\fR
123 Getsa preference value.
124 On success the second field of the response line will have the value.
126 If the track or preference do not exist then the response code is 555.
128 .B get\-global \fIKEY\fR
129 Get a global preference.
131 If the preference does not exist then the response code is 555.
133 .B length \fITRACK\fR
134 Get the length of the track in seconds.
135 On success the second field of the response line will have the value.
138 Send event log messages in a response body.
139 The command will never terminate.
140 Any further data sent to the server will be discarded (explicitly;
141 i.e. it will not accumulate in a buffer somewhere).
143 See \fBEVENT LOG\fR below for more details.
146 Returns an opaque string that can be used by the \fBcookie\fR command to log
147 this user back in on another connection (until the cookie expires).
149 .B move \fITRACK\fR \fIDELTA\fR
150 Move a track in the queue.
151 The track may be identified by ID (preferred) or name (which might cause
152 confusion if it's there twice).
153 \fIDELTA\fR should be an negative or positive integer and indicates how
154 many steps towards the head of the queue the track should be moved.
156 Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
157 depending on how the track came to be added to the queue.
159 .B moveafter \fITARGET\fR \fIID\fR ...
160 Move all the tracks in the \fIID\fR list after ID \fITARGET\fR.
161 If \fITARGET\fR is the empty string then the listed tracks are put
162 at the head of the queue.
163 If \fITARGET\fR is listed in the ID list then the tracks are moved
164 to just after the first non-listed track before it, or to the head if there is
167 Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
168 depending on how the tracks came to be added to the queue.
170 .B new \fR[\fIMAX\fR]
171 Send the most recently added \fIMAX\fR tracks in a response body.
172 If the argument is ommitted, the \fBnew_max\fR most recent tracks are
173 listed (see \fBdisorder_config\fR(5)).
179 as a keepalive measure.
180 This command does not require authentication.
182 .B part \fITRACK\fR \fICONTEXT\fI \fIPART\fR
183 Get a track name part.
184 Returns an empty string if a name part cannot be constructed.
200 Pause the current track.
201 Requires the \fBpause\fR right.
204 Add a track to the queue.
205 The response contains the queue ID of the track.
206 Requires the \fBplay\fR right.
209 Report what track is playing.
211 If the response is \fB252\fR then the rest of the response line consists of
212 track information (see below).
214 If the response is \fB259\fR then nothing is playing.
216 .B playlist-delete \fIPLAYLIST\fR
218 Requires permission to modify that playlist and the \fBplay\fR right.
220 .B playlist-get \fIPLAYLIST\fR
221 Get the contents of a playlist, in a response body.
222 Requires permission to read that playlist and the \fBread\fR right.
224 .B playlist-get-share \fIPLAYLIST\fR
225 Get the sharing status of a playlist.
226 The result will be \fBpublic\fR, \fBprivate\fR or \fBshared\fR.
227 Requires permission to read that playlist and the \fBread\fR right.
229 .B playlist-lock \fIPLAYLIST\fR
231 Requires permission to modify that playlist and the \fBplay\fR right.
232 Only one playlist may be locked at a time on a given connection and the lock
233 automatically expires when the connection is closed.
235 .B playlist-set \fIPLAYLIST\fR
236 Set the contents of a playlist.
237 The new contents should be supplied in a command body.
238 Requires permission to modify that playlist and the \fBplay\fR right.
239 The playlist must be locked.
241 .B playlist-set-share \fIPLAYLIST\fR \fISHARE\fR
242 Set the sharing status of a playlist to
243 \fBpublic\fR, \fBprivate\fR or \fBshared\fR.
244 Requires permission to modify that playlist and the \fBplay\fR right.
246 .B playlist-unlock\fR
247 Unlock the locked playlist.
250 List all playlists that this connection has permission to read.
251 Requires the \fBread\fR right.
254 Send back the preferences for \fITRACK\fR in a response body.
255 Each line of the response has the usual line syntax, the first field being the
256 name of the pref and the second the value.
259 Send back the current queue in a response body, one track to a line, the track
260 at the head of the queue (i.e. next to be be played) first.
261 See below for the track information syntax.
264 Disable random play (but don't stop the current track).
265 Requires the \fBglobal prefs\fR right.
269 Requires the \fBglobal prefs\fR right.
272 Report whether random play is enabled.
273 The second field of the response line will be \fByes\fR or \fBno\fR.
276 Send back the current recently-played list in a response body, one track to a
277 line, the track most recently played last.
278 See below for the track information syntax.
281 Request that DisOrder reconfigure itself.
282 Requires the \fBadmin\fR right.
284 .B register \fIUSERNAME PASSWORD EMAIL
286 Requires the \fBregister\fR right.
287 The result contains a confirmation string; the user will be be able
288 to log in until this has been presented back to the server via the
289 \fBconfirm\fR command.
291 .B reminder \fIUSERNAME\fR
292 Send a password reminder to user \fIUSERNAME\fR.
293 If the user has no valid email address, or no password, or a
294 reminder has been sent too recently, then no reminder will be sent.
297 Remove the track identified by \fIID\fR.
298 Requires one of the \fBremove mine\fR, \fBremove random\fR or
299 \fBremove any\fR rights depending on how the
300 track came to be added to the queue.
302 .B rescan \fR[\fBwait\fR] \fR[\fBfresh\fR]
303 Rescan all roots for new or obsolete tracks.
304 Requires the \fBrescan\fR right.
306 If the \fBwait\fR flag is present then the response is delayed until the rescan
308 Otherwise the response arrives immediately.
309 This is primarily intended for testing.
311 If the \fBfresh\fR flag is present a rescan is already underway then a second
312 rescan will be started when it completes.
313 The default behavior is to piggyback on the existing rescan.
315 NB that \fBfresh\fR is currently disabled in the server source, so using this
316 flag will just provoke an error.
318 .B resolve \fITRACK\fR
319 Resolve a track name, i.e. if this is an alias then return the real track name.
322 Resume the current track after a \fBpause\fR command.
323 Requires the \fBpause\fR right.
325 .B revoke \fBcookie\fR
326 Revoke a cookie previously created with \fBmake\-cookie\fR.
327 It will not be possible to use this cookie in the future.
330 Report the RTP broadcast (or multicast) address, in the form \fIADDRESS
332 This command does not require authentication.
334 .B scratch \fR[\fIID\fR]
335 Remove the track identified by \fIID\fR, or the currently playing track if no
336 \fIID\fR is specified.
337 Requires one of the \fBscratch mine\fR, \fBscratch random\fR or
338 \fBscratch any\fR rights depending on how the track came to be
341 .B schedule-add \fIWHEN\fR \fIPRIORITY\fR \fIACTION\fR ...
342 Schedule an event for the future.
345 is the time when it should happen, as \fBtime_t\fR value.
346 It must refer to a time in the future.
349 is the event priority.
350 This can be \fBnormal\fR, in which case the event will be run at startup if its
351 time has past, or \fBjunk\fR in which case it will be discarded if it is found
352 to be in the past at startup.
353 The meaning of other values is not defined.
356 is the action to perform.
357 The choice of action determines the meaning of the remaining arguments.
358 Possible actions are:
363 The next argument is the track name.
364 Requires the \fBplay\fR right.
367 Set a global preference.
368 The next argument is the preference name and the final argument is the value to
369 set it to (omit it to unset it).
370 Requires the \fBglobal prefs\fR right.
373 You need the right at the point you create the event.
374 It is not possible to create scheduled events in expectation of a future change
377 .B schedule-del \fIEVENT\fR
378 Deletes a scheduled event.
379 Users can always delete their own scheduled events; with the \fBadmin\fR
380 right you can delete any event.
382 .B schedule-get \fIEVENT\fR
383 Sends the details of scheduled event \fIEVENT\fR in a response body.
384 Each line is a pair of strings quoted in the usual way, the first being the key
385 ane the second the value.
386 No particular order is used.
388 Scheduled events are considered public information.
389 Right \fBread\fR is sufficient to see details of all events.
392 Sends the event IDs of all scheduled events in a response body, in no
394 Use \fBschedule-get\fR to get the details of each event.
396 .B search \fITERMS\fR
397 Search for tracks matching the search terms.
398 The results are put in a response body, one to a line.
400 The search string is split in the usual way, with quoting supported, into a
402 Only tracks matching all terms are included in the results.
404 Any terms of the form \fBtag:\fITAG\fR limits the search to tracks with that
407 All other terms are interpreted as individual words which must be present in
410 Spaces in terms don't currently make sense, but may one day be interpreted to
411 allow searching for phrases.
413 .B \fBset\fR \fITRACK\fR \fIPREF\fR \fIVALUE\fR
415 Requires the \fBprefs\fR right.
417 .B set\-global \fIKEY\fR \fIVALUE\fR
418 Set a global preference.
419 Requires the \fBglobal prefs\fR right.
422 Send server statistics in plain text in a response body.
425 Send the list of currently known tags in a response body.
427 .B \fBunset\fR \fITRACK\fR \fIPREF\fR
429 Requires the \fBprefs\fR right.
431 .B \fBunset\-global\fR \fIKEY\fR
432 Unset a global preference.
433 Requires the \fBglobal prefs\fR right.
435 .B user \fIUSERNAME\fR \fIRESPONSE\fR
436 Authenticate as user \fIUSERNAME\fR.
441 .B userinfo \fIUSERNAME PROPERTY
445 Send the list of currently known users in a response body.
448 Send back a response with the server version as the second field.
450 .B volume \fR[\fILEFT\fR [\fIRIGHT\fR]]
451 Get or set the volume.
453 With zero parameters just gets the volume and reports the left and right sides
454 as the 2nd and 3rd fields of the response.
456 With one parameter sets both sides to the same value.
457 With two parameters sets each side independently.
458 Setting the volume requires the \fBvolume\fR right.
460 Responses are three-digit codes.
461 The first digit distinguishes errors from succesful responses:
469 The second digit breaks down the origin of the response:
472 Generic responses not specific to the handling of the command.
473 Mostly this is parse errors.
476 51x errors indicate that the user had insufficient rights for the command.
479 Authentication responses.
482 Responses specific to the handling of the command.
484 The third digit provides extra information about the response:
487 Text part is just commentary.
490 Text part is a constant result e.g. \fBversion\fR.
493 Text part is a potentially variable result.
496 Text part is just commentary; a dot-stuffed body follows.
499 Text part is just commentary; an indefinite dot-stuffed body follows.
500 (Used for \fBlog\fR.)
503 Used with "normal" errors, for instance a preference not being found.
504 The text part is commentary.
507 The text part is just commentary (but would normally be a response for this
508 command) e.g. \fBplaying\fR.
510 Result strings (not bodies) intended for machine parsing (i.e. xx1 and xx2
511 responses) are quoted.
513 When a connection is made the server sends a \fB231\fR response before any
515 This contains a protocol generation, an algorithm name and a
516 challenge encoded in hex, all separated by whitespace.
518 The current protocol generation is \fB2\fR.
520 The possible algorithms are (currently) \fBsha1\fR, \fBsha256\fR, \fBsha384\fR
522 \fBSHA1\fR etc work as synonyms.
524 The \fBuser\fR response consists of the selected hash of the user's password
525 concatenated with the challenge, encoded in hex.
526 .SH "TRACK INFORMATION"
527 Track information is encoded in a line (i.e. using the usual line syntax) as
529 The first is a name, the second a value.
530 The names have the following meanings:
533 The time the track is expected to be played at.
536 A string uniquely identifying this queue entry.
539 The time the track was played at.
542 The user that scratched the track.
545 The current track state.
550 The player failed (exited with nonzero status but wasn't scratched).
553 The track is actually a scratch.
556 No player could be found for the track.
559 The track was played without any problems.
562 The track was scratched.
565 The track is currently playing.
568 In the queue, hasn't been played yet.
571 The track was terminated because the server is shutting down.
575 The user that submitted the track.
578 The filename of the track.
581 The time the track was added to the queue.
584 The wait status of the player in decimal.
586 Times are decimal integers using the server's \fBtime_t\fR.
588 For file listings, the regexp applies to the basename of the returned file, not
589 the whole filename, and letter case is ignored.
590 \fBpcrepattern\fR(3) describes the regexp syntax.
592 Filenames are in UTF-8 even if the collection they come from uses some other
593 encoding - if you want to access the real file (in such cases as the filenames
594 actually correspond to a real file) you'll have to convert to whatever the
597 The event log consists of lines starting with a hexadecimal timestamp and a
598 keyword followed by (optionally) parameters.
599 The parameters are quoted in the usual DisOrder way.
600 Currently the following keywords are used:
602 .B completed \fITRACK\fR
603 Completed playing \fITRACK\fR
605 .B failed \fITRACK\fR \fIERROR\fR
606 Completed playing \fITRACK\fR with an error status
608 .B moved \fIUSERNAME\fR
609 User \fIUSERNAME\fR moved some track(s).
610 Further details aren't included any more.
612 .B playing \fITRACK\fR [\fIUSERNAME\fR]
613 Started playing \fITRACK\fR.
615 .B queue \fIQUEUE-ENTRY\fR...
616 Added \fITRACK\fR to the queue.
618 .B recent_added \fIQUEUE-ENTRY\fR...
619 Added \fIID\fR to the recently played list.
621 .B recent_removed \fIID\fR
622 Removed \fIID\fR from the recently played list.
624 .B removed \fIID\fR [\fIUSERNAME\fR]
625 Queue entry \fIID\fR was removed.
626 This is used both for explicit removal (when \fIUSERNAME\fR is present)
627 and when playing a track (when it is absent).
632 .B scratched \fITRACK\fR \fIUSERNAME\fR
633 \fITRACK\fR was scratched by \fIUSERNAME\fR.
635 .B state \fIKEYWORD\fR
636 Some state change occurred.
637 The current set of keywords is:
641 The current track completed successfully.
644 Playing was disabled.
647 Random play was disabled.
653 Random play was enabled.
656 The current track failed.
659 The current track was paused.
662 A track started playing.
665 The current track was resumed.
667 .B rights_changed \fIRIGHTS\fR
668 User's rights were changed.
671 The current track was scratched.
673 To simplify client implementation, \fBstate\fR commands reflecting the current
674 state are sent at the start of the log.
677 .B user_add \fIUSERNAME\fR
680 .B user_delete \fIUSERNAME\fR
683 .B user_edit \fIUSERNAME\fR \fIPROPERTY\fR
684 Some property of a user was edited.
686 .B user_confirm \fIUSERNAME\fR
687 A user's login was confirmed (via the web interface).
689 .B volume \fILEFT\fR \fIRIGHT\fR
694 .B "TRACK INFORMATION"
697 The \fBuser-*\fR messages are only sent to admin users, and are not sent over
698 non-local connections unless \fBremote_userman\fR is enabled.
699 .SH "CHARACTER ENCODING"
700 All data sent by both server and client is encoded using UTF-8.
701 Moreover it must be valid UTF-8, i.e. non-minimal sequences are not
702 permitted, nor are surrogates, nor are code points outside the
705 There are no particular normalization requirements on either side of the
707 The server currently converts internally to NFC, the client must
708 normalize the responses returned if it needs some normalized form for further
711 The various characters which divide up lines may not be followed by combining
713 For instance all of the following are prohibited:
716 LINE FEED followed by a combining character.
717 For example the sequence LINE FEED, COMBINING GRAVE ACCENT is never permitted.
720 APOSTROPHE or QUOTATION MARK followed by a combining character when used to
722 For instance a line starting APOSTROPHE, COMBINING CEDILLA is prohibited.
724 Note that such sequences are not prohibited when the quote character cannot be
725 interpreted as a field delimiter.
726 For instance APOSTROPHE, REVERSE SOLIDUS, APOSTROPHE, COMBINING CEDILLA,
727 APOSTROPHE would be permitted.
730 REVERSE SOLIDUS (BACKSLASH) followed by a combining character in a quoted
731 string when it is the first character of an escape sequence.
732 For instance a line starting APOSTROPHE, REVERSE SOLIDUS, COMBINING TILDE
735 As above such sequences are not prohibited when the character is not being used
736 to start an escape sequence.
737 For instance APOSTROPHE, REVERSE SOLIDUS, REVERSE SOLIDS, COMBINING TILDE,
738 APOSTROPHE is permitted.
741 Any of the field-splitting whitespace characters followed by a combining
742 character when not part of a quoted field.
743 For instance a line starting COLON, SPACE, COMBINING CANDRABINDU is prohibited.
745 As above non-delimiter uses are fine.
748 The FULL STOP characters used to quote or delimit a body.
750 Furthermore none of these characters are permitted to appear in the context of
751 a canonical decomposition (i.e. they must still be present when converted to
753 In practice however this is not an issue in Unicode 5.0.
755 These rules are consistent with the observation that the split() function is
756 essentially a naive ASCII parser.
757 The implication is not that these sequences never actually appear in
758 the protocol, merely that the server is not required to honor them in
759 any useful way nor be consistent between versions: in current
760 versions the result will be lines and fields that start with combining
761 characters and are not necessarily split where you expect, but future versions
762 may remove them, reject them or ignore some or all of the delimiters that have
763 following combining characters, and no notice will be given of any change.
769 \fBdisorder_config\fR(5),