Difference between revisions of "Channel Viewer Protocol"

From Mumble Wiki
Jump to: navigation, search
(User format: add oauth to "how to auth" notes...)
(add info about how the address field is to be handled)
Line 30: Line 30:
 
easily usable as possible. Servers must set their encoding headers correctly to
 
easily usable as possible. Servers must set their encoding headers correctly to
 
prevent encoding issues.
 
prevent encoding issues.
 +
 +
=== The Address field ===
 +
 +
The address field in the user records requires special attention for multiple reasons.
 +
 +
*  To respect users' privacy, user records should generally not contain the address
 +
  if the request does not provide any means of authentication. What kind of
 +
  authentication the client needs to provide is a bit hard to say; a compromise
 +
  between security and ease of implementation (both client- and server side) is to
 +
  accept both...
 +
** the standard authentication means of the platform the server is implemented in;
 +
  that means if your server implementation uses a web framework, its built-in
 +
  authentication (e.g. through cookies) should be accepted,
 +
** HTTP Basic auth if no other authentication data has been provided, to enable
 +
  non-web-based clients to retrieve the address information if they need to.
 +
*  To ease client implementation, the server should set the "x-addrstr" field
 +
  to a string that contains either...
 +
** a fully qualified domain name: "somewhere.example.com",
 +
** an IPv4 address in dotted quad notation: "192.168.0.1",
 +
** an IPv6 address in colon notation: "2001:6f8:108f:1:21f:3cff:wx:yz"
 +
 +
Note however that in most cases, the users' addresses will not even be needed by the
 +
client, so most of this shouldn't even apply to most clients.
 +
 +
If a server does not support delivering users' addresses at all, it should just ignore
 +
any authentication data the client may have sent.
 +
  
 
== Example Channel tree ==
 
== Example Channel tree ==

Revision as of 17:36, 11 May 2010

People often wish to have a view on their Mumble servers without needing to actually run the client. This is mostly accomplished using a web based channel viewer which retrieves channel and user data from a web server, which in turn queries it from Murmur, and then using techniques like JavaScript to render that data into a nice tree structure.

As multiple channel viewers start to arise, developers found the consensus that using a standardized format for data retrieval yields multiple advantages, the most important of which is interoperability: The need for using a specific server and viewer does not arise when all servers and viewers use a shared data format, thus allowing for both parts to be exchanged easily and independent from one another.

General notes

The data format should generally be aimed towards delivering information retrieved from Murmur unaltered. That means that any field that exists in Murmur should be exposed by the server (unless there is a really good reason not to do so, like for passwords and the like), and it should not alter any fields that exist in Murmur to prevent confusion.

If the implementer of the protocol chooses to add extra information that does not originate from Murmur itself, these fields should be prefixed with "x-" in order to prevent name clashes (so for example, a custom field named "coolstuff" should be named "x-coolstuff" instead).

If a client encounters a field which it does not understand, it must ignore that field.

The documents, be it JSON or XML, should be encoded in UTF-8 in order to be as easily usable as possible. Servers must set their encoding headers correctly to prevent encoding issues.

The Address field

The address field in the user records requires special attention for multiple reasons.

  • To respect users' privacy, user records should generally not contain the address
  if the request does not provide any means of authentication. What kind of
  authentication the client needs to provide is a bit hard to say; a compromise
  between security and ease of implementation (both client- and server side) is to
  accept both...
    • the standard authentication means of the platform the server is implemented in;
  that means if your server implementation uses a web framework, its built-in
  authentication (e.g. through cookies) should be accepted,
    • HTTP Basic auth if no other authentication data has been provided, to enable
  non-web-based clients to retrieve the address information if they need to.
  • To ease client implementation, the server should set the "x-addrstr" field
  to a string that contains either...
    • a fully qualified domain name: "somewhere.example.com",
    • an IPv4 address in dotted quad notation: "192.168.0.1",
    • an IPv6 address in colon notation: "2001:6f8:108f:1:21f:3cff:wx:yz"

Note however that in most cases, the users' addresses will not even be needed by the client, so most of this shouldn't even apply to most clients.

If a server does not support delivering users' addresses at all, it should just ignore any authentication data the client may have sent.


Example Channel tree

All examples are based on the following channel structure:

  • test server
    • newtesting
    • testing
      • htmlsubtesting - This channel has HTML elements in its description
        • subsubtesting
      • plainsubtesting - This channel has HTML elements in its description which are escaped and should NOT be evaluated
        • subsubtesting


JSON

To expose the full channel tree using JSON, start with the root channel and recursively add the users and data to it.

In order to make cross-site requests easier, the server must implement JSONP. The name for the request parameter that holds the callback name must be "jsonp_callback".

Server format

The root object of the tree must always be the server itself, which has the following properties:

'id': 1,             // The ID of this server instance
'name': 'some name', // The server's name
'root': {...},       // The root channel object

And may optionally have:

'x-connecturl': 'mumble://somewhere/'

Channel format

A Channel entry must at least contain the following fields:

'description': ,
'id': 0,
'links': [],         // A list of IDs that name linked channels
'name': 'Root',
'parent': -1,
'users': [],         // A list of users in this channel
'position': 0,
'channels': [],      // A list of subchannels
'temporary': False

And may optionally contain:

'x-connecturl': 'mumble://somewhere/somechannel'

User format

A User entry must at least contain the following fields:

'channel': 40,
'deaf': False,
'mute': False,
'name': 'Yps0',
'selfDeaf': False,
'selfMute': False,
'session': 143,
'suppress': False,
'userid': 4,

And may optionally contain:

'address': (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 192, 168, 0, 10),
'x-addrstring': '192.168.0.10',           // A nicely formatted version of the IP address (hostname, dotted quad, IPv6 notation)
'bytespersec': 6580,
'comment': ,
'context': ,
'identity': ,
'idlesecs': 0,
'onlinesecs': 161,
'os': 'Win',
'osversion': '5.1.2600.1',
'prioritySpeaker': False,
'release': '02071e',
'tcponly': False,
'x-texture': '/mumble/1/4/texture.png',   // A URL to retrieve the texture/avatar from
'version': 66051

Which fields to expose may depend on the user of the channel viewer, e.g. the IP adress may be shown to certain logged-in users only.

Which reminds me: how to auth? http basic auth, cookies? if cookies, where to get them
from? (Trivial for web based clients, but not for others like a mobile app)
Rul0r solution would be oauth, but that's not quite trivial to implement :/

Full Example

Serializing the aforementioned channel structure as JSON, we will get:

{'id': 1,
 'name': u'test server',
 'root': {'channels': [{'channels': [],
                       'description': ,
                       'id': 6,
                       'links': [],
                       'name': 'newtesting',
                       'parent': 0,
                       'position': 0,
                       'temporary': False,
                       'users': [],
                       'x-connecturl': u'mumble://kuunavang.funzt-halt.net/newtesting?version=1.2.2'},
                      {'channels': [{'channels': [{'channels': [],
                                                   'description': ,
                                                   'id': 5,
                                                   'links': [],
                                                   'name': 'subsubtesting',
                                                   'parent': 4,
                                                   'position': 0,
                                                   'temporary': False,
                                                   'users': [],
                                                   'x-connecturl': u'mumble://kuunavang.funzt-halt.net/testing/htmlsubtesting/subsubtesting?version=1.2.2'}],
                                     'description': 'This channel has HTML elements in its description that are evaluated as red bold Fonts!',
                                     'id': 4,
                                     'links': [2],
                                     'name': 'htmlsubtesting',
                                     'parent': 1,
                                     'position': 0,
                                     'temporary': False,
                                     'users': [{'address': [32, 1, 6, 248, 16, 143, 0, 1, 2, 31, 60, 255, w, x, y, z],
                                                'bytespersec': 0,
                                                'channel': 4,
                                                'comment': ,
                                                'context': ,
                                                'deaf': False,
                                                'identity': ,
                                                'idlesecs': 575,
                                                'mute': False,
                                                'name': 'svedrin',
                                                'onlinesecs': 1186,
                                                'os': 'X11',
                                                'osversion': 'Debian GNU/Linux unstable (sid)',
                                                'release': '1.2.2-2',
                                                'selfDeaf': False,
                                                'selfMute': False,
                                                'session': 7,
                                                'suppress': False,
                                                'tcponly': False,
                                                'userid': 1,
                                                'version': 66050,
                                                'x-addrstring': '2001:6f8:108f:1:21f:3cff:wx:yz'}],
                                     'x-connecturl': u'mumble://kuunavang.funzt-halt.net/testing/htmlsubtesting?version=1.2.2'},
                                    {'channels': [{'channels': [],
                                                   'description': ,
                                                   'id': 3,
                                                   'links': [],
                                                   'name': 'subsubtesting',
                                                   'parent': 2,
                                                   'position': 0,
                                                   'temporary': False,
                                                   'users': [],
                                                   'x-connecturl': u'mumble://kuunavang.funzt-halt.net/testing/plainsubtesting/subsubtesting?version=1.2.2'}],
                                     'description': 'This channel has <i>HTML</i> elements in its description that are not evaluated as <span style="color: red">red <b>bold</b></span> Fonts!',
                                     'id': 2,
                                     'links': [4],
                                     'name': 'plainsubtesting',
                                     'parent': 1,
                                     'position': 0,
                                     'temporary': False,
                                     'users': [],
                                     'x-connecturl': u'mumble://kuunavang.funzt-halt.net/testing/plainsubtesting?version=1.2.2'}],
                       'description': ,
                       'id': 1,
                       'links': [],
                       'name': 'testing',
                       'parent': 0,
                       'position': 0,
                       'temporary': False,
                       'users': [],
                       'x-connecturl': u'mumble://kuunavang.funzt-halt.net/testing?version=1.2.2'}],
         'description': ,
         'id': 0,
         'links': [],
         'name': 'Root',
         'parent': -1,
         'position': 0,
         'temporary': False,
         'users': [],
         'x-connecturl': u'mumble://kuunavang.funzt-halt.net?version=1.2.2'},
'x-connecturl': u'mumble://kuunavang.funzt-halt.net?version=1.2.2'}

XML

For XML, the same principles apply as for JSON, along with the following encoding principles:

  • Boolean values are represented as "true" or "false"
  • Lists (e.g. for the players' IP addresses or the channel links) are comma-separated numbers

Server Format

A server is represented using the <server /> tag.

Channel Format

A channel is represented using the <channel /> tag.

User Format

A user is represented using the <user /> tag.

Full Example

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<server
 id="1"
 name="test server"
 x-connecturl="mumble://kuunavang.funzt-halt.net?version=1.2.2">
  <channel
   description=""
   id="0"
   links=""
   name="Root"
   parent="-1"
   position="0"
   temporary="false"
   x-connecturl="mumble://kuunavang.funzt-halt.net?version=1.2.2">
    <channel
     description=""
     id="6"
     links=""
     name="newtesting"
     parent="0"
     position="0"
     temporary="false"
     x-connecturl="mumble://kuunavang.funzt-halt.net/newtesting?version=1.2.2" />
    <channel
     description=""
     id="1"
     links=""
     name="testing"
     parent="0"
     position="0"
     temporary="false"
     x-connecturl="mumble://kuunavang.funzt-halt.net/testing?version=1.2.2">
      <channel
       description="This channel has <i>HTML</i> elements in its description that are evaluated as <span style=&quot;color:#ff0000&quot;>red </span><b><span style=&quot;color:#ff0000&quot;>bold</span></b> Fonts!"
       id="4"
       links="2"
       name="htmlsubtesting"
       parent="1"
       position="0"
       temporary="false"
       x-connecturl="mumble://kuunavang.funzt-halt.net/testing/htmlsubtesting?version=1.2.2">
        <channel
         description=""
         id="5"
         links=""
         name="subsubtesting"
         parent="4"
         position="0"
         temporary="false"
         x-connecturl="mumble://kuunavang.funzt-halt.net/testing/htmlsubtesting/subsubtesting?version=1.2.2" />
        <user
         address="32,1,6,248,16,143,0,1,2,31,60,255,w,x,y,z"
         bytespersec="0"
         channel="4"
         comment=""
         context=""
         deaf="false"
         identity=""
         idlesecs="1693"
         mute="false"
         name="svedrin"
         onlinesecs="2943"
         os="X11"
         osversion="Debian GNU/Linux unstable (sid)"
         release="1.2.2-2"
         selfDeaf="false"
         selfMute="false"
         session="7"
         suppress="false"
         tcponly="false"
         userid="1"
         version="66050"
         x-addrstring="2001:6f8:108f:1:21f:3cff:wx:yz" />
      </channel>
      <channel
       description="This channel has &lt;i&gt;HTML&lt;/i&gt; elements in its description that are not evaluated as &lt;span style=&quot;color: red&quot;&gt;red &lt;b&gt;bold&lt;/b&gt;&lt;/span&gt; Fonts!"
       id="2"
       links="4"
       name="plainsubtesting"
       parent="1"
       position="0"
       temporary="false"
       x-connecturl="mumble://kuunavang.funzt-halt.net/testing/plainsubtesting?version=1.2.2">
        <channel
         description=""
         id="3"
         links=""
         name="subsubtesting"
         parent="2"
         position="0"
         temporary="false"
         x-connecturl="mumble://kuunavang.funzt-halt.net/testing/plainsubtesting/subsubtesting?version=1.2.2" />
      </channel>
    </channel>
  </channel>
</server>