1// Copyright 2005-2019 The Mumble Developers. All rights reserved.
2// Use of this source code is governed by a BSD-style license
3// that can be found in the LICENSE file at the root of the
4// Mumble source tree or at <https://www.mumble.info/LICENSE>.
5
6syntax = "proto2";
7
8package MurmurRPC;
9
10// Note about embedded messages:
11//
12// To help save bandwidth, the protocol does not always send complete embedded
13// messages (i.e. an embeddded message with all of the fields filled in). These
14// incomplete messages only contain enough identifying information to get more
15// information from the message's corresponding "Get" method. For example:
16//
17// User.server only ever contains the server ID. Calling ServerGet(User.server)
18// will return a Server message with the server's status and uptime.
19
20message Void {
21}
22
23message Version {
24	// 2-byte Major, 1-byte Minor and 1-byte Patch version number.
25	optional uint32 version = 1;
26	// Client release name.
27	optional string release = 2;
28	// Client OS name.
29	optional string os = 3;
30	// Client OS version.
31	optional string os_version = 4;
32}
33
34message Uptime {
35	// The number of seconds from the starting time.
36	optional uint64 secs = 1;
37}
38
39message Server {
40	// The unique server ID.
41	required uint32 id = 1;
42	// Is the server currently running?
43	optional bool running = 2;
44	// The update of the server.
45	optional Uptime uptime = 3;
46
47	message Event {
48		enum Type {
49			UserConnected = 0;
50			UserDisconnected = 1;
51			UserStateChanged = 2;
52			UserTextMessage = 3;
53			ChannelCreated = 4;
54			ChannelRemoved = 5;
55			ChannelStateChanged = 6;
56		};
57		// The server on which the event happened.
58		optional Server server = 1;
59		// The type of event that happened.
60		optional Type type = 2;
61		// The user tied to the event (if applicable).
62		optional User user = 3;
63		// The text message tied to the event (if applicable).
64		optional TextMessage message = 4;
65		// The channel tied to the event (if applicable).
66		optional Channel channel = 5;
67	}
68
69	message Query {
70	}
71
72	message List {
73		// The servers.
74		repeated Server servers = 1;
75	}
76}
77
78message Event {
79	enum Type {
80		ServerStopped = 0;
81		ServerStarted = 1;
82	};
83	// The server for which the event happened.
84	optional Server server = 1;
85	// The type of event that happened.
86	optional Type type = 2;
87}
88
89message ContextAction {
90	enum Context {
91		Server = 0x01;
92		Channel = 0x02;
93		User = 0x04;
94	};
95	// The server on which the action is.
96	optional Server server = 1;
97	// The context in which the action is.
98	optional uint32 context = 2;
99	// The action name.
100	optional string action = 3;
101	// The user-visible descriptive name of the action.
102	optional string text = 4;
103	// The user that triggered the ContextAction.
104	optional User actor = 5;
105	// The user on which the ContextAction was triggered.
106	optional User user = 6;
107	// The channel on which the ContextAction was triggered.
108	optional Channel channel = 7;
109}
110
111message TextMessage {
112	// The server on which the TextMessage originates.
113	optional Server server = 1;
114	// The user who sent the message.
115	optional User actor = 2;
116	// The users to whom the message is sent.
117	repeated User users = 3;
118	// The channels to which the message is sent.
119	repeated Channel channels = 4;
120	// The channels to which the message is sent, including the channels'
121	// ancestors.
122	repeated Channel trees = 5;
123	// The message body that is sent.
124	optional string text = 6;
125
126	message Filter {
127		enum Action {
128			// Accept the message.
129			Accept = 0;
130			// Reject the message with a permission error.
131			Reject = 1;
132			// Silently drop the message.
133			Drop = 2;
134		}
135		// The server on which the message originated.
136		optional Server server = 1;
137		// The action to perform for the message.
138		optional Action action = 2;
139		// The text message.
140		optional TextMessage message = 3;
141	}
142}
143
144message Log {
145	// The server on which the log message was generated.
146	optional Server server = 1;
147	// The unix timestamp of when the message was generated.
148	optional int64 timestamp = 2;
149	// The log message.
150	optional string text = 3;
151
152	message Query {
153		// The server whose logs will be queried.
154		optional Server server = 1;
155		// The minimum log index to receive.
156		optional uint32 min = 2;
157		// The maximum log index to receive.
158		optional uint32 max = 3;
159	}
160
161	message List {
162		// The server where the log entries are from.
163		optional Server server = 1;
164		// The total number of logs entries on the server.
165		optional uint32 total = 2;
166		// The minimum log index that was sent.
167		optional uint32 min = 3;
168		// The maximum log index that was sent.
169		optional uint32 max = 4;
170		// The log entries.
171		repeated Log entries = 5;
172	}
173}
174
175message Config {
176	// The server for which the configuration is for.
177	optional Server server = 1;
178	// The configuration keys and values.
179	map<string, string> fields = 2;
180
181	message Field {
182		// The server for which the configuration field is for.
183		optional Server server = 1;
184		// The field key.
185		optional string key = 2;
186		// The field value.
187		optional string value = 3;
188	}
189}
190
191message Channel {
192	// The server on which the channel exists.
193	optional Server server = 1;
194	// The unique channel identifier.
195	optional uint32 id = 2;
196	// The channel name.
197	optional string name = 3;
198	// The channel's parent.
199	optional Channel parent = 4;
200	// Linked channels.
201	repeated Channel links = 5;
202	// The channel's description.
203	optional string description = 6;
204	// Is the channel temporary?
205	optional bool temporary = 7;
206	// The position in which the channel should appear in a sorted list.
207	optional int32 position = 8;
208
209	message Query {
210		// The server on which the channels are.
211		optional Server server = 1;
212	}
213
214	message List {
215		// The server on which the channels are.
216		optional Server server = 1;
217		// The channels.
218		repeated Channel channels = 2;
219	}
220}
221
222message User {
223	// The server to which the user is connected.
224	optional Server server = 1;
225	// The user's session ID.
226	optional uint32 session = 2;
227	// The user's registered ID.
228	optional uint32 id = 3;
229	// The user's name.
230	optional string name = 4;
231	// Is the user muted?
232	optional bool mute = 5;
233	// Is the user deafened?
234	optional bool deaf = 6;
235	// Is the user suppressed?
236	optional bool suppress = 7;
237	// Is the user a priority speaker?
238	optional bool priority_speaker = 8;
239	// Has the user muted him/herself?
240	optional bool self_mute = 9;
241	// Has the user muted him/herself?
242	optional bool self_deaf = 10;
243	// Is the user recording?
244	optional bool recording = 11;
245	// The channel the user is in.
246	optional Channel channel = 12;
247	// How long the user has been connected to the server.
248	optional uint32 online_secs = 13;
249	// How long the user has been idle on the server.
250	optional uint32 idle_secs = 14;
251	// How many bytes per second is the user transmitting to the server.
252	optional uint32 bytes_per_sec = 15;
253	// The user's client version.
254	optional Version version = 16;
255	// The user's  plugin context.
256	optional bytes plugin_context = 17;
257	// The user's plugin identity.
258	optional string plugin_identity = 18;
259	// The user's comment.
260	optional string comment = 19;
261	// The user's texture.
262	optional bytes texture = 20;
263	// The user's IP address.
264	optional bytes address = 21;
265	// Is the user in TCP-only mode?
266	optional bool tcp_only = 22;
267	// The user's UDP ping in milliseconds.
268	optional float udp_ping_msecs = 23;
269	// The user's TCP ping in milliseconds.
270	optional float tcp_ping_msecs = 24;
271
272	message Query {
273		// The server whose users will be queried.
274		optional Server server = 1;
275	}
276
277	message List {
278		// The server to which the users are connected.
279		optional Server server = 1;
280		// The users.
281		repeated User users = 2;
282	}
283
284	message Kick {
285		// The server to which the user is connected.
286		optional Server server = 1;
287		// The user to kick.
288		optional User user = 2;
289		// The user who performed the kick.
290		optional User actor = 3;
291		// The reason for why the user is being kicked.
292		optional string reason = 4;
293	}
294}
295
296message Tree {
297	// The server which the tree represents.
298	optional Server server = 1;
299	// The current channel.
300	optional Channel channel = 2;
301	// Channels below the current channel.
302	repeated Tree children = 3;
303	// The users in the current channel.
304	repeated User users = 4;
305
306	message Query {
307		// The server to query.
308		optional Server server = 1;
309	}
310}
311
312message Ban {
313	// The server on which the ban is applied.
314	optional Server server = 1;
315	// The banned IP address.
316	optional bytes address = 2;
317	// The number of leading bits in the address to which the ban applies.
318	optional uint32 bits = 3;
319	// The name of the banned user.
320	optional string name = 4;
321	// The certificate hash of the banned user.
322	optional string hash = 5;
323	// The reason for the ban.
324	optional string reason = 6;
325	// The ban start time (in epoch form).
326	optional int64 start = 7;
327	// The ban duration.
328	optional int64 duration_secs = 8;
329
330	message Query {
331		// The server whose bans to query.
332		optional Server server = 1;
333	}
334
335	message List {
336		// The server for which the bans apply.
337		optional Server server = 1;
338		// The bans.
339		repeated Ban bans = 2;
340	}
341}
342
343message ACL {
344	enum Permission {
345		None = 0x00;
346		Write = 0x01;
347		Traverse = 0x02;
348		Enter = 0x04;
349		Speak = 0x08;
350		Whisper = 0x100;
351		MuteDeafen = 0x10;
352		Move = 0x20;
353		MakeChannel = 0x40;
354		MakeTemporaryChannel = 0x400;
355		LinkChannel = 0x80;
356		TextMessage = 0x200;
357
358		Kick = 0x10000;
359		Ban = 0x20000;
360		Register = 0x40000;
361		RegisterSelf = 0x80000;
362	}
363
364	message Group {
365		// The ACL group name.
366		optional string name = 1;
367		// Is the group inherited?
368		optional bool inherited = 2;
369		// Does the group inherit members?
370		optional bool inherit = 3;
371		// Can this group be inherited by its children?
372		optional bool inheritable = 4;
373
374		// The users explicitly added by this group.
375		repeated DatabaseUser users_add = 5;
376		// The users explicitly removed by this group.
377		repeated DatabaseUser users_remove = 6;
378		// All of the users who are part of this group.
379		repeated DatabaseUser users = 7;
380	}
381
382	// Does the ACL apply to the current channel?
383	optional bool apply_here = 3;
384	// Does the ACL apply to the current channel's sub-channels?
385	optional bool apply_subs = 4;
386	// Was the ACL inherited?
387	optional bool inherited = 5;
388
389	// The user to whom the ACL applies.
390	optional DatabaseUser user = 6;
391	// The group to whom the ACL applies.
392	optional ACL.Group group = 7;
393
394	// The permissions granted by the ACL (bitmask of ACL.Permission).
395	optional uint32 allow = 8;
396	// The permissions denied by the ACL (bitmask of ACL.Permission).
397	optional uint32 deny = 9;
398
399	message Query {
400		// The server where the user and channel exist.
401		optional Server server = 1;
402		// The user to query.
403		optional User user = 2;
404		// The channel to query.
405		optional Channel channel = 3;
406	}
407
408	message List {
409		// The server on which the ACLs exist.
410		optional Server server = 1;
411		// The channel to which the ACL refers.
412		optional Channel channel = 2;
413		// The ACLs part of the given channel.
414		repeated ACL acls = 3;
415		// The groups part of the given channel.
416		repeated ACL.Group groups = 4;
417		// Should ACLs be inherited from the parent channel.
418		optional bool inherit = 5;
419	}
420
421	message TemporaryGroup {
422		// The server where the temporary group exists.
423		optional Server server = 1;
424		// The channel to which the temporary user group is added.
425		optional Channel channel = 2;
426		// The user who is added to the group.
427		optional User user = 3;
428		// The name of the temporary group.
429		optional string name = 4;
430	}
431}
432
433message Authenticator {
434	message Request {
435		// An authentication request for a connecting user.
436		message Authenticate {
437			// The user's name.
438			optional string name = 1;
439			// The user's password.
440			optional string password = 2;
441			// The user's certificate chain in DER format.
442			repeated bytes certificates = 3;
443			// The hexadecimal hash of the user's certificate.
444			optional string certificate_hash = 4;
445			// If the user is connecting with a strong certificate.
446			optional bool strong_certificate = 5;
447		}
448
449		// A request for information about a user, given by either the user's ID
450		// or name.
451		message Find {
452			// The user's ID used for lookup.
453			optional uint32 id = 1;
454			// The user's name used for lookup.
455			optional string name = 2;
456		}
457
458		// A query of all the registered users, optionally filtered by the given
459		// filter string.
460		message Query {
461			// A user name filter (% is often used as a wildcard)
462			optional string filter = 1;
463		}
464
465		// A request for a new user registration.
466		message Register {
467			// The database user to register.
468			optional DatabaseUser user = 1;
469		}
470
471		// A request for deregistering a registered user.
472		message Deregister {
473			// The database user to deregister.
474			optional DatabaseUser user = 1;
475		}
476
477		// A request to update a registered user's information. The information
478		// provided should be merged with existing data.
479		message Update {
480			// The database user to update.
481			optional DatabaseUser user = 1;
482		}
483
484		optional Authenticate authenticate = 1;
485		optional Find find = 2;
486		optional Query query = 3;
487		optional Register register = 4;
488		optional Deregister deregister = 5;
489		optional Update update = 6;
490	}
491
492	message Response {
493		// The initialization for the authenticator stream. This message must be
494		// sent before authentication requests will start streaming.
495		message Initialize {
496			optional Server server = 1;
497		}
498
499		enum Status {
500			// The request should fallthrough to murmur's default action.
501			Fallthrough = 0;
502			// The request was successful.
503			Success = 1;
504			// The request failed; there was some error.
505			Failure = 2;
506			// A temporary failure prevented the request from succeeding (e.g. a
507			// database was unavailable).
508			TemporaryFailure = 3;
509		}
510
511		message Authenticate {
512			// The status of the request.
513			optional Status status = 1;
514			// The user's registered ID.
515			optional uint32 id = 2;
516			// The corrected user's name;
517			optional string name = 3;
518			// Additional ACL groups that the user belongs too.
519			repeated ACL.Group groups = 4;
520		}
521
522		message Find {
523			// The database user (if found).
524			optional DatabaseUser user = 1;
525		}
526
527		message Query {
528			// The matched database users.
529			repeated DatabaseUser users = 1;
530		}
531
532		message Register {
533			// The status of the request.
534			optional Status status = 1;
535			// The registered database user (must contain the registered user's ID).
536			optional DatabaseUser user = 2;
537		}
538
539		message Deregister {
540			// The status of the request.
541			optional Status status = 1;
542		}
543
544		message Update {
545			// The status of the request.
546			optional Status status = 1;
547		}
548
549		optional Initialize initialize = 1;
550		optional Authenticate authenticate = 2;
551		optional Find find = 3;
552		optional Query query = 4;
553		optional Register register = 5;
554		optional Deregister deregister = 6;
555		optional Update update = 7;
556	}
557}
558
559message DatabaseUser {
560	// The server on which the user is registered.
561	optional Server server = 1;
562	// The unique user ID.
563	optional uint32 id = 2;
564	// The user's name.
565	optional string name = 3;
566	// The user's email address.
567	optional string email = 4;
568	// The user's comment.
569	optional string comment = 5;
570	// The user's certificate hash.
571	optional string hash = 6;
572	// The user's password (never sent; used only when updating).
573	optional string password = 7;
574	// When the user was last on the server.
575	optional string last_active = 8;
576	// The user's texture.
577	optional bytes texture = 9;
578
579	message Query {
580		// The server whose users will be queried.
581		optional Server server = 1;
582		// A string to filter the users by.
583		optional string filter = 2;
584	}
585
586	message List {
587		// The server on which the users are registered.
588		optional Server server = 1;
589		// The users.
590		repeated DatabaseUser users = 2;
591	}
592
593	message Verify {
594		// The server on which the user-password pair will be authenticated.
595		optional Server server = 1;
596		// The user's name.
597		optional string name = 2;
598		// The user's password.
599		optional string password  = 3;
600	}
601}
602
603message RedirectWhisperGroup {
604	// The server on which the whisper redirection will take place.
605	optional Server server = 1;
606	// The user to whom the redirection will be applied.
607	optional User user = 2;
608	// The source group.
609	optional ACL.Group source = 3;
610	// The target group.
611	optional ACL.Group target = 4;
612}
613
614service V1 {
615	//
616	// Meta
617	//
618
619	// GetUptime returns murmur's uptime.
620	rpc GetUptime(Void) returns(Uptime);
621	// GetVersion returns murmur's version.
622	rpc GetVersion(Void) returns(Version);
623	// Events returns a stream of murmur events.
624	rpc Events(Void) returns(stream Event);
625
626	//
627	// Servers
628	//
629
630	// ServerCreate creates a new virtual server. The returned server object
631	// contains the newly created server's ID.
632	rpc ServerCreate(Void) returns(Server);
633	// ServerQuery returns a list of servers that match the given query.
634	rpc ServerQuery(Server.Query) returns(Server.List);
635	// ServerGet returns information about the given server.
636	rpc ServerGet(Server) returns(Server);
637	// ServerStart starts the given stopped server.
638	rpc ServerStart(Server) returns(Void);
639	// ServerStop stops the given virtual server.
640	rpc ServerStop(Server) returns(Void);
641	// ServerRemove removes the given virtual server and its configuration.
642	rpc ServerRemove(Server) returns(Void);
643	// ServerEvents returns a stream of events that happen on the given server.
644	rpc ServerEvents(Server) returns(stream Server.Event);
645
646	//
647	// ContextActions
648	//
649
650	// ContextActionAdd adds a context action to the given user's client. The
651	// following ContextAction fields must be set:
652	//   context, action, text, and user.
653	//
654	// Added context actions are valid until:
655	//  - The context action is removed with ContextActionRemove, or
656	//  - The user disconnects from the server, or
657	//  - The server stops.
658	rpc ContextActionAdd(ContextAction) returns(Void);
659	// ContextActionRemove removes a context action from the given user's client.
660	// The following ContextAction must be set:
661	//   action
662	// If no user is given, the context action is removed from all users.
663	rpc ContextActionRemove(ContextAction) returns(Void);
664	// ContextActionEvents returns a stream of context action events that are
665	// triggered by users.
666	rpc ContextActionEvents(ContextAction) returns(stream ContextAction);
667
668	//
669	// TextMessage
670	//
671
672	// TextMessageSend sends the given TextMessage to the server.
673	//
674	// If no users, channels, or trees are added to the TextMessage, the message
675	// will be broadcast the entire server. Otherwise, the message will be
676	// targeted to the specified users, channels, and trees.
677	rpc TextMessageSend(TextMessage) returns(Void);
678	// TextMessageFilter filters text messages on a given server.
679
680	// TextMessageFilter filters text messages for a given server.
681	//
682	// When a filter stream is active, text messages sent from users to the
683	// server are sent over the stream. The RPC client then sends a message back
684	// on the same stream, containing an action: whether the message should be
685	// accepted, rejected, or dropped.
686	//
687	// To activate the filter stream, an initial TextMessage.Filter message must
688	// be sent that contains the server on which the filter will be active.
689	rpc TextMessageFilter(stream TextMessage.Filter) returns(stream TextMessage.Filter);
690
691	//
692	// Logs
693	//
694
695	// LogQuery returns a list of log entries from the given server.
696	//
697	// To get the total number of log entries, omit min and/or max from the
698	// query.
699	rpc LogQuery(Log.Query) returns(Log.List);
700
701	//
702	// Config
703	//
704
705	// ConfigGet returns the explicitly set configuration for the given server.
706	rpc ConfigGet(Server) returns(Config);
707	// ConfigGetField returns the configuration value for the given key.
708	rpc ConfigGetField(Config.Field) returns(Config.Field);
709	// ConfigSetField sets the configuration value to the given value.
710	rpc ConfigSetField(Config.Field) returns(Void);
711	// ConfigGetDefault returns the default server configuration.
712	rpc ConfigGetDefault(Void) returns(Config);
713
714	//
715	// Channels
716	//
717
718	// ChannelQuery returns a list of channels that match the given query.
719	rpc ChannelQuery(Channel.Query) returns(Channel.List);
720	// ChannelGet returns the channel with the given ID.
721	rpc ChannelGet(Channel) returns(Channel);
722	// ChannelAdd adds the channel to the given server. The parent and name of
723	// the channel must be set.
724	rpc ChannelAdd(Channel) returns(Channel);
725	// ChannelRemove removes the given channel from the server.
726	rpc ChannelRemove(Channel) returns(Void);
727	// ChannelUpdate updates the given channel's attributes. Only the fields that
728	// are set will be updated.
729	rpc ChannelUpdate(Channel) returns(Channel);
730
731	//
732	// Users
733	//
734
735	// UserQuery returns a list of connected users who match the given query.
736	rpc UserQuery(User.Query) returns(User.List);
737	// UserGet returns information on the connected user, given by the user's
738	// session or name.
739	rpc UserGet(User) returns(User);
740	// UserUpdate changes the given user's state. Only the following fields can
741	// be changed:
742	//   name, mute, deaf, suppress, priority_speaker, channel, comment.
743	rpc UserUpdate(User) returns(User);
744	// UserKick kicks the user from the server.
745	rpc UserKick(User.Kick) returns(Void);
746
747	//
748	// Tree
749	//
750
751	// TreeQuery returns a representation of the given server's channel/user
752	// tree.
753	rpc TreeQuery(Tree.Query) returns(Tree);
754
755	//
756	// Bans
757	//
758
759	// BansGet returns a list of bans for the given server.
760	rpc BansGet(Ban.Query) returns(Ban.List);
761	// BansSet replaces the server's ban list with the given list.
762	rpc BansSet(Ban.List) returns(Void);
763
764	//
765	// ACL
766	//
767
768	// ACLGet returns the ACL for the given channel.
769	rpc ACLGet(Channel) returns(ACL.List);
770	// ACLSet overrides the ACL of the given channel to what is provided.
771	rpc ACLSet(ACL.List) returns(Void);
772	// ACLGetEffectivePermissions returns the effective permissions for the given
773	// user in the given channel.
774	rpc ACLGetEffectivePermissions(ACL.Query) returns(ACL);
775	// ACLAddTemporaryGroup adds a user to a temporary group.
776	rpc ACLAddTemporaryGroup(ACL.TemporaryGroup) returns(Void);
777	// ACLRemoveTemporaryGroup removes a user from a temporary group.
778	rpc ACLRemoveTemporaryGroup(ACL.TemporaryGroup) returns(Void);
779
780	//
781	// Authenticator
782	//
783
784	// AuthenticatorStream opens an authentication stream to the server.
785	//
786	// There can only be one RPC client with an open Stream. If a new
787	// authenticator connects, the open connected will be closed.
788	rpc AuthenticatorStream(stream Authenticator.Response) returns(stream Authenticator.Request);
789
790	//
791	// Database
792	//
793
794	// DatabaseUserQuery returns a list of registered users who match given
795	// query.
796	rpc DatabaseUserQuery(DatabaseUser.Query) returns(DatabaseUser.List);
797	// DatabaseUserGet returns the database user with the given ID.
798	rpc DatabaseUserGet(DatabaseUser) returns(DatabaseUser);
799	// DatabaseUserUpdate updates the given database user.
800	rpc DatabaseUserUpdate(DatabaseUser) returns(Void);
801	// DatabaseUserRegister registers a user with the given information on the
802	// server. The returned DatabaseUser will contain the newly registered user's
803	// ID.
804	rpc DatabaseUserRegister(DatabaseUser) returns(DatabaseUser);
805	// DatabaseUserDeregister deregisters the given user.
806	rpc DatabaseUserDeregister(DatabaseUser) returns(Void);
807	// DatabaseUserVerify verifies the that the given user-password pair is
808	// correct.
809	rpc DatabaseUserVerify(DatabaseUser.Verify) returns(DatabaseUser);
810
811	//
812	// Audio
813	//
814
815	// AddRedirectWhisperGroup add a whisper targets redirection for the given
816	// user. Whenever a user whispers to group "source", the whisper will be
817	// redirected to group "target".
818	rpc RedirectWhisperGroupAdd(RedirectWhisperGroup) returns(Void);
819
820	// RemoveRedirectWhisperGroup removes a whisper target redirection for
821	// the the given user.
822	rpc RedirectWhisperGroupRemove(RedirectWhisperGroup) returns(Void);
823}
824