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 3 of the License, or
7 .\" (at your option) any later version.
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 .\" GNU 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, see <http://www.gnu.org/licenses/>.
17 .TH disorder_protocol 5
19 disorder_protocol \- DisOrder communication protocol
21 The DisOrder client and server communicate via the protocol described
24 The protocol is liable to change without notice.
25 You are recommended to check the implementation before believing this document.
27 Everything is encoded using UTF-8.
29 .B "CHARACTER ENCODING"
30 below for more detail on character encoding issues.
32 Commands and responses consist of a line perhaps followed (depending on the
33 command or response) by a body.
35 The line syntax is the same as described in \fBdisorder_config\fR(5) except
36 that comments are prohibited.
38 Bodies borrow their syntax from RFC821; they consist of zero or more ordinary
39 lines, with any initial full stop doubled up, and are terminated by a line
40 consisting of a full stop and a line feed.
42 Commands always have a command name as the first field of the line; responses
43 always have a 3-digit response code as the first field.
44 See below for more details about this field.
46 All commands require the connection to have been already authenticated unless
48 If not stated otherwise, the \fBread\fR right is sufficient to execute
51 Neither commands nor responses have a body unless stated otherwise.
53 .B adduser \fIUSERNAME PASSWORD \fR[\fIRIGHTS\fR]
54 Create a new user with the given username and password.
55 The new user's rights list can be specified; if it is not
56 then the \fBdefault_rights\fR setting applies instead.
57 Requires the \fBadmin\fR right, and only works on local
60 .B allfiles \fIDIRECTORY\fR [\fIREGEXP\fR]
61 List all the files and directories in \fIDIRECTORY\fR in a response body.
62 If \fIREGEXP\fR is present only matching files and directories are returned.
64 .B confirm \fICONFIRMATION
65 Confirm user registration.
66 \fICONFIRMATION\fR is as returned from \fBregister\fR below.
67 This command can be used without logging in.
70 Log a user back in using a cookie created with \fBmake\-cookie\fR.
71 The response contains the username.
73 .B deluser \fIUSERNAME
74 Delete the named user.
75 Requires the \fBadmin\fR right, and only works on local connections.
77 .B dirs \fIDIRECTORY\fR [\fIREGEXP\fR]
78 List all the directories in \fIDIRECTORY\fR in a response body.
79 If \fIREGEXP\fR is present only matching directories are returned.
81 .B disable \fR[\fBnow\fR]
82 Disable further playing.
83 If the optional \fBnow\fR argument is present then the current track
85 Requires the \fBglobal prefs\fR right.
87 .B edituser \fIUSERNAME PROPERTY VALUE
89 With the \fBadmin\fR right any username and property may be specified.
90 Otherwise the \fBuserinfo\fR right is required and only the
91 \fBemail\fR and \fBpassword\fR properties may be set.
93 User properties are syntax-checked before setting. For instance \fBemail\fR
94 must contain an "@" sign or you will get an error. (Setting an empty value for
95 \fBemail\fR is allowed and removes the property.)
98 Re-enable further playing, and is the opposite of \fBdisable\fR.
99 Requires the \fBglobal prefs\fR right.
102 Report whether playing is enabled.
103 The second field of the response line will be \fByes\fR or \fBno\fR.
105 .B exists \fITRACK\fR
106 Report whether the named track exists.
107 The second field of the response line will be \fByes\fR or \fBno\fR.
109 .B files \fIDIRECTORY\fR [\fIREGEXP\fR]
110 List all the files in \fIDIRECTORY\fR in a response body.
111 If \fIREGEXP\fR is present only matching files are returned.
113 .B get \fITRACK\fR \fIPREF\fR
114 Getsa preference value.
115 On success the second field of the response line will have the value.
117 If the track or preference do not exist then the response code is 555.
119 .B get\-global \fIKEY\fR
120 Get a global preference.
122 If the preference does not exist then the response code is 555.
124 .B length \fITRACK\fR
125 Get the length of the track in seconds.
126 On success the second field of the response line will have the value.
129 Send event log messages in a response body.
130 The command will never terminate.
131 Any further data sent to the server will be discarded (explicitly;
132 i.e. it will not accumulate in a buffer somewhere).
134 See \fBEVENT LOG\fR below for more details.
137 Returns an opaque string that can be used by the \fBcookie\fR command to log
138 this user back in on another connection (until the cookie expires).
140 .B move \fITRACK\fR \fIDELTA\fR
141 Move a track in the queue.
142 The track may be identified by ID (preferred) or name (which might cause
143 confusion if it's there twice).
144 \fIDELTA\fR should be an negative or positive integer and indicates how
145 many steps towards the head of the queue the track should be moved.
147 Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
148 depending on how the track came to be added to the queue.
150 .B moveafter \fITARGET\fR \fIID\fR ...
151 Move all the tracks in the \fIID\fR list after ID \fITARGET\fR.
152 If \fITARGET\fR is the empty string then the listed tracks are put
153 at the head of the queue.
154 If \fITARGET\fR is listed in the ID list then the tracks are moved
155 to just after the first non-listed track before it, or to the head if there is
158 Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
159 depending on how the tracks came to be added to the queue.
161 .B new \fR[\fIMAX\fR]
162 Send the most recently added \fIMAX\fR tracks in a response body.
163 If the argument is ommitted, the \fBnew_max\fR most recent tracks are
164 listed (see \fBdisorder_config\fR(5)).
170 as a keepalive measure.
171 This command does not require authentication.
173 .B part \fITRACK\fR \fICONTEXT\fI \fIPART\fR
174 Get a track name part.
175 Returns an empty string if a name part cannot be constructed.
191 Pause the current track.
192 Requires the \fBpause\fR right.
195 Add a track to the queue.
196 The response contains the queue ID of the track.
197 Requires the \fBplay\fR right.
200 Report what track is playing.
202 If the response is \fB252\fR then the rest of the response line consists of
203 track information (see below).
205 If the response is \fB259\fR then nothing is playing.
208 Send back the preferences for \fITRACK\fR in a response body.
209 Each line of the response has the usual line syntax, the first field being the
210 name of the pref and the second the value.
213 Send back the current queue in a response body, one track to a line, the track
214 at the head of the queue (i.e. next to be be played) first.
215 See below for the track information syntax.
218 Disable random play (but don't stop the current track).
219 Requires the \fBglobal prefs\fR right.
223 Requires the \fBglobal prefs\fR right.
226 Report whether random play is enabled.
227 The second field of the response line will be \fByes\fR or \fBno\fR.
230 Send back the current recently-played list in a response body, one track to a
231 line, the track most recently played last.
232 See below for the track information syntax.
235 Request that DisOrder reconfigure itself.
236 Requires the \fBadmin\fR right.
238 .B register \fIUSERNAME PASSWORD EMAIL
240 Requires the \fBregister\fR right.
241 The result contains a confirmation string; the user will be be able
242 to log in until this has been presented back to the server via the
243 \fBconfirm\fR command.
245 .B reminder \fIUSERNAME\fR
246 Send a password reminder to user \fIUSERNAME\fR.
247 If the user has no valid email address, or no password, or a
248 reminder has been sent too recently, then no reminder will be sent.
251 Remove the track identified by \fIID\fR.
252 Requires one of the \fBremove mine\fR, \fBremove random\fR or
253 \fBremove any\fR rights depending on how the
254 track came to be added to the queue.
256 .B rescan \fR[\fBwait\fR] \fR[\fBfresh\fR]
257 Rescan all roots for new or obsolete tracks.
258 Requires the \fBrescan\fR right.
260 If the \fBwait\fR flag is present then the response is delayed until the rescan
262 Otherwise the response arrives immediately.
263 This is primarily intended for testing.
265 If the \fBfresh\fR flag is present a rescan is already underway then a second
266 rescan will be started when it completes.
267 The default behavior is to piggyback on the existing rescan.
269 NB that \fBfresh\fR is currently disabled in the server source, so using this
270 flag will just provoke an error.
272 .B resolve \fITRACK\fR
273 Resolve a track name, i.e. if this is an alias then return the real track name.
276 Resume the current track after a \fBpause\fR command.
277 Requires the \fBpause\fR right.
279 .B revoke \fBcookie\fR
280 Revoke a cookie previously created with \fBmake\-cookie\fR.
281 It will not be possible to use this cookie in the future.
284 Report the RTP broadcast (or multicast) address, in the form \fIADDRESS
286 This command does not require authentication.
288 .B scratch \fR[\fIID\fR]
289 Remove the track identified by \fIID\fR, or the currently playing track if no
290 \fIID\fR is specified.
291 Requires one of the \fBscratch mine\fR, \fBscratch random\fR or
292 \fBscratch any\fR rights depending on how the track came to be
295 .B schedule-add \fIWHEN\fR \fIPRIORITY\fR \fIACTION\fR ...
296 Schedule an event for the future.
299 is the time when it should happen, as \fBtime_t\fR value.
300 It must refer to a time in the future.
303 is the event priority.
304 This can be \fBnormal\fR, in which case the event will be run at startup if its
305 time has past, or \fBjunk\fR in which case it will be discarded if it is found
306 to be in the past at startup.
307 The meaning of other values is not defined.
310 is the action to perform.
311 The choice of action determines the meaning of the remaining arguments.
312 Possible actions are:
317 The next argument is the track name.
318 Requires the \fBplay\fR right.
321 Set a global preference.
322 The next argument is the preference name and the final argument is the value to
323 set it to (omit it to unset it).
324 Requires the \fBglobal prefs\fR right.
327 You need the right at the point you create the event.
328 It is not possible to create scheduled events in expectation of a future change
331 .B schedule-del \fIEVENT\fR
332 Deletes a scheduled event.
333 Users can always delete their own scheduled events; with the \fBadmin\fR
334 right you can delete any event.
336 .B schedule-get \fIEVENT\fR
337 Sends the details of scheduled event \fIEVENT\fR in a response body.
338 Each line is a pair of strings quoted in the usual way, the first being the key
339 ane the second the value.
340 No particular order is used.
342 Scheduled events are considered public information.
343 Right \fBread\fR is sufficient to see details of all events.
346 Sends the event IDs of all scheduled events in a response body, in no
348 Use \fBschedule-get\fR to get the details of each event.
350 .B search \fITERMS\fR
351 Search for tracks matching the search terms.
352 The results are put in a response body, one to a line.
354 The search string is split in the usual way, with quoting supported, into a
356 Only tracks matching all terms are included in the results.
358 Any terms of the form \fBtag:\fITAG\fR limits the search to tracks with that
361 All other terms are interpreted as individual words which must be present in
364 Spaces in terms don't currently make sense, but may one day be interpreted to
365 allow searching for phrases.
367 .B \fBset\fR \fITRACK\fR \fIPREF\fR \fIVALUE\fR
369 Requires the \fBprefs\fR right.
371 .B set\-global \fIKEY\fR \fIVALUE\fR
372 Set a global preference.
373 Requires the \fBglobal prefs\fR right.
376 Send server statistics in plain text in a response body.
379 Send the list of currently known tags in a response body.
381 .B \fBunset\fR \fITRACK\fR \fIPREF\fR
383 Requires the \fBprefs\fR right.
385 .B \fBunset\-global\fR \fIKEY\fR
386 Unset a global preference.
387 Requires the \fBglobal prefs\fR right.
389 .B user \fIUSERNAME\fR \fIRESPONSE\fR
390 Authenticate as user \fIUSERNAME\fR.
395 .B userinfo \fIUSERNAME PROPERTY
399 Send the list of currently known users in a response body.
402 Send back a response with the server version as the second field.
404 .B volume \fR[\fILEFT\fR [\fIRIGHT\fR]]
405 Get or set the volume.
407 With zero parameters just gets the volume and reports the left and right sides
408 as the 2nd and 3rd fields of the response.
410 With one parameter sets both sides to the same value.
411 With two parameters sets each side independently.
412 Setting the volume requires the \fBvolume\fR right.
414 Responses are three-digit codes.
415 The first digit distinguishes errors from succesful responses:
423 The second digit breaks down the origin of the response:
426 Generic responses not specific to the handling of the command.
427 Mostly this is parse errors.
430 51x errors indicate that the user had insufficient rights for the command.
433 Authentication responses.
436 Responses specific to the handling of the command.
438 The third digit provides extra information about the response:
441 Text part is just commentary.
444 Text part is a constant result e.g. \fBversion\fR.
447 Text part is a potentially variable result.
450 Text part is just commentary; a dot-stuffed body follows.
453 Text part is just commentary; an indefinite dot-stuffed body follows.
454 (Used for \fBlog\fR.)
457 Used with "normal" errors, for instance a preference not being found.
458 The text part is commentary.
461 The text part is just commentary (but would normally be a response for this
462 command) e.g. \fBplaying\fR.
464 Result strings (not bodies) intended for machine parsing (i.e. xx1 and xx2
465 responses) are quoted.
467 When a connection is made the server sends a \fB231\fR response before any
469 This contains a protocol generation, an algorithm name and a
470 challenge encoded in hex, all separated by whitespace.
472 The current protocol generation is \fB2\fR.
474 The possible algorithms are (currently) \fBsha1\fR, \fBsha256\fR, \fBsha384\fR
476 \fBSHA1\fR etc work as synonyms.
478 The \fBuser\fR response consists of the selected hash of the user's password
479 concatenated with the challenge, encoded in hex.
480 .SH "TRACK INFORMATION"
481 Track information is encoded in a line (i.e. using the usual line syntax) as
483 The first is a name, the second a value.
484 The names have the following meanings:
487 The time the track is expected to be played at.
490 A string uniquely identifying this queue entry.
493 The time the track was played at.
496 The user that scratched the track.
499 The current track state.
504 The player failed (exited with nonzero status but wasn't scratched).
507 The track is actually a scratch.
510 No player could be found for the track.
513 The track was played without any problems.
516 The track was scratched.
519 The track is currently playing.
522 In the queue, hasn't been played yet.
525 The track was terminated because the server is shutting down.
529 The user that submitted the track.
532 The filename of the track.
535 The time the track was added to the queue.
538 The wait status of the player in decimal.
540 Times are decimal integers using the server's \fBtime_t\fR.
542 For file listings, the regexp applies to the basename of the returned file, not
543 the whole filename, and letter case is ignored.
544 \fBpcrepattern\fR(3) describes the regexp syntax.
546 Filenames are in UTF-8 even if the collection they come from uses some other
547 encoding - if you want to access the real file (in such cases as the filenames
548 actually correspond to a real file) you'll have to convert to whatever the
551 The event log consists of lines starting with a hexadecimal timestamp and a
552 keyword followed by (optionally) parameters.
553 The parameters are quoted in the usual DisOrder way.
554 Currently the following keywords are used:
556 .B completed \fITRACK\fR
557 Completed playing \fITRACK\fR
559 .B failed \fITRACK\fR \fIERROR\fR
560 Completed playing \fITRACK\fR with an error status
562 .B moved \fIUSERNAME\fR
563 User \fIUSERNAME\fR moved some track(s).
564 Further details aren't included any more.
566 .B playing \fITRACK\fR [\fIUSERNAME\fR]
567 Started playing \fITRACK\fR.
569 .B queue \fIQUEUE-ENTRY\fR...
570 Added \fITRACK\fR to the queue.
572 .B recent_added \fIQUEUE-ENTRY\fR...
573 Added \fIID\fR to the recently played list.
575 .B recent_removed \fIID\fR
576 Removed \fIID\fR from the recently played list.
578 .B removed \fIID\fR [\fIUSERNAME\fR]
579 Queue entry \fIID\fR was removed.
580 This is used both for explicit removal (when \fIUSERNAME\fR is present)
581 and when playing a track (when it is absent).
586 .B scratched \fITRACK\fR \fIUSERNAME\fR
587 \fITRACK\fR was scratched by \fIUSERNAME\fR.
589 .B state \fIKEYWORD\fR
590 Some state change occurred.
591 The current set of keywords is:
595 The current track completed successfully.
598 Playing was disabled.
601 Random play was disabled.
607 Random play was enabled.
610 The current track failed.
613 The current track was paused.
616 A track started playing.
619 The current track was resumed.
621 .B rights_changed \fIRIGHTS\fR
622 User's rights were changed.
625 The current track was scratched.
627 To simplify client implementation, \fBstate\fR commands reflecting the current
628 state are sent at the start of the log.
631 .B user_add \fIUSERNAME\fR
634 .B user_delete \fIUSERNAME\fR
637 .B user_edit \fIUSERNAME\fR \fIPROPERTY\fR
638 Some property of a user was edited.
640 .B user_confirm \fIUSERNAME\fR
641 A user's login was confirmed (via the web interface).
643 .B volume \fILEFT\fR \fIRIGHT\fR
648 .B "TRACK INFORMATION"
651 The \fBuser-*\fR messages are only sent to admin users, and are not sent over
652 non-local connections unless \fBremote_userman\fR is enabled.
653 .SH "CHARACTER ENCODING"
654 All data sent by both server and client is encoded using UTF-8.
655 Moreover it must be valid UTF-8, i.e. non-minimal sequences are not
656 permitted, nor are surrogates, nor are code points outside the
659 There are no particular normalization requirements on either side of the
661 The server currently converts internally to NFC, the client must
662 normalize the responses returned if it needs some normalized form for further
665 The various characters which divide up lines may not be followed by combining
667 For instance all of the following are prohibited:
670 LINE FEED followed by a combining character.
671 For example the sequence LINE FEED, COMBINING GRAVE ACCENT is never permitted.
674 APOSTROPHE or QUOTATION MARK followed by a combining character when used to
676 For instance a line starting APOSTROPHE, COMBINING CEDILLA is prohibited.
678 Note that such sequences are not prohibited when the quote character cannot be
679 interpreted as a field delimiter.
680 For instance APOSTROPHE, REVERSE SOLIDUS, APOSTROPHE, COMBINING CEDILLA,
681 APOSTROPHE would be permitted.
684 REVERSE SOLIDUS (BACKSLASH) followed by a combining character in a quoted
685 string when it is the first character of an escape sequence.
686 For instance a line starting APOSTROPHE, REVERSE SOLIDUS, COMBINING TILDE
689 As above such sequences are not prohibited when the character is not being used
690 to start an escape sequence.
691 For instance APOSTROPHE, REVERSE SOLIDUS, REVERSE SOLIDS, COMBINING TILDE,
692 APOSTROPHE is permitted.
695 Any of the field-splitting whitespace characters followed by a combining
696 character when not part of a quoted field.
697 For instance a line starting COLON, SPACE, COMBINING CANDRABINDU is prohibited.
699 As above non-delimiter uses are fine.
702 The FULL STOP characters used to quote or delimit a body.
704 Furthermore none of these characters are permitted to appear in the context of
705 a canonical decomposition (i.e. they must still be present when converted to
707 In practice however this is not an issue in Unicode 5.0.
709 These rules are consistent with the observation that the split() function is
710 essentially a naive ASCII parser.
711 The implication is not that these sequences never actually appear in
712 the protocol, merely that the server is not required to honor them in
713 any useful way nor be consistent between versions: in current
714 versions the result will be lines and fields that start with combining
715 characters and are not necessarily split where you expect, but future versions
716 may remove them, reject them or ignore some or all of the delimiters that have
717 following combining characters, and no notice will be given of any change.
723 \fBdisorder_config\fR(5),