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
61 Adopts a randomly picked track, leaving it in a similar state to if it was
62 picked by this user. Requires the \fBplay\fR right.
64 .B allfiles \fIDIRECTORY\fR [\fIREGEXP\fR]
65 List all the files and directories in \fIDIRECTORY\fR in a response body.
66 If \fIREGEXP\fR is present only matching files and directories are returned.
68 .B confirm \fICONFIRMATION
69 Confirm user registration.
70 \fICONFIRMATION\fR is as returned from \fBregister\fR below.
71 This command can be used without logging in.
74 Log a user back in using a cookie created with \fBmake\-cookie\fR.
75 The response contains the username.
77 .B deluser \fIUSERNAME
78 Delete the named user.
79 Requires the \fBadmin\fR right, and only works on local connections.
81 .B dirs \fIDIRECTORY\fR [\fIREGEXP\fR]
82 List all the directories in \fIDIRECTORY\fR in a response body.
83 If \fIREGEXP\fR is present only matching directories are returned.
85 .B disable \fR[\fBnow\fR]
86 Disable further playing.
87 If the optional \fBnow\fR argument is present then the current track
89 Requires the \fBglobal prefs\fR right.
91 .B edituser \fIUSERNAME PROPERTY VALUE
93 With the \fBadmin\fR right any username and property may be specified.
94 Otherwise the \fBuserinfo\fR right is required and only the
95 \fBemail\fR and \fBpassword\fR properties may be set.
97 User properties are syntax-checked before setting. For instance \fBemail\fR
98 must contain an "@" sign or you will get an error. (Setting an empty value for
99 \fBemail\fR is allowed and removes the property.)
102 Re-enable further playing, and is the opposite of \fBdisable\fR.
103 Requires the \fBglobal prefs\fR right.
106 Report whether playing is enabled.
107 The second field of the response line will be \fByes\fR or \fBno\fR.
109 .B exists \fITRACK\fR
110 Report whether the named track exists.
111 The second field of the response line will be \fByes\fR or \fBno\fR.
113 .B files \fIDIRECTORY\fR [\fIREGEXP\fR]
114 List all the files in \fIDIRECTORY\fR in a response body.
115 If \fIREGEXP\fR is present only matching files are returned.
117 .B get \fITRACK\fR \fIPREF\fR
118 Getsa preference value.
119 On success the second field of the response line will have the value.
121 If the track or preference do not exist then the response code is 555.
123 .B get\-global \fIKEY\fR
124 Get a global preference.
126 If the preference does not exist then the response code is 555.
128 .B length \fITRACK\fR
129 Get the length of the track in seconds.
130 On success the second field of the response line will have the value.
133 Send event log messages in a response body.
134 The command will never terminate.
135 Any further data sent to the server will be discarded (explicitly;
136 i.e. it will not accumulate in a buffer somewhere).
138 See \fBEVENT LOG\fR below for more details.
141 Returns an opaque string that can be used by the \fBcookie\fR command to log
142 this user back in on another connection (until the cookie expires).
144 .B move \fITRACK\fR \fIDELTA\fR
145 Move a track in the queue.
146 The track may be identified by ID (preferred) or name (which might cause
147 confusion if it's there twice).
148 \fIDELTA\fR should be an negative or positive integer and indicates how
149 many steps towards the head of the queue the track should be moved.
151 Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
152 depending on how the track came to be added to the queue.
154 .B moveafter \fITARGET\fR \fIID\fR ...
155 Move all the tracks in the \fIID\fR list after ID \fITARGET\fR.
156 If \fITARGET\fR is the empty string then the listed tracks are put
157 at the head of the queue.
158 If \fITARGET\fR is listed in the ID list then the tracks are moved
159 to just after the first non-listed track before it, or to the head if there is
162 Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
163 depending on how the tracks came to be added to the queue.
165 .B new \fR[\fIMAX\fR]
166 Send the most recently added \fIMAX\fR tracks in a response body.
167 If the argument is ommitted, the \fBnew_max\fR most recent tracks are
168 listed (see \fBdisorder_config\fR(5)).
174 as a keepalive measure.
175 This command does not require authentication.
177 .B part \fITRACK\fR \fICONTEXT\fI \fIPART\fR
178 Get a track name part.
179 Returns an empty string if a name part cannot be constructed.
195 Pause the current track.
196 Requires the \fBpause\fR right.
199 Add a track to the queue.
200 The response contains the queue ID of the track.
201 Requires the \fBplay\fR right.
204 Report what track is playing.
206 If the response is \fB252\fR then the rest of the response line consists of
207 track information (see below).
209 If the response is \fB259\fR then nothing is playing.
212 Send back the preferences for \fITRACK\fR in a response body.
213 Each line of the response has the usual line syntax, the first field being the
214 name of the pref and the second the value.
217 Send back the current queue in a response body, one track to a line, the track
218 at the head of the queue (i.e. next to be be played) first.
219 See below for the track information syntax.
222 Disable random play (but don't stop the current track).
223 Requires the \fBglobal prefs\fR right.
227 Requires the \fBglobal prefs\fR right.
230 Report whether random play is enabled.
231 The second field of the response line will be \fByes\fR or \fBno\fR.
234 Send back the current recently-played list in a response body, one track to a
235 line, the track most recently played last.
236 See below for the track information syntax.
239 Request that DisOrder reconfigure itself.
240 Requires the \fBadmin\fR right.
242 Not all configuration options can be modified during the lifetime of the
243 server; of those that can't, some will just be ignored if they change while
244 others will cause the new configuration to be rejected.
245 See \fBdisorder_config\fR(5) for details.
247 .B register \fIUSERNAME PASSWORD EMAIL
249 Requires the \fBregister\fR right.
250 The result contains a confirmation string; the user will be be able
251 to log in until this has been presented back to the server via the
252 \fBconfirm\fR command.
254 .B reminder \fIUSERNAME\fR
255 Send a password reminder to user \fIUSERNAME\fR.
256 If the user has no valid email address, or no password, or a
257 reminder has been sent too recently, then no reminder will be sent.
260 Remove the track identified by \fIID\fR.
261 Requires one of the \fBremove mine\fR, \fBremove random\fR or
262 \fBremove any\fR rights depending on how the
263 track came to be added to the queue.
265 .B rescan \fR[\fBwait\fR] \fR[\fBfresh\fR]
266 Rescan all roots for new or obsolete tracks.
267 Requires the \fBrescan\fR right.
269 If the \fBwait\fR flag is present then the response is delayed until the rescan
271 Otherwise the response arrives immediately.
272 This is primarily intended for testing.
274 If the \fBfresh\fR flag is present a rescan is already underway then a second
275 rescan will be started when it completes.
276 The default behavior is to piggyback on the existing rescan.
278 NB that \fBfresh\fR is currently disabled in the server source, so using this
279 flag will just provoke an error.
281 .B resolve \fITRACK\fR
282 Resolve a track name, i.e. if this is an alias then return the real track name.
285 Resume the current track after a \fBpause\fR command.
286 Requires the \fBpause\fR right.
288 .B revoke \fBcookie\fR
289 Revoke a cookie previously created with \fBmake\-cookie\fR.
290 It will not be possible to use this cookie in the future.
293 Report the RTP broadcast (or multicast) address, in the form \fIADDRESS
295 This command does not require authentication.
297 .B scratch \fR[\fIID\fR]
298 Remove the track identified by \fIID\fR, or the currently playing track if no
299 \fIID\fR is specified.
300 Requires one of the \fBscratch mine\fR, \fBscratch random\fR or
301 \fBscratch any\fR rights depending on how the track came to be
304 .B schedule-add \fIWHEN\fR \fIPRIORITY\fR \fIACTION\fR ...
305 Schedule an event for the future.
308 is the time when it should happen, as \fBtime_t\fR value.
309 It must refer to a time in the future.
312 is the event priority.
313 This can be \fBnormal\fR, in which case the event will be run at startup if its
314 time has past, or \fBjunk\fR in which case it will be discarded if it is found
315 to be in the past at startup.
316 The meaning of other values is not defined.
319 is the action to perform.
320 The choice of action determines the meaning of the remaining arguments.
321 Possible actions are:
326 The next argument is the track name.
327 Requires the \fBplay\fR right.
330 Set a global preference.
331 The next argument is the preference name and the final argument is the value to
332 set it to (omit it to unset it).
333 Requires the \fBglobal prefs\fR right.
336 You need the right at the point you create the event.
337 It is not possible to create scheduled events in expectation of a future change
340 .B schedule-del \fIEVENT\fR
341 Deletes a scheduled event.
342 Users can always delete their own scheduled events; with the \fBadmin\fR
343 right you can delete any event.
345 .B schedule-get \fIEVENT\fR
346 Sends the details of scheduled event \fIEVENT\fR in a response body.
347 Each line is a pair of strings quoted in the usual way, the first being the key
348 ane the second the value.
349 No particular order is used.
351 Scheduled events are considered public information.
352 Right \fBread\fR is sufficient to see details of all events.
355 Sends the event IDs of all scheduled events in a response body, in no
357 Use \fBschedule-get\fR to get the details of each event.
359 .B search \fITERMS\fR
360 Search for tracks matching the search terms.
361 The results are put in a response body, one to a line.
363 The search string is split in the usual way, with quoting supported, into a
365 Only tracks matching all terms are included in the results.
367 Any terms of the form \fBtag:\fITAG\fR limits the search to tracks with that
370 All other terms are interpreted as individual words which must be present in
373 Spaces in terms don't currently make sense, but may one day be interpreted to
374 allow searching for phrases.
376 .B \fBset\fR \fITRACK\fR \fIPREF\fR \fIVALUE\fR
378 Requires the \fBprefs\fR right.
380 .B set\-global \fIKEY\fR \fIVALUE\fR
381 Set a global preference.
382 Requires the \fBglobal prefs\fR right.
385 Send server statistics in plain text in a response body.
388 Send the list of currently known tags in a response body.
390 .B \fBunset\fR \fITRACK\fR \fIPREF\fR
392 Requires the \fBprefs\fR right.
394 .B \fBunset\-global\fR \fIKEY\fR
395 Unset a global preference.
396 Requires the \fBglobal prefs\fR right.
398 .B user \fIUSERNAME\fR \fIRESPONSE\fR
399 Authenticate as user \fIUSERNAME\fR.
404 .B userinfo \fIUSERNAME PROPERTY
408 Send the list of currently known users in a response body.
411 Send back a response with the server version as the second field.
413 .B volume \fR[\fILEFT\fR [\fIRIGHT\fR]]
414 Get or set the volume.
416 With zero parameters just gets the volume and reports the left and right sides
417 as the 2nd and 3rd fields of the response.
419 With one parameter sets both sides to the same value.
420 With two parameters sets each side independently.
421 Setting the volume requires the \fBvolume\fR right.
423 Responses are three-digit codes.
424 The first digit distinguishes errors from succesful responses:
432 The second digit breaks down the origin of the response:
435 Generic responses not specific to the handling of the command.
436 Mostly this is parse errors.
439 51x errors indicate that the user had insufficient rights for the command.
442 Authentication responses.
445 Responses specific to the handling of the command.
447 The third digit provides extra information about the response:
450 Text part is just commentary.
453 Text part is a constant result e.g. \fBversion\fR.
456 Text part is a potentially variable result.
459 Text part is just commentary; a dot-stuffed body follows.
462 Text part is just commentary; an indefinite dot-stuffed body follows.
463 (Used for \fBlog\fR.)
466 Used with "normal" errors, for instance a preference not being found.
467 The text part is commentary.
470 The text part is just commentary (but would normally be a response for this
471 command) e.g. \fBplaying\fR.
473 Result strings (not bodies) intended for machine parsing (i.e. xx1 and xx2
474 responses) are quoted.
476 When a connection is made the server sends a \fB231\fR response before any
478 This contains a protocol generation, an algorithm name and a
479 challenge encoded in hex, all separated by whitespace.
481 The current protocol generation is \fB2\fR.
483 The possible algorithms are (currently) \fBsha1\fR, \fBsha256\fR, \fBsha384\fR
485 \fBSHA1\fR etc work as synonyms.
487 The \fBuser\fR response consists of the selected hash of the user's password
488 concatenated with the challenge, encoded in hex.
489 .SH "TRACK INFORMATION"
490 Track information is encoded in a line (i.e. using the usual line syntax) as
492 The first is a name, the second a value.
493 The names have the following meanings:
496 The time the track is expected to be played at.
499 A string uniquely identifying this queue entry.
502 The time the track was played at.
505 The user that scratched the track.
508 The origin of the track. Valid origins are:
512 The track was originally randomly picked but has been adopted by a user.
515 The track was picked by a user.
518 The track was randomly picked.
521 The track was played from a scheduled action.
524 The track is a scratch sound.
528 The current track state.
533 The player failed (exited with nonzero status but wasn't scratched).
536 The track was played without any problems.
539 The track was scratched.
542 The track is currently playing.
545 Track is playing but paused.
548 In the queue, hasn't been played yet.
551 The track was terminated because the server is shutting down.
555 The user that submitted the track.
558 The filename of the track.
561 The time the track was added to the queue.
564 The wait status of the player in decimal.
566 Note that \fBorigin\fR is new with DisOrder 4.3, and obsoletes some old
569 Times are decimal integers using the server's \fBtime_t\fR.
571 For file listings, the regexp applies to the basename of the returned file, not
572 the whole filename, and letter case is ignored.
573 \fBpcrepattern\fR(3) describes the regexp syntax.
575 Filenames are in UTF-8 even if the collection they come from uses some other
576 encoding - if you want to access the real file (in such cases as the filenames
577 actually correspond to a real file) you'll have to convert to whatever the
580 The event log consists of lines starting with a hexadecimal timestamp and a
581 keyword followed by (optionally) parameters.
582 The parameters are quoted in the usual DisOrder way.
583 Currently the following keywords are used:
585 .B adopted \fIID\fR \fIUSERNAME\fR
586 \fIUSERNAME\fR adopted track \fIID\fR.
588 .B completed \fITRACK\fR
589 Completed playing \fITRACK\fR
591 .B failed \fITRACK\fR \fIERROR\fR
592 Completed playing \fITRACK\fR with an error status
594 .B moved \fIUSERNAME\fR
595 User \fIUSERNAME\fR moved some track(s).
596 Further details aren't included any more.
598 .B playing \fITRACK\fR [\fIUSERNAME\fR]
599 Started playing \fITRACK\fR.
601 .B queue \fIQUEUE-ENTRY\fR...
602 Added \fITRACK\fR to the queue.
604 .B recent_added \fIQUEUE-ENTRY\fR...
605 Added \fIID\fR to the recently played list.
607 .B recent_removed \fIID\fR
608 Removed \fIID\fR from the recently played list.
610 .B removed \fIID\fR [\fIUSERNAME\fR]
611 Queue entry \fIID\fR was removed.
612 This is used both for explicit removal (when \fIUSERNAME\fR is present)
613 and when playing a track (when it is absent).
618 .B scratched \fITRACK\fR \fIUSERNAME\fR
619 \fITRACK\fR was scratched by \fIUSERNAME\fR.
621 .B state \fIKEYWORD\fR
622 Some state change occurred.
623 The current set of keywords is:
627 The current track completed successfully.
630 Playing was disabled.
633 Random play was disabled.
639 Random play was enabled.
642 The current track failed.
645 The current track was paused.
648 A track started playing.
651 The current track was resumed.
653 .B rights_changed \fIRIGHTS\fR
654 User's rights were changed.
657 The current track was scratched.
659 To simplify client implementation, \fBstate\fR commands reflecting the current
660 state are sent at the start of the log.
663 .B user_add \fIUSERNAME\fR
666 .B user_delete \fIUSERNAME\fR
669 .B user_edit \fIUSERNAME\fR \fIPROPERTY\fR
670 Some property of a user was edited.
672 .B user_confirm \fIUSERNAME\fR
673 A user's login was confirmed (via the web interface).
675 .B volume \fILEFT\fR \fIRIGHT\fR
680 .B "TRACK INFORMATION"
683 The \fBuser-*\fR messages are only sent to admin users, and are not sent over
684 non-local connections unless \fBremote_userman\fR is enabled.
685 .SH "CHARACTER ENCODING"
686 All data sent by both server and client is encoded using UTF-8.
687 Moreover it must be valid UTF-8, i.e. non-minimal sequences are not
688 permitted, nor are surrogates, nor are code points outside the
691 There are no particular normalization requirements on either side of the
693 The server currently converts internally to NFC, the client must
694 normalize the responses returned if it needs some normalized form for further
697 The various characters which divide up lines may not be followed by combining
699 For instance all of the following are prohibited:
702 LINE FEED followed by a combining character.
703 For example the sequence LINE FEED, COMBINING GRAVE ACCENT is never permitted.
706 APOSTROPHE or QUOTATION MARK followed by a combining character when used to
708 For instance a line starting APOSTROPHE, COMBINING CEDILLA is prohibited.
710 Note that such sequences are not prohibited when the quote character cannot be
711 interpreted as a field delimiter.
712 For instance APOSTROPHE, REVERSE SOLIDUS, APOSTROPHE, COMBINING CEDILLA,
713 APOSTROPHE would be permitted.
716 REVERSE SOLIDUS (BACKSLASH) followed by a combining character in a quoted
717 string when it is the first character of an escape sequence.
718 For instance a line starting APOSTROPHE, REVERSE SOLIDUS, COMBINING TILDE
721 As above such sequences are not prohibited when the character is not being used
722 to start an escape sequence.
723 For instance APOSTROPHE, REVERSE SOLIDUS, REVERSE SOLIDS, COMBINING TILDE,
724 APOSTROPHE is permitted.
727 Any of the field-splitting whitespace characters followed by a combining
728 character when not part of a quoted field.
729 For instance a line starting COLON, SPACE, COMBINING CANDRABINDU is prohibited.
731 As above non-delimiter uses are fine.
734 The FULL STOP characters used to quote or delimit a body.
736 Furthermore none of these characters are permitted to appear in the context of
737 a canonical decomposition (i.e. they must still be present when converted to
739 In practice however this is not an issue in Unicode 5.0.
741 These rules are consistent with the observation that the split() function is
742 essentially a naive ASCII parser.
743 The implication is not that these sequences never actually appear in
744 the protocol, merely that the server is not required to honor them in
745 any useful way nor be consistent between versions: in current
746 versions the result will be lines and fields that start with combining
747 characters and are not necessarily split where you expect, but future versions
748 may remove them, reject them or ignore some or all of the delimiters that have
749 following combining characters, and no notice will be given of any change.
755 \fBdisorder_config\fR(5),