NAME
disorder_protocol - DisOrder communication protocol
DESCRIPTION
The DisOrder client and server communicate via the protocol described
in this man page.
The protocol is liable to change without notice. You are recommended
to check the implementation before believing this document.
GENERAL SYNTAX
Everything is encoded using UTF-8. See CHARACTER ENCODING below for
more detail on character encoding issues.
Commands and responses consist of a line perhaps followed (depending on
the command or response) by a body.
The line syntax is the same as described in disorder_config(5) except
that comments are prohibited.
Bodies borrow their syntax from RFC821; they consist of zero or more
ordinary lines, with any initial full stop doubled up, and are termi-
nated by a line consisting of a full stop and a line feed.
COMMANDS
Commands always have a command name as the first field of the line;
responses always have a 3-digit response code as the first field. See
below for more details about this field.
All commands require the connection to have been already authenticated
unless stated otherwise. If not stated otherwise, the read right is
sufficient to execute the command.
Neither commands nor responses have a body unless stated otherwise.
adduser USERNAME PASSWORD [RIGHTS]
Create a new user with the given username and password. The new
user's rights list can be specified; if it is not then the
default_rights setting applies instead. Requires the admin
right, and only works on local connections.
allfiles DIRECTORY [REGEXP]
List all the files and directories in DIRECTORY in a response
body. If REGEXP is present only matching files and directories
are returned.
confirm CONFIRMATION
Confirm user registration. CONFIRMATION is as returned from
register below. This command can be used without logging in.
cookie COOKIE
Log a user back in using a cookie created with make-cookie. The
response contains the username.
deluser USERNAME
Delete the named user. Requires the admin right, and only works
on local connections.
dirs DIRECTORY [REGEXP]
List all the directories in DIRECTORY in a response body. If
REGEXP is present only matching directories are returned.
disable [now]
Disable further playing. If the optional now argument is
present then the current track is stopped. Requires the global
prefs right.
edituser USERNAME PROPERTY VALUE
Set a user property. With the admin right any username and
property may be specified. Otherwise the userinfo right is
required and only the email and password properties may be set.
User properties are syntax-checked before setting. For instance
email must contain an "@" sign or you will get an error. (Set-
ting an empty value for email is allowed and removes the prop-
erty.)
enable Re-enable further playing, and is the opposite of disable.
Requires the global prefs right.
enabled
Report whether playing is enabled. The second field of the
response line will be yes or no.
exists TRACK
Report whether the named track exists. The second field of the
response line will be yes or no.
files DIRECTORY [REGEXP]
List all the files in DIRECTORY in a response body. If REGEXP
is present only matching files are returned.
get TRACK PREF
Getsa preference value. On success the second field of the
response line will have the value.
If the track or preference do not exist then the response code
is 555.
get-global KEY
Get a global preference.
If the preference does not exist then the response code is 555.
length TRACK
Get the length of the track in seconds. On success the second
field of the response line will have the value.
log Send event log messages in a response body. The command will
never terminate. Any further data sent to the server will be
discarded (explicitly; i.e. it will not accumulate in a buffer
somewhere).
See EVENT LOG below for more details.
make-cookie
Returns an opaque string that can be used by the cookie command
to log this user back in on another connection (until the cookie
expires).
move TRACK DELTA
Move a track in the queue. The track may be identified by ID
(preferred) or name (which might cause confusion if it's there
twice). DELTA should be an negative or positive integer and
indicates how many steps towards the head of the queue the track
should be moved.
Requires one of the move mine, move random or move any rights
depending on how the track came to be added to the queue.
moveafter TARGET ID ...
Move all the tracks in the ID list after ID TARGET. If TARGET
is the empty string then the listed tracks are put at the head
of the queue. If TARGET is listed in the ID list then the
tracks are moved to just after the first non-listed track before
it, or to the head if there is no such track.
Requires one of the move mine, move random or move any rights
depending on how the tracks came to be added to the queue.
new [MAX]
Send the most recently added MAX tracks in a response body. If
the argument is ommitted, the new_max most recent tracks are
listed (see disorder_config(5)).
nop Do nothing. Used by disobedience(1) as a keepalive measure.
This command does not require authentication.
part TRACK CONTEXT PART
Get a track name part. Returns an empty string if a name part
cannot be constructed.
CONTEXT is one of sort or display and PART is usually one of
artist, album or title.
pause Pause the current track. Requires the pause right.
play TRACK
Add a track to the queue. The response contains the queue ID of
the track. Requires the play right.
playing
Report what track is playing.
If the response is 252 then the rest of the response line con-
sists of track information (see below).
If the response is 259 then nothing is playing.
prefs TRACK
Send back the preferences for TRACK in a response body. Each
line of the response has the usual line syntax, the first field
being the name of the pref and the second the value.
queue Send back the current queue in a response body, one track to a
line, the track at the head of the queue (i.e. next to be be
played) first. See below for the track information syntax.
random-disable
Disable random play (but don't stop the current track).
Requires the global prefs right.
random-enable
Enable random play. Requires the global prefs right.
random-enabled
Report whether random play is enabled. The second field of the
response line will be yes or no.
recent Send back the current recently-played list in a response body,
one track to a line, the track most recently played last. See
below for the track information syntax.
reconfigure
Request that DisOrder reconfigure itself. Requires the admin
right.
register USERNAME PASSWORD EMAIL
Register a new user. Requires the register right. The result
contains a confirmation string; the user will be be able to log
in until this has been presented back to the server via the con-
firm command.
reminder USERNAME
Send a password reminder to user USERNAME. If the user has no
valid email address, or no password, or a reminder has been sent
too recently, then no reminder will be sent.
remove ID
Remove the track identified by ID. Requires one of the remove
mine, remove random or remove any rights depending on how the
track came to be added to the queue.
rescan [wait] [fresh]
Rescan all roots for new or obsolete tracks. Requires the res-
can right.
If the wait flag is present then the response is delayed until
the rescan completes. Otherwise the response arrives immedi-
ately. This is primarily intended for testing.
If the fresh flag is present a rescan is already underway then a
second rescan will be started when it completes. The default
behavior is to piggyback on the existing rescan.
NB that fresh is currently disabled in the server source, so
using this flag will just provoke an error.
resolve TRACK
Resolve a track name, i.e. if this is an alias then return the
real track name.
resume Resume the current track after a pause command. Requires the
pause right.
revoke cookie
Revoke a cookie previously created with make-cookie. It will
not be possible to use this cookie in the future.
rtp-address
Report the RTP broadcast (or multicast) address, in the form
ADDRESS PORT. This command does not require authentication.
scratch [ID]
Remove the track identified by ID, or the currently playing
track if no ID is specified. Requires one of the scratch mine,
scratch random or scratch any rights depending on how the track
came to be added to the queue.
schedule-add WHEN PRIORITY ACTION ...
Schedule an event for the future.
WHEN is the time when it should happen, as time_t value. It
must refer to a time in the future.
PRIORITY is the event priority. This can be normal, in which
case the event will be run at startup if its time has past, or
junk in which case it will be discarded if it is found to be in
the past at startup. The meaning of other values is not
defined.
ACTION is the action to perform. The choice of action deter-
mines the meaning of the remaining arguments. Possible actions
are:
play Play a track. The next argument is the track name.
Requires the play right.
set-global
Set a global preference. The next argument is the pref-
erence name and the final argument is the value to set it
to (omit it to unset it). Requires the global prefs
right.
You need the right at the point you create the event. It is not
possible to create scheduled events in expectation of a future
change in rights.
schedule-del EVENT
Deletes a scheduled event. Users can always delete their own
scheduled events; with the admin right you can delete any event.
schedule-get EVENT
Sends the details of scheduled event EVENT in a response body.
Each line is a pair of strings quoted in the usual way, the
first being the key ane the second the value. No particular
order is used.
Scheduled events are considered public information. Right read
is sufficient to see details of all events.
schedule-list
Sends the event IDs of all scheduled events in a response body,
in no particular order. Use schedule-get to get the details of
each event.
search TERMS
Search for tracks matching the search terms. The results are
put in a response body, one to a line.
The search string is split in the usual way, with quoting sup-
ported, into a list of terms. Only tracks matching all terms
are included in the results.
Any terms of the form tag:TAG limits the search to tracks with
that tag.
All other terms are interpreted as individual words which must
be present in the track name.
Spaces in terms don't currently make sense, but may one day be
interpreted to allow searching for phrases.
set TRACK PREF VALUE
Set a preference. Requires the prefs right.
set-global KEY VALUE
Set a global preference. Requires the global prefs right.
stats Send server statistics in plain text in a response body.
tags Send the list of currently known tags in a response body.
unset TRACK PREF
Unset a preference. Requires the prefs right.
unset-global KEY
Unset a global preference. Requires the global prefs right.
user USERNAME RESPONSE
Authenticate as user USERNAME. See AUTHENTICATION below.
userinfo USERNAME PROPERTY
Get a user property.
users Send the list of currently known users in a response body.
version
Send back a response with the server version as the second
field.
volume [LEFT [RIGHT]]
Get or set the volume.
With zero parameters just gets the volume and reports the left
and right sides as the 2nd and 3rd fields of the response.
With one parameter sets both sides to the same value. With two
parameters sets each side independently. Setting the volume
requires the volume right.
RESPONSES
Responses are three-digit codes. The first digit distinguishes errors
from succesful responses:
2 Operation succeeded.
5 Operation failed.
The second digit breaks down the origin of the response:
0 Generic responses not specific to the handling of the command.
Mostly this is parse errors.
1 51x errors indicate that the user had insufficient rights for
the command.
3 Authentication responses.
5 Responses specific to the handling of the command.
The third digit provides extra information about the response:
0 Text part is just commentary.
1 Text part is a constant result e.g. version.
2 Text part is a potentially variable result.
3 Text part is just commentary; a dot-stuffed body follows.
4 Text part is just commentary; an indefinite dot-stuffed body
follows. (Used for log.)
5 Used with "normal" errors, for instance a preference not being
found. The text part is commentary.
9 The text part is just commentary (but would normally be a
response for this command) e.g. playing.
Result strings (not bodies) intended for machine parsing (i.e. xx1 and
xx2 responses) are quoted.
AUTHENTICATION
When a connection is made the server sends a 231 response before any
command is received. This contains a protocol generation, an algorithm
name and a challenge encoded in hex, all separated by whitespace.
The current protocol generation is 2.
The possible algorithms are (currently) sha1, sha256, sha384 and
sha512. SHA1 etc work as synonyms.
The user response consists of the selected hash of the user's password
concatenated with the challenge, encoded in hex.
TRACK INFORMATION
Track information is encoded in a line (i.e. using the usual line syn-
tax) as pairs of fields. The first is a name, the second a value. The
names have the following meanings:
expected The time the track is expected to be played at.
id A string uniquely identifying this queue entry.
played The time the track was played at.
scratched The user that scratched the track.
state The current track state. Valid states are:
failed The player failed (exited with nonzero status
but wasn't scratched).
isscratch The track is actually a scratch.
no_player No player could be found for the track.
ok The track was played without any problems.
scratched The track was scratched.
started The track is currently playing.
unplayed In the queue, hasn't been played yet.
quitting The track was terminated because the server is
shutting down.
submitter The user that submitted the track.
track The filename of the track.
when The time the track was added to the queue.
wstat The wait status of the player in decimal.
NOTES
Times are decimal integers using the server's time_t.
For file listings, the regexp applies to the basename of the returned
file, not the whole filename, and letter case is ignored. pcrepat-
tern(3) describes the regexp syntax.
Filenames are in UTF-8 even if the collection they come from uses some
other encoding - if you want to access the real file (in such cases as
the filenames actually correspond to a real file) you'll have to con-
vert to whatever the right encoding is.
EVENT LOG
The event log consists of lines starting with a hexadecimal timestamp
and a keyword followed by (optionally) parameters. The parameters are
quoted in the usual DisOrder way. Currently the following keywords are
used:
completed TRACK
Completed playing TRACK
failed TRACK ERROR
Completed playing TRACK with an error status
moved USERNAME
User USERNAME moved some track(s). Further details aren't
included any more.
playing TRACK [USERNAME]
Started playing TRACK.
queue QUEUE-ENTRY...
Added TRACK to the queue.
recent_added QUEUE-ENTRY...
Added ID to the recently played list.
recent_removed ID
Removed ID from the recently played list.
removed ID [USERNAME]
Queue entry ID was removed. This is used both for explicit
removal (when USERNAME is present) and when playing a track
(when it is absent).
rescanned
A rescan completed.
scratched TRACK USERNAME
TRACK was scratched by USERNAME.
state KEYWORD
Some state change occurred. The current set of keywords is:
completed
The current track completed successfully.
disable_play
Playing was disabled.
disable_random
Random play was disabled.
enable_play
Playing was enabled.
enable_random
Random play was enabled.
failed The current track failed.
pause The current track was paused.
playing
A track started playing.
resume The current track was resumed.
rights_changed RIGHTS
User's rights were changed.
scratched
The current track was scratched.
To simplify client implementation, state commands reflecting the
current state are sent at the start of the log.
user_add USERNAME A user was created.
user_delete USERNAME
A user was deleted.
user_edit USERNAME PROPERTY
Some property of a user was edited.
user_confirm USERNAME
A user's login was confirmed (via the web interface).
volume LEFT RIGHT
The volume changed.
QUEUE-ENTRY... is as defined in TRACK INFORMATION above.
The user-* messages are only sent to admin users, and are not sent over
non-local connections unless remote_userman is enabled.
CHARACTER ENCODING
All data sent by both server and client is encoded using UTF-8. More-
over it must be valid UTF-8, i.e. non-minimal sequences are not permit-
ted, nor are surrogates, nor are code points outside the Unicode code
space.
There are no particular normalization requirements on either side of
the protocol. The server currently converts internally to NFC, the
client must normalize the responses returned if it needs some normal-
ized form for further processing.
The various characters which divide up lines may not be followed by
combining characters. For instance all of the following are prohib-
ited:
o LINE FEED followed by a combining character. For example the
sequence LINE FEED, COMBINING GRAVE ACCENT is never permitted.
o APOSTROPHE or QUOTATION MARK followed by a combining character
when used to delimit fields. For instance a line starting APOS-
TROPHE, COMBINING CEDILLA is prohibited.
Note that such sequences are not prohibited when the quote char-
acter cannot be interpreted as a field delimiter. For instance
APOSTROPHE, REVERSE SOLIDUS, APOSTROPHE, COMBINING CEDILLA,
APOSTROPHE would be permitted.
o REVERSE SOLIDUS (BACKSLASH) followed by a combining character in
a quoted string when it is the first character of an escape
sequence. For instance a line starting APOSTROPHE, REVERSE
SOLIDUS, COMBINING TILDE is prohibited.
As above such sequences are not prohibited when the character is
not being used to start an escape sequence. For instance APOS-
TROPHE, REVERSE SOLIDUS, REVERSE SOLIDS, COMBINING TILDE, APOS-
TROPHE is permitted.
o Any of the field-splitting whitespace characters followed by a
combining character when not part of a quoted field. For
instance a line starting COLON, SPACE, COMBINING CANDRABINDU is
prohibited.
As above non-delimiter uses are fine.
o The FULL STOP characters used to quote or delimit a body.
Furthermore none of these characters are permitted to appear in the
context of a canonical decomposition (i.e. they must still be present
when converted to NFC). In practice however this is not an issue in
Unicode 5.0.
These rules are consistent with the observation that the split() func-
tion is essentially a naive ASCII parser. The implication is not that
these sequences never actually appear in the protocol, merely that the
server is not required to honor them in any useful way nor be consis-
tent between versions: in current versions the result will be lines and
fields that start with combining characters and are not necessarily
split where you expect, but future versions may remove them, reject
them or ignore some or all of the delimiters that have following
combining characters, and no notice will be given of any change.
SEE ALSO
disorder(1), time(2), disorder(3), pcrepattern(3) disorder_config(5),
disorderd(8), utf8(7)