Initial commit
This commit is contained in:
commit
83773f0a1d
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/src/protos
|
||||
/target
|
||||
**/*.rs.bk
|
1430
Cargo.lock
generated
Normal file
1430
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
23
Cargo.toml
Normal file
23
Cargo.toml
Normal file
|
@ -0,0 +1,23 @@
|
|||
[package]
|
||||
name = "mumble-web-proxy"
|
||||
version = "0.1.0"
|
||||
authors = ["Jonas Herzig <me@johni0702.de>"]
|
||||
|
||||
[build-dependencies]
|
||||
protobuf-codegen-pure = "2.0"
|
||||
|
||||
[dependencies]
|
||||
argparse = "0.2.2"
|
||||
bytes = "0.4"
|
||||
byteorder = "1.2"
|
||||
futures = "0.1"
|
||||
tokio = "0.1"
|
||||
tokio-core = "0.1"
|
||||
tokio-codec = "0.1"
|
||||
tokio-tls = "0.1"
|
||||
native-tls = "0.1"
|
||||
protobuf = "2.0"
|
||||
websocket = "0.21.1"
|
||||
rtp = { git = "https://github.com/johni0702/rtp", rev = "0a8ec94", features = ["openssl", "tokio"] }
|
||||
nice = { git = "https://github.com/johni0702/libnice.rs", rev = "956d190" }
|
||||
openssl = "0.10"
|
56
README.md
Normal file
56
README.md
Normal file
|
@ -0,0 +1,56 @@
|
|||
# mumble-web-proxy
|
||||
|
||||
mumble-web-proxy is a [Mumble] to WebSocket+WebRTC proxy.
|
||||
|
||||
The Mumble protocol uses TCP for control and UDP for voice.
|
||||
This proxy bridges those to WebSocket for control and WebRTC for voice.
|
||||
|
||||
While not limited to, its primary use-case is allowing [mumble-web] to connect to vanilla Mumble 1.2/1.3 servers.
|
||||
|
||||
Note that it requires an extension to the Mumble protocol which has not yet been stabilized and as such may change at any time, so make sure to keep mumble-web and mumble-web-proxy in sync.
|
||||
|
||||
### Installing
|
||||
|
||||
#### Building
|
||||
For now, mumble-web-proxy must be built from source. Pre-built binaries may be provided at a later point in development.
|
||||
|
||||
Make sure you have Cargo (Rust's package manager) installed (e.g. via [rustup](https://rustup.rs/)), then run:
|
||||
```
|
||||
git clone https://github.com/johni0702/mumble-web-proxy
|
||||
cd mumble-web-proxy
|
||||
cargo build --release
|
||||
```
|
||||
The final binary will be at `target/release/mumble-web-proxy`.
|
||||
|
||||
#### Running
|
||||
|
||||
mumble-web-proxy can only accept insecure websocket connections, so you will want to run it behind some web server which can terminate TLS. See [mumble-web]'s README for an example.
|
||||
|
||||
Run `mumble-web-proxy --help` to see available options.
|
||||
E.g. if you want the proxy to listen on port `64737` and connect to your Mumble server at `mumbleserver:64738`, run:
|
||||
```
|
||||
mumble-web-proxy --listen-ws 64737 --server mumbleserver:64738
|
||||
```
|
||||
|
||||
#### Firewalls or NAT
|
||||
Note: Not yet implemented.
|
||||
|
||||
If your mumble-web-proxy is running behind a firewall or NAT, you need to allocate a range of ports to it which it can use for ICE connection establishment.
|
||||
```
|
||||
mumble-web-proxy --listen-ws 64737 --server mumbleserver:64738 --ice-start 20000 --ice-end 21000
|
||||
```
|
||||
For NATs, you additionally need to provide it with its publicly reachable IP address(es):
|
||||
```
|
||||
--ice-ipv4 1.2.3.4 --ice-ipv6 1:2:3:4:5::6
|
||||
```
|
||||
|
||||
### License
|
||||
mumble-web-proxy is available under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
|
||||
Additionally, it is available under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
The GPLv2 is used because libnice.rs uses the GPLv2 which is not compatible with the AGPLv3.
|
||||
The AGPLv3 is used to allow dropping of the GPLv2 when/if libnice.rs is ever dropped.
|
||||
|
||||
[Mumble]: https://wiki.mumble.info/wiki/Main_Page
|
||||
[mumble-web]: https://github.com/Johni0702/mumble-web/tree/webrtc
|
||||
[mumble-web-proxy]: https://github.com/johni0702/mumble-web-proxy
|
661
agpl-3.0.txt
Normal file
661
agpl-3.0.txt
Normal file
|
@ -0,0 +1,661 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
12
build.rs
Normal file
12
build.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
extern crate protobuf_codegen_pure;
|
||||
|
||||
fn main() {
|
||||
protobuf_codegen_pure::run(protobuf_codegen_pure::Args {
|
||||
out_dir: "src/protos",
|
||||
input: &["protos/Mumble.proto"],
|
||||
includes: &["protos"],
|
||||
customize: protobuf_codegen_pure::Customize {
|
||||
..Default::default()
|
||||
},
|
||||
}).expect("protoc");
|
||||
}
|
339
gpl-2.0.txt
Normal file
339
gpl-2.0.txt
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
640
protos/Mumble.proto
Normal file
640
protos/Mumble.proto
Normal file
|
@ -0,0 +1,640 @@
|
|||
// Copyright 2005-2018 The Mumble Developers. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file at the root of the
|
||||
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package MumbleProto;
|
||||
|
||||
option optimize_for = SPEED;
|
||||
|
||||
message Version {
|
||||
// 2-byte Major, 1-byte Minor and 1-byte Patch version number.
|
||||
optional uint32 version = 1;
|
||||
// Client release name.
|
||||
optional string release = 2;
|
||||
// Client OS name.
|
||||
optional string os = 3;
|
||||
// Client OS version.
|
||||
optional string os_version = 4;
|
||||
}
|
||||
|
||||
// Not used. Not even for tunneling UDP through TCP.
|
||||
message UDPTunnel {
|
||||
// Not used.
|
||||
required bytes packet = 1;
|
||||
}
|
||||
|
||||
// Used by the client to send the authentication credentials to the server.
|
||||
message Authenticate {
|
||||
// UTF-8 encoded username.
|
||||
optional string username = 1;
|
||||
// Server or user password.
|
||||
optional string password = 2;
|
||||
// Additional access tokens for server ACL groups.
|
||||
repeated string tokens = 3;
|
||||
// A list of CELT bitstream version constants supported by the client.
|
||||
repeated int32 celt_versions = 4;
|
||||
optional bool opus = 5 [default = false];
|
||||
// Whether to use WebRTC instead of native UDP packets.
|
||||
optional bool webrtc = 6 [default = false];
|
||||
}
|
||||
|
||||
// Sent by the client to notify the server that the client is still alive.
|
||||
// Server must reply to the packet with the same timestamp and its own
|
||||
// good/late/lost/resync numbers. None of the fields is strictly required.
|
||||
message Ping {
|
||||
// Client timestamp. Server should not attempt to decode.
|
||||
optional uint64 timestamp = 1;
|
||||
// The amount of good packets received.
|
||||
optional uint32 good = 2;
|
||||
// The amount of late packets received.
|
||||
optional uint32 late = 3;
|
||||
// The amount of packets never received.
|
||||
optional uint32 lost = 4;
|
||||
// The amount of nonce resyncs.
|
||||
optional uint32 resync = 5;
|
||||
// The total amount of UDP packets received.
|
||||
optional uint32 udp_packets = 6;
|
||||
// The total amount of TCP packets received.
|
||||
optional uint32 tcp_packets = 7;
|
||||
// UDP ping average.
|
||||
optional float udp_ping_avg = 8;
|
||||
// UDP ping variance.
|
||||
optional float udp_ping_var = 9;
|
||||
// TCP ping average.
|
||||
optional float tcp_ping_avg = 10;
|
||||
// TCP ping variance.
|
||||
optional float tcp_ping_var = 11;
|
||||
}
|
||||
|
||||
// Sent by the server when it rejects the user connection.
|
||||
message Reject {
|
||||
enum RejectType {
|
||||
// The rejection reason is unknown (details should be available
|
||||
// in Reject.reason).
|
||||
None = 0;
|
||||
// The client attempted to connect with an incompatible version.
|
||||
WrongVersion = 1;
|
||||
// The user name supplied by the client was invalid.
|
||||
InvalidUsername = 2;
|
||||
// The client attempted to authenticate as a user with a password but it
|
||||
// was wrong.
|
||||
WrongUserPW = 3;
|
||||
// The client attempted to connect to a passworded server but the password
|
||||
// was wrong.
|
||||
WrongServerPW = 4;
|
||||
// Supplied username is already in use.
|
||||
UsernameInUse = 5;
|
||||
// Server is currently full and cannot accept more users.
|
||||
ServerFull = 6;
|
||||
// The user did not provide a certificate but one is required.
|
||||
NoCertificate = 7;
|
||||
AuthenticatorFail = 8;
|
||||
}
|
||||
// Rejection type.
|
||||
optional RejectType type = 1;
|
||||
// Human readable rejection reason.
|
||||
optional string reason = 2;
|
||||
}
|
||||
|
||||
// ServerSync message is sent by the server when it has authenticated the user
|
||||
// and finished synchronizing the server state.
|
||||
message ServerSync {
|
||||
// The session of the current user.
|
||||
optional uint32 session = 1;
|
||||
// Maximum bandwidth that the user should use.
|
||||
optional uint32 max_bandwidth = 2;
|
||||
// Server welcome text.
|
||||
optional string welcome_text = 3;
|
||||
// Current user permissions in the root channel.
|
||||
optional uint64 permissions = 4;
|
||||
}
|
||||
|
||||
// Sent by the client when it wants a channel removed. Sent by the server when
|
||||
// a channel has been removed and clients should be notified.
|
||||
message ChannelRemove {
|
||||
required uint32 channel_id = 1;
|
||||
}
|
||||
|
||||
// Used to communicate channel properties between the client and the server.
|
||||
// Sent by the server during the login process or when channel properties are
|
||||
// updated. Client may use this message to update said channel properties.
|
||||
message ChannelState {
|
||||
// Unique ID for the channel within the server.
|
||||
optional uint32 channel_id = 1;
|
||||
// channel_id of the parent channel.
|
||||
optional uint32 parent = 2;
|
||||
// UTF-8 encoded channel name.
|
||||
optional string name = 3;
|
||||
// A collection of channel id values of the linked channels. Absent during
|
||||
// the first channel listing.
|
||||
repeated uint32 links = 4;
|
||||
// UTF-8 encoded channel description. Only if the description is less than
|
||||
// 128 bytes
|
||||
optional string description = 5;
|
||||
// A collection of channel_id values that should be added to links.
|
||||
repeated uint32 links_add = 6;
|
||||
// A collection of channel_id values that should be removed from links.
|
||||
repeated uint32 links_remove = 7;
|
||||
// True if the channel is temporary.
|
||||
optional bool temporary = 8 [default = false];
|
||||
// Position weight to tweak the channel position in the channel list.
|
||||
optional int32 position = 9 [default = 0];
|
||||
// SHA1 hash of the description if the description is 128 bytes or more.
|
||||
optional bytes description_hash = 10;
|
||||
// Maximum number of users allowed in the channel. If this value is zero,
|
||||
// the maximum number of users allowed in the channel is given by the
|
||||
// server's "usersperchannel" setting.
|
||||
optional uint32 max_users = 11;
|
||||
}
|
||||
|
||||
// Used to communicate user leaving or being kicked. May be sent by the client
|
||||
// when it attempts to kick a user. Sent by the server when it informs the
|
||||
// clients that a user is not present anymore.
|
||||
message UserRemove {
|
||||
// The user who is being kicked, identified by their session, not present
|
||||
// when no one is being kicked.
|
||||
required uint32 session = 1;
|
||||
// The user who initiated the removal. Either the user who performs the kick
|
||||
// or the user who is currently leaving.
|
||||
optional uint32 actor = 2;
|
||||
// Reason for the kick, stored as the ban reason if the user is banned.
|
||||
optional string reason = 3;
|
||||
// True if the kick should result in a ban.
|
||||
optional bool ban = 4;
|
||||
}
|
||||
|
||||
// Sent by the server when it communicates new and changed users to client.
|
||||
// First seen during login procedure. May be sent by the client when it wishes
|
||||
// to alter its state.
|
||||
message UserState {
|
||||
// Unique user session ID of the user whose state this is, may change on
|
||||
// reconnect.
|
||||
optional uint32 session = 1;
|
||||
// The session of the user who is updating this user.
|
||||
optional uint32 actor = 2;
|
||||
// User name, UTF-8 encoded.
|
||||
optional string name = 3;
|
||||
// Registered user ID if the user is registered.
|
||||
optional uint32 user_id = 4;
|
||||
// Channel on which the user is.
|
||||
optional uint32 channel_id = 5;
|
||||
// True if the user is muted by admin.
|
||||
optional bool mute = 6;
|
||||
// True if the user is deafened by admin.
|
||||
optional bool deaf = 7;
|
||||
// True if the user has been suppressed from talking by a reason other than
|
||||
// being muted.
|
||||
optional bool suppress = 8;
|
||||
// True if the user has muted self.
|
||||
optional bool self_mute = 9;
|
||||
// True if the user has deafened self.
|
||||
optional bool self_deaf = 10;
|
||||
// User image if it is less than 128 bytes.
|
||||
optional bytes texture = 11;
|
||||
// The positional audio plugin identifier.
|
||||
// Positional audio information is only sent to users who share
|
||||
// identical plugin contexts.
|
||||
//
|
||||
// This value is not trasmitted to clients.
|
||||
optional bytes plugin_context = 12;
|
||||
// The user's plugin-specific identity.
|
||||
// This value is not transmitted to clients.
|
||||
optional string plugin_identity = 13;
|
||||
// User comment if it is less than 128 bytes.
|
||||
optional string comment = 14;
|
||||
// The hash of the user certificate.
|
||||
optional string hash = 15;
|
||||
// SHA1 hash of the user comment if it 128 bytes or more.
|
||||
optional bytes comment_hash = 16;
|
||||
// SHA1 hash of the user picture if it 128 bytes or more.
|
||||
optional bytes texture_hash = 17;
|
||||
// True if the user is a priority speaker.
|
||||
optional bool priority_speaker = 18;
|
||||
// True if the user is currently recording.
|
||||
optional bool recording = 19;
|
||||
// Unique SSRC from which the user's audio is sent when using WebRTC.
|
||||
//
|
||||
// As opposed to `session`, this value must not be monotonically increasing
|
||||
// but must instead be re-used where possible (i.e. after a user disconnects).
|
||||
// The WebRTC implementation must keep track of all SSRCs ever used for the
|
||||
// entirety of the WebRTC session, so that number needs to be kept low.
|
||||
optional uint32 ssrc = 20;
|
||||
}
|
||||
|
||||
// Relays information on the bans. The client may send the BanList message to
|
||||
// either modify the list of bans or query them from the server. The server
|
||||
// sends this list only after a client queries for it.
|
||||
message BanList {
|
||||
message BanEntry {
|
||||
// Banned IP address.
|
||||
required bytes address = 1;
|
||||
// The length of the subnet mask for the ban.
|
||||
required uint32 mask = 2;
|
||||
// User name for identification purposes (does not affect the ban).
|
||||
optional string name = 3;
|
||||
// The certificate hash of the banned user.
|
||||
optional string hash = 4;
|
||||
// Reason for the ban (does not affect the ban).
|
||||
optional string reason = 5;
|
||||
// Ban start time.
|
||||
optional string start = 6;
|
||||
// Ban duration in seconds.
|
||||
optional uint32 duration = 7;
|
||||
}
|
||||
// List of ban entries currently in place.
|
||||
repeated BanEntry bans = 1;
|
||||
// True if the server should return the list, false if it should replace old
|
||||
// ban list with the one provided.
|
||||
optional bool query = 2 [default = false];
|
||||
}
|
||||
|
||||
// Used to send and broadcast text messages.
|
||||
message TextMessage {
|
||||
// The message sender, identified by its session.
|
||||
optional uint32 actor = 1;
|
||||
// Target users for the message, identified by their session.
|
||||
repeated uint32 session = 2;
|
||||
// The channels to which the message is sent, identified by their
|
||||
// channel_ids.
|
||||
repeated uint32 channel_id = 3;
|
||||
// The root channels when sending message recursively to several channels,
|
||||
// identified by their channel_ids.
|
||||
repeated uint32 tree_id = 4;
|
||||
// The UTF-8 encoded message. May be HTML if the server allows.
|
||||
required string message = 5;
|
||||
}
|
||||
|
||||
message PermissionDenied {
|
||||
enum DenyType {
|
||||
// Operation denied for other reason, see reason field.
|
||||
Text = 0;
|
||||
// Permissions were denied.
|
||||
Permission = 1;
|
||||
// Cannot modify SuperUser.
|
||||
SuperUser = 2;
|
||||
// Invalid channel name.
|
||||
ChannelName = 3;
|
||||
// Text message too long.
|
||||
TextTooLong = 4;
|
||||
// The flux capacitor was spelled wrong.
|
||||
H9K = 5;
|
||||
// Operation not permitted in temporary channel.
|
||||
TemporaryChannel = 6;
|
||||
// Operation requires certificate.
|
||||
MissingCertificate = 7;
|
||||
// Invalid username.
|
||||
UserName = 8;
|
||||
// Channel is full.
|
||||
ChannelFull = 9;
|
||||
// Channels are nested too deply.
|
||||
NestingLimit = 10;
|
||||
// Maximum channel count reached.
|
||||
ChannelCountLimit = 11;
|
||||
}
|
||||
// The denied permission when type is Permission.
|
||||
optional uint32 permission = 1;
|
||||
// channel_id for the channel where the permission was denied when type is
|
||||
// Permission.
|
||||
optional uint32 channel_id = 2;
|
||||
// The user who was denied permissions, identified by session.
|
||||
optional uint32 session = 3;
|
||||
// Textual reason for the denial.
|
||||
optional string reason = 4;
|
||||
// Type of the denial.
|
||||
optional DenyType type = 5;
|
||||
// The name that is invalid when type is UserName.
|
||||
optional string name = 6;
|
||||
}
|
||||
|
||||
message ACL {
|
||||
message ChanGroup {
|
||||
// Name of the channel group, UTF-8 encoded.
|
||||
required string name = 1;
|
||||
// True if the group has been inherited from the parent (Read only).
|
||||
optional bool inherited = 2 [default = true];
|
||||
// True if the group members are inherited.
|
||||
optional bool inherit = 3 [default = true];
|
||||
// True if the group can be inherited by sub channels.
|
||||
optional bool inheritable = 4 [default = true];
|
||||
// Users explicitly included in this group, identified by user_id.
|
||||
repeated uint32 add = 5;
|
||||
// Users explicitly removed from this group in this channel if the group
|
||||
// has been inherited, identified by user_id.
|
||||
repeated uint32 remove = 6;
|
||||
// Users inherited, identified by user_id.
|
||||
repeated uint32 inherited_members = 7;
|
||||
}
|
||||
message ChanACL {
|
||||
// True if this ACL applies to the current channel.
|
||||
optional bool apply_here = 1 [default = true];
|
||||
// True if this ACL applies to the sub channels.
|
||||
optional bool apply_subs = 2 [default = true];
|
||||
// True if the ACL has been inherited from the parent.
|
||||
optional bool inherited = 3 [default = true];
|
||||
// ID of the user that is affected by this ACL.
|
||||
optional uint32 user_id = 4;
|
||||
// ID of the group that is affected by this ACL.
|
||||
optional string group = 5;
|
||||
// Bit flag field of the permissions granted by this ACL.
|
||||
optional uint32 grant = 6;
|
||||
// Bit flag field of the permissions denied by this ACL.
|
||||
optional uint32 deny = 7;
|
||||
}
|
||||
// Channel ID of the channel this message affects.
|
||||
required uint32 channel_id = 1;
|
||||
// True if the channel inherits its parent's ACLs.
|
||||
optional bool inherit_acls = 2 [default = true];
|
||||
// User group specifications.
|
||||
repeated ChanGroup groups = 3;
|
||||
// ACL specifications.
|
||||
repeated ChanACL acls = 4;
|
||||
// True if the message is a query for ACLs instead of setting them.
|
||||
optional bool query = 5 [default = false];
|
||||
}
|
||||
|
||||
// Client may use this message to refresh its registered user information. The
|
||||
// client should fill the IDs or Names of the users it wants to refresh. The
|
||||
// server fills the missing parts and sends the message back.
|
||||
message QueryUsers {
|
||||
// user_ids.
|
||||
repeated uint32 ids = 1;
|
||||
// User names in the same order as ids.
|
||||
repeated string names = 2;
|
||||
}
|
||||
|
||||
// Used to initialize and resync the UDP encryption. Either side may request a
|
||||
// resync by sending the message without any values filled. The resync is
|
||||
// performed by sending the message with only the client or server nonce
|
||||
// filled.
|
||||
message CryptSetup {
|
||||
// Encryption key.
|
||||
optional bytes key = 1;
|
||||
// Client nonce.
|
||||
optional bytes client_nonce = 2;
|
||||
// Server nonce.
|
||||
optional bytes server_nonce = 3;
|
||||
}
|
||||
|
||||
message ContextActionModify {
|
||||
enum Context {
|
||||
// Action is applicable to the server.
|
||||
Server = 0x01;
|
||||
// Action can target a Channel.
|
||||
Channel = 0x02;
|
||||
// Action can target a User.
|
||||
User = 0x04;
|
||||
}
|
||||
enum Operation {
|
||||
Add = 0;
|
||||
Remove = 1;
|
||||
}
|
||||
// The action name.
|
||||
required string action = 1;
|
||||
// The display name of the action.
|
||||
optional string text = 2;
|
||||
// Context bit flags defining where the action should be displayed.
|
||||
optional uint32 context = 3;
|
||||
optional Operation operation = 4;
|
||||
}
|
||||
|
||||
// Sent by the client when it wants to initiate a Context action.
|
||||
message ContextAction {
|
||||
// The target User for the action, identified by session.
|
||||
optional uint32 session = 1;
|
||||
// The target Channel for the action, identified by channel_id.
|
||||
optional uint32 channel_id = 2;
|
||||
// The action that should be executed.
|
||||
required string action = 3;
|
||||
}
|
||||
|
||||
// Lists the registered users.
|
||||
message UserList {
|
||||
message User {
|
||||
// Registered user ID.
|
||||
required uint32 user_id = 1;
|
||||
// Registered user name.
|
||||
optional string name = 2;
|
||||
optional string last_seen = 3;
|
||||
optional uint32 last_channel = 4;
|
||||
}
|
||||
// A list of registered users.
|
||||
repeated User users = 1;
|
||||
}
|
||||
|
||||
// Sent by the client when it wants to register or clear whisper targets.
|
||||
//
|
||||
// Note: The first available target ID is 1 as 0 is reserved for normal
|
||||
// talking. Maximum target ID is 30.
|
||||
message VoiceTarget {
|
||||
message Target {
|
||||
// Users that are included as targets.
|
||||
repeated uint32 session = 1;
|
||||
// Channel that is included as a target.
|
||||
optional uint32 channel_id = 2;
|
||||
// ACL group that is included as a target.
|
||||
optional string group = 3;
|
||||
// True if the voice should follow links from the specified channel.
|
||||
optional bool links = 4 [default = false];
|
||||
// True if the voice should also be sent to children of the specific
|
||||
// channel.
|
||||
optional bool children = 5 [default = false];
|
||||
}
|
||||
// Voice target ID.
|
||||
optional uint32 id = 1;
|
||||
// The receivers that this voice target includes.
|
||||
repeated Target targets = 2;
|
||||
}
|
||||
|
||||
// Sent by the client when it wants permissions for a certain channel. Sent by
|
||||
// the server when it replies to the query or wants the user to resync all
|
||||
// channel permissions.
|
||||
message PermissionQuery {
|
||||
// channel_id of the channel for which the permissions are queried.
|
||||
optional uint32 channel_id = 1;
|
||||
// Channel permissions.
|
||||
optional uint32 permissions = 2;
|
||||
// True if the client should drop its current permission information for all
|
||||
// channels.
|
||||
optional bool flush = 3 [default = false];
|
||||
}
|
||||
|
||||
// Sent by the server to notify the users of the version of the CELT codec they
|
||||
// should use. This may change during the connection when new users join.
|
||||
message CodecVersion {
|
||||
// The version of the CELT Alpha codec.
|
||||
required int32 alpha = 1;
|
||||
// The version of the CELT Beta codec.
|
||||
required int32 beta = 2;
|
||||
// True if the user should prefer Alpha over Beta.
|
||||
required bool prefer_alpha = 3 [default = true];
|
||||
optional bool opus = 4 [default = false];
|
||||
}
|
||||
|
||||
// Used to communicate user stats between the server and clients.
|
||||
message UserStats {
|
||||
message Stats {
|
||||
// The amount of good packets received.
|
||||
optional uint32 good = 1;
|
||||
// The amount of late packets received.
|
||||
optional uint32 late = 2;
|
||||
// The amount of packets never received.
|
||||
optional uint32 lost = 3;
|
||||
// The amount of nonce resyncs.
|
||||
optional uint32 resync = 4;
|
||||
}
|
||||
|
||||
// User whose stats these are.
|
||||
optional uint32 session = 1;
|
||||
// True if the message contains only mutable stats (packets, ping).
|
||||
optional bool stats_only = 2 [default = false];
|
||||
// Full user certificate chain of the user certificate in DER format.
|
||||
repeated bytes certificates = 3;
|
||||
// Packet statistics for packets received from the client.
|
||||
optional Stats from_client = 4;
|
||||
// Packet statistics for packets sent by the server.
|
||||
optional Stats from_server = 5;
|
||||
|
||||
// Amount of UDP packets sent.
|
||||
optional uint32 udp_packets = 6;
|
||||
// Amount of TCP packets sent.
|
||||
optional uint32 tcp_packets = 7;
|
||||
// UDP ping average.
|
||||
optional float udp_ping_avg = 8;
|
||||
// UDP ping variance.
|
||||
optional float udp_ping_var = 9;
|
||||
// TCP ping average.
|
||||
optional float tcp_ping_avg = 10;
|
||||
// TCP ping variance.
|
||||
optional float tcp_ping_var = 11;
|
||||
|
||||
// Client version.
|
||||
optional Version version = 12;
|
||||
// A list of CELT bitstream version constants supported by the client of this
|
||||
// user.
|
||||
repeated int32 celt_versions = 13;
|
||||
// Client IP address.
|
||||
optional bytes address = 14;
|
||||
// Bandwith used by this client.
|
||||
optional uint32 bandwidth = 15;
|
||||
// Connection duration.
|
||||
optional uint32 onlinesecs = 16;
|
||||
// Duration since last activity.
|
||||
optional uint32 idlesecs = 17;
|
||||
// True if the user has a strong certificate.
|
||||
optional bool strong_certificate = 18 [default = false];
|
||||
optional bool opus = 19 [default = false];
|
||||
}
|
||||
|
||||
// Used by the client to request binary data from the server. By default large
|
||||
// comments or textures are not sent within standard messages but instead the
|
||||
// hash is. If the client does not recognize the hash it may request the
|
||||
// resource when it needs it. The client does so by sending a RequestBlob
|
||||
// message with the correct fields filled with the user sessions or channel_ids
|
||||
// it wants to receive. The server replies to this by sending a new
|
||||
// UserState/ChannelState message with the resources filled even if they would
|
||||
// normally be transmitted as hashes.
|
||||
message RequestBlob {
|
||||
// sessions of the requested UserState textures.
|
||||
repeated uint32 session_texture = 1;
|
||||
// sessions of the requested UserState comments.
|
||||
repeated uint32 session_comment = 2;
|
||||
// channel_ids of the requested ChannelState descriptions.
|
||||
repeated uint32 channel_description = 3;
|
||||
}
|
||||
|
||||
// Sent by the server when it informs the clients on server configuration
|
||||
// details.
|
||||
message ServerConfig {
|
||||
// The maximum bandwidth the clients should use.
|
||||
optional uint32 max_bandwidth = 1;
|
||||
// Server welcome text.
|
||||
optional string welcome_text = 2;
|
||||
// True if the server allows HTML.
|
||||
optional bool allow_html = 3;
|
||||
// Maximum text message length.
|
||||
optional uint32 message_length = 4;
|
||||
// Maximum image message length.
|
||||
optional uint32 image_message_length = 5;
|
||||
// The maximum number of users allowed on the server.
|
||||
optional uint32 max_users = 6;
|
||||
}
|
||||
|
||||
// Sent by the server to inform the clients of suggested client configuration
|
||||
// specified by the server administrator.
|
||||
message SuggestConfig {
|
||||
// Suggested client version.
|
||||
optional uint32 version = 1;
|
||||
// True if the administrator suggests positional audio to be used on this
|
||||
// server.
|
||||
optional bool positional = 2;
|
||||
// True if the administrator suggests push to talk to be used on this server.
|
||||
optional bool push_to_talk = 3;
|
||||
}
|
||||
|
||||
// Used to exchange WebRTC session details between client and server.
|
||||
// The client may only send these if it received one from the server beforehand.
|
||||
// The server may only send these if the client has indicated its support in
|
||||
// the `webrtc` field of the `Authenticate` message and, if the server chooses to
|
||||
// support WebRTC for the client, it MUST send the message right after receiving
|
||||
// the `Authenticate` message, before any other message (especially before any
|
||||
// `UserState`, `TalkingState` or `IceCandidate` messages).
|
||||
//
|
||||
// No actual SDP is exchanged, it is instead built separately by both, the client
|
||||
// and the server, on every user join/part.
|
||||
// All audio is bundled via "a=group:BUNDLE audio$ssrc ..." over a single
|
||||
// DTLS-SRTP over ICE connection.
|
||||
// The client should be in controlling mode for ICE, the server should act as
|
||||
// the server/passive for DTLS and as the offerer for WebRTC.
|
||||
// Note:
|
||||
// WebRTC demands the offerer to offer both active and passive modes "actpass".
|
||||
// The client should modify the browser's answer to use the correct one before applying it.
|
||||
//
|
||||
// Global parameters (ice_pwd, ice_ufrag and dtls_fingerprint) are sent via an initial
|
||||
// `WebRTC` packet. Transmitting further `WebRTC` packets should trigger ICE-restarts.
|
||||
//
|
||||
// There needs to be one unidirectional media section per connected user. The
|
||||
// SSRC for each media section is sent with the initial `UserState` message.
|
||||
//
|
||||
// SDP for each media segment:
|
||||
// m=audio 0 UDP/TLS/RTP/SAVPF 97
|
||||
// c=IN IP4 0.0.0.0
|
||||
// a=fingerprint:sha-256 $dtls_fingerprint
|
||||
// a=ice-pwd:$ice_pwd
|
||||
// a=ice-ufrag:$ice_ufrag
|
||||
// a=rtpmap:97 OPUS/48000/2
|
||||
// a=rtcp-mux
|
||||
// a=setup:actpass
|
||||
// a=bundle-only
|
||||
// a=ssrc:$ssrc cname:audio$ssrc
|
||||
//
|
||||
// There also needs to be one unidirectional media section which describes
|
||||
// the stream containing the client's voice. This section's SDP is similar
|
||||
// to the above one except in the opposite direction (e.g. different ice and
|
||||
// dtls credentials) und no specific SSRC (considering how the server chooses
|
||||
// SSRCs for its users, 0xffffffff should be a safe bet to prevent collisions).
|
||||
message WebRTC {
|
||||
optional string ice_pwd = 1;
|
||||
optional string ice_ufrag = 2;
|
||||
optional string dtls_fingerprint = 3;
|
||||
}
|
||||
|
||||
// Used to exchange ICE candidates.
|
||||
message IceCandidate {
|
||||
required string content = 1;
|
||||
}
|
||||
|
||||
// Indicates whether a user is currently talking (or whispering or shouting).
|
||||
// Also used to set own talking state.
|
||||
// Only sent when WebRTC is used, otherwise this information can be deduced
|
||||
// from the UDP packets.
|
||||
message TalkingState {
|
||||
// User whose state this is
|
||||
optional uint32 session = 1;
|
||||
// Target, as used in UDP packets:
|
||||
// Clientbound: 0 is normal talking, 1 is shout, 2 is whisper, 31 is server loopback
|
||||
// Serverbound: 0 is normal talking, 1-30 as per VoiceTarget, 31 is server loopback
|
||||
optional uint32 target = 2;
|
||||
}
|
633
src/connection.rs
Normal file
633
src/connection.rs
Normal file
|
@ -0,0 +1,633 @@
|
|||
use futures::stream;
|
||||
use futures::{Future, Sink, Stream};
|
||||
use openssl::asn1::Asn1Time;
|
||||
use openssl::hash::MessageDigest;
|
||||
use openssl::pkey::{PKey, Private};
|
||||
use openssl::rsa::Rsa;
|
||||
use openssl::ssl::{SslAcceptor, SslAcceptorBuilder, SslMethod};
|
||||
use openssl::x509::X509;
|
||||
use protobuf::Message;
|
||||
use rtp::rfc3550::{
|
||||
RtcpCompoundPacket, RtcpPacket, RtcpPacketReader, RtcpPacketWriter, RtpFixedHeader, RtpPacket,
|
||||
RtpPacketReader, RtpPacketWriter,
|
||||
};
|
||||
use rtp::rfc5761::{MuxPacketReader, MuxPacketWriter, MuxedPacket};
|
||||
use rtp::rfc5764::{DtlsSrtp, DtlsSrtpHandshakeResult};
|
||||
use rtp::traits::{ReadPacket, WritePacket};
|
||||
use std::collections::BTreeMap;
|
||||
use std::time::{Duration, Instant};
|
||||
use tokio::io;
|
||||
use tokio::prelude::*;
|
||||
use tokio::timer::Delay;
|
||||
|
||||
use error::Error;
|
||||
use ice::{IceAgent, IceStream};
|
||||
use mumble;
|
||||
use mumble::MumbleFrame;
|
||||
use protos::Mumble;
|
||||
use utils::{read_varint, write_varint32, EitherS};
|
||||
|
||||
type SessionId = u32;
|
||||
|
||||
struct User {
|
||||
session: u32, // mumble session id
|
||||
ssrc: u32, // ssrc id
|
||||
active: bool, // whether the user is currently transmitting audio
|
||||
timeout: Option<Delay>, // assume end of transmission if silent until then
|
||||
start_voice_seq_num: u64,
|
||||
highest_voice_seq_num: u64,
|
||||
rtp_seq_num_offset: u32, // u32 because we also derive the timestamp from it
|
||||
}
|
||||
|
||||
impl User {
|
||||
fn set_inactive(&mut self) -> impl Stream<Item = Frame, Error = Error> {
|
||||
self.timeout = None;
|
||||
|
||||
if self.active {
|
||||
self.active = false;
|
||||
|
||||
let mut msg = Mumble::TalkingState::new();
|
||||
msg.set_session(self.session);
|
||||
EitherS::A(stream::once(Ok(Frame::Client(MumbleFrame {
|
||||
id: mumble::MSG_TALKING_STATE,
|
||||
bytes: msg.write_to_bytes().unwrap().into(),
|
||||
}))))
|
||||
} else {
|
||||
EitherS::B(stream::empty())
|
||||
}
|
||||
}
|
||||
|
||||
fn set_active(&mut self, target: u8) -> impl Stream<Item = Frame, Error = Error> {
|
||||
let when = Instant::now() + Duration::from_millis(400);
|
||||
self.timeout = Some(Delay::new(when));
|
||||
|
||||
if self.active {
|
||||
EitherS::A(stream::empty())
|
||||
} else {
|
||||
self.active = true;
|
||||
|
||||
let mut msg = Mumble::TalkingState::new();
|
||||
msg.set_session(self.session);
|
||||
msg.set_target(target.into());
|
||||
EitherS::B(stream::once(Ok(Frame::Client(MumbleFrame {
|
||||
id: mumble::MSG_TALKING_STATE,
|
||||
bytes: msg.write_to_bytes().unwrap().into(),
|
||||
}))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Connection {
|
||||
inbound_client: Box<Stream<Item = MumbleFrame, Error = Error>>,
|
||||
outbound_client: Box<Sink<SinkItem = MumbleFrame, SinkError = Error>>,
|
||||
inbound_server: Box<Stream<Item = MumbleFrame, Error = Error>>,
|
||||
outbound_server: Box<Sink<SinkItem = MumbleFrame, SinkError = Error>>,
|
||||
next_clientbound_frame: Option<MumbleFrame>,
|
||||
next_serverbound_frame: Option<MumbleFrame>,
|
||||
next_rtp_frame: Option<Vec<u8>>,
|
||||
stream_to_be_sent: Option<Box<Stream<Item = Frame, Error = Error>>>,
|
||||
|
||||
ice_future: Option<Box<Future<Item = (IceAgent, IceStream), Error = Error>>>,
|
||||
ice: Option<IceAgent>,
|
||||
|
||||
dtls_srtp_future: Option<DtlsSrtpHandshakeResult<IceStream, SslAcceptorBuilder>>,
|
||||
dtls_srtp: Option<DtlsSrtp<IceStream, SslAcceptorBuilder>>,
|
||||
dtls_key: PKey<Private>,
|
||||
dtls_cert: X509,
|
||||
|
||||
rtp_reader: MuxPacketReader<RtpPacketReader, RtcpPacketReader>,
|
||||
rtp_writer: MuxPacketWriter<RtpPacketWriter, RtcpPacketWriter>,
|
||||
|
||||
target: Option<u8>, // only if client is talking
|
||||
next_ssrc: u32,
|
||||
free_ssrcs: Vec<u32>,
|
||||
sessions: BTreeMap<SessionId, User>,
|
||||
}
|
||||
|
||||
impl Connection {
|
||||
pub fn new<CSi, CSt, SSi, SSt>(
|
||||
client_sink: CSi,
|
||||
client_stream: CSt,
|
||||
server_sink: SSi,
|
||||
server_stream: SSt,
|
||||
) -> Self
|
||||
where
|
||||
CSi: Sink<SinkItem = MumbleFrame, SinkError = Error> + 'static,
|
||||
CSt: Stream<Item = MumbleFrame, Error = Error> + 'static,
|
||||
SSi: Sink<SinkItem = MumbleFrame, SinkError = Error> + 'static,
|
||||
SSt: Stream<Item = MumbleFrame, Error = Error> + 'static,
|
||||
{
|
||||
let rsa = Rsa::generate(2048).unwrap();
|
||||
let key = PKey::from_rsa(rsa).unwrap();
|
||||
|
||||
let mut cert_builder = X509::builder().unwrap();
|
||||
cert_builder
|
||||
.set_not_after(&Asn1Time::days_from_now(1).unwrap())
|
||||
.unwrap();
|
||||
cert_builder
|
||||
.set_not_before(&Asn1Time::days_from_now(0).unwrap())
|
||||
.unwrap();
|
||||
cert_builder.set_pubkey(&key).unwrap();
|
||||
cert_builder.sign(&key, MessageDigest::sha256()).unwrap();
|
||||
let cert = cert_builder.build();
|
||||
|
||||
Self {
|
||||
inbound_client: Box::new(client_stream),
|
||||
outbound_client: Box::new(client_sink),
|
||||
inbound_server: Box::new(server_stream),
|
||||
outbound_server: Box::new(server_sink),
|
||||
next_clientbound_frame: None,
|
||||
next_serverbound_frame: None,
|
||||
next_rtp_frame: None,
|
||||
stream_to_be_sent: None,
|
||||
ice_future: None,
|
||||
ice: None,
|
||||
dtls_srtp_future: None,
|
||||
dtls_srtp: None,
|
||||
dtls_key: key,
|
||||
dtls_cert: cert,
|
||||
rtp_reader: MuxPacketReader::new(RtpPacketReader, RtcpPacketReader),
|
||||
rtp_writer: MuxPacketWriter::new(RtpPacketWriter, RtcpPacketWriter),
|
||||
target: None,
|
||||
next_ssrc: 1,
|
||||
free_ssrcs: Vec::new(),
|
||||
sessions: BTreeMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn allocate_ssrc(&mut self, session_id: SessionId) -> &mut User {
|
||||
let ssrc = self.free_ssrcs.pop().unwrap_or_else(|| {
|
||||
let ssrc = self.next_ssrc;
|
||||
self.next_ssrc += 1;
|
||||
if let Some(ref mut dtls_srtp) = self.dtls_srtp {
|
||||
dtls_srtp.add_incoming_unknown_ssrcs(1);
|
||||
dtls_srtp.add_outgoing_unknown_ssrcs(1);
|
||||
}
|
||||
ssrc
|
||||
});
|
||||
let user = User {
|
||||
session: session_id,
|
||||
ssrc,
|
||||
active: false,
|
||||
timeout: None,
|
||||
start_voice_seq_num: 0,
|
||||
highest_voice_seq_num: 0,
|
||||
rtp_seq_num_offset: 0,
|
||||
};
|
||||
self.sessions.insert(session_id, user);
|
||||
self.sessions.get_mut(&session_id).unwrap()
|
||||
}
|
||||
|
||||
fn free_ssrc(&mut self, session_id: SessionId) {
|
||||
if let Some(user) = self.sessions.remove(&session_id) {
|
||||
self.free_ssrcs.push(user.ssrc)
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_ice(
|
||||
&mut self,
|
||||
agent: IceAgent,
|
||||
stream: IceStream,
|
||||
) -> impl Stream<Item = Frame, Error = Error> {
|
||||
// Send WebRTC details to the client
|
||||
let mut msg = Mumble::WebRTC::new();
|
||||
msg.set_dtls_fingerprint(
|
||||
self.dtls_cert
|
||||
.digest(MessageDigest::sha256())
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|byte| format!("{:02X}", byte))
|
||||
.collect::<Vec<_>>()
|
||||
.join(":"),
|
||||
);
|
||||
msg.set_ice_pwd(agent.pwd().to_owned());
|
||||
msg.set_ice_ufrag(agent.ufrag().to_owned());
|
||||
let webrtc_msg = Frame::Client(MumbleFrame {
|
||||
id: mumble::MSG_WEBRTC,
|
||||
bytes: msg.write_to_bytes().unwrap().into(),
|
||||
});
|
||||
|
||||
// Parse ICE candidates and send them to the client
|
||||
let candidate_msgs = agent
|
||||
.sdp()
|
||||
.lines()
|
||||
.filter(|line| line.starts_with("a=candidate"))
|
||||
.map(|line| line[2..].to_owned())
|
||||
.map(move |candidate| {
|
||||
let mut msg = Mumble::IceCandidate::new();
|
||||
msg.set_content(candidate);
|
||||
Frame::Client(MumbleFrame {
|
||||
id: mumble::MSG_ICE_CANDIDATE,
|
||||
bytes: msg.write_to_bytes().unwrap().into(),
|
||||
})
|
||||
})
|
||||
.collect::<Vec<Frame>>();
|
||||
|
||||
// Store ice agent for later use
|
||||
self.ice = Some(agent);
|
||||
|
||||
// Prepare to accept the DTLS connection
|
||||
let mut acceptor = SslAcceptor::mozilla_modern(SslMethod::dtls()).unwrap();
|
||||
acceptor.set_certificate(&self.dtls_cert).unwrap();
|
||||
acceptor.set_private_key(&self.dtls_key).unwrap();
|
||||
// FIXME: verify remote fingerprint
|
||||
self.dtls_srtp_future = Some(DtlsSrtp::handshake(stream, acceptor));
|
||||
|
||||
stream::iter_ok(Some(webrtc_msg).into_iter().chain(candidate_msgs))
|
||||
}
|
||||
|
||||
fn handle_voice_packet(&mut self, buf: &[u8]) -> impl Stream<Item = Frame, Error = Error> {
|
||||
let (header, buf) = match buf.split_first() {
|
||||
Some(t) => t,
|
||||
None => return EitherS::B(stream::empty()),
|
||||
};
|
||||
if (header >> 5_u8) != 4_u8 {
|
||||
// only opus
|
||||
return EitherS::B(stream::empty());
|
||||
}
|
||||
let target = header & 0x1f;
|
||||
let (session_id, buf) = match read_varint(buf) {
|
||||
Some(t) => t,
|
||||
None => return EitherS::B(stream::empty()),
|
||||
};
|
||||
let (sequence_id, buf) = match read_varint(buf) {
|
||||
Some(t) => t,
|
||||
None => return EitherS::B(stream::empty()),
|
||||
};
|
||||
let (opus_header, buf) = match read_varint(buf) {
|
||||
Some(t) => t,
|
||||
None => return EitherS::B(stream::empty()),
|
||||
};
|
||||
let length = (opus_header & 0x1fff) as usize;
|
||||
let last_bit = opus_header & 0x2000 != 0;
|
||||
if length > buf.len() {
|
||||
return EitherS::B(stream::empty());
|
||||
}
|
||||
let (opus_data, _) = buf.split_at(length);
|
||||
|
||||
// NOTE: the mumble packet id increases by 1 per 10ms of audio contained
|
||||
// whereas rtp seq_num should increase by 1 per packet, regardless of audio,
|
||||
// but firefox seems to be just fine if we skip over rtp seq_nums.
|
||||
// NOTE: we rely on the srtp layer to prevent two-time-pads and by doing so,
|
||||
// allow for (reasonable) jitter of incoming voice packets.
|
||||
|
||||
let user = match self.sessions.get_mut(&(session_id as u32)) {
|
||||
Some(s) => s,
|
||||
None => return EitherS::B(stream::empty()),
|
||||
};
|
||||
let rtp_ssrc = user.ssrc;
|
||||
|
||||
let mut rtp_marker = if user.active {
|
||||
false
|
||||
} else {
|
||||
user.start_voice_seq_num = sequence_id;
|
||||
user.highest_voice_seq_num = sequence_id;
|
||||
true
|
||||
};
|
||||
|
||||
let activity_stream = if last_bit && sequence_id > user.start_voice_seq_num {
|
||||
// this is the last packet of this voice transmission -> reset counters
|
||||
// doing that will effectively trash any delayed packets but that's just
|
||||
// a flaw in the mumble protocol and there's nothing we can do about it.
|
||||
EitherS::B(user.set_inactive())
|
||||
} else if sequence_id >= user.highest_voice_seq_num
|
||||
&& sequence_id + 100 < user.highest_voice_seq_num
|
||||
{
|
||||
// probably same voice transmission (also not too far in the future)
|
||||
user.highest_voice_seq_num = sequence_id;
|
||||
EitherS::A(user.set_active(target))
|
||||
} else if user.highest_voice_seq_num > sequence_id + 100 {
|
||||
// Either significant jitter (>2s) or we missed the end of the last
|
||||
// transmission. Since >2s jitter will break opus horribly anyway,
|
||||
// we assume the latter and start a new transmission
|
||||
user.rtp_seq_num_offset = user
|
||||
.rtp_seq_num_offset
|
||||
.wrapping_add((user.highest_voice_seq_num - user.start_voice_seq_num) as u32)
|
||||
.wrapping_add(1);
|
||||
user.start_voice_seq_num = sequence_id;
|
||||
user.highest_voice_seq_num = sequence_id;
|
||||
rtp_marker = true;
|
||||
EitherS::A(user.set_active(target))
|
||||
} else {
|
||||
EitherS::A(user.set_active(target))
|
||||
};
|
||||
|
||||
let offset = sequence_id - user.start_voice_seq_num;
|
||||
let rtp_seq_num = user.rtp_seq_num_offset + offset as u32;
|
||||
|
||||
if !user.active {
|
||||
user.rtp_seq_num_offset = user
|
||||
.rtp_seq_num_offset
|
||||
.wrapping_add((sequence_id - user.start_voice_seq_num) as u32)
|
||||
.wrapping_add(1);
|
||||
user.start_voice_seq_num = 0;
|
||||
user.highest_voice_seq_num = 0;
|
||||
}
|
||||
|
||||
let rtp_time = 480 * rtp_seq_num;
|
||||
|
||||
let rtp = RtpPacket {
|
||||
header: RtpFixedHeader {
|
||||
padding: false,
|
||||
marker: rtp_marker,
|
||||
payload_type: 97,
|
||||
seq_num: rtp_seq_num as u16,
|
||||
timestamp: rtp_time as u32,
|
||||
ssrc: rtp_ssrc,
|
||||
csrc_list: Vec::new(),
|
||||
extension: None,
|
||||
},
|
||||
payload: opus_data.to_vec(),
|
||||
padding: Vec::new(),
|
||||
};
|
||||
let frame = Frame::Rtp(MuxedPacket::Rtp(rtp));
|
||||
EitherS::A(activity_stream.chain(stream::once(Ok(frame))))
|
||||
}
|
||||
|
||||
fn process_packet_from_server(
|
||||
&mut self,
|
||||
mut frame: MumbleFrame,
|
||||
) -> impl Stream<Item = Frame, Error = Error> {
|
||||
match frame.id {
|
||||
mumble::MSG_UDP_TUNNEL => EitherS::A(self.handle_voice_packet(&frame.bytes)),
|
||||
mumble::MSG_USER_STATE => {
|
||||
let mut message: Mumble::UserState =
|
||||
protobuf::parse_from_bytes(&frame.bytes).unwrap();
|
||||
let session_id = message.get_session();
|
||||
if !self.sessions.contains_key(&session_id) {
|
||||
let user = self.allocate_ssrc(session_id);
|
||||
message.set_ssrc(user.ssrc);
|
||||
}
|
||||
frame.bytes = message.write_to_bytes().unwrap().as_slice().into();
|
||||
EitherS::B(stream::once(Ok(Frame::Client(frame))))
|
||||
}
|
||||
mumble::MSG_USER_REMOVE => {
|
||||
let mut message: Mumble::UserRemove =
|
||||
protobuf::parse_from_bytes(&frame.bytes).unwrap();
|
||||
self.free_ssrc(message.get_session());
|
||||
EitherS::B(stream::once(Ok(Frame::Client(frame))))
|
||||
}
|
||||
_ => EitherS::B(stream::once(Ok(Frame::Client(frame)))),
|
||||
}
|
||||
}
|
||||
|
||||
fn process_packet_from_client(
|
||||
&mut self,
|
||||
mut frame: MumbleFrame,
|
||||
) -> impl Stream<Item = Frame, Error = Error> {
|
||||
match frame.id {
|
||||
mumble::MSG_AUTHENTICATE => {
|
||||
let mut message: Mumble::Authenticate =
|
||||
protobuf::parse_from_bytes(&frame.bytes).unwrap();
|
||||
println!("MSG Authenticate: {:?}", message);
|
||||
if message.get_webrtc() {
|
||||
// strip webrtc support from the connection (we will be providing it)
|
||||
message.clear_webrtc();
|
||||
// and make sure opus is marked as supported
|
||||
message.set_opus(true);
|
||||
|
||||
self.ice_future = Some(Box::new(IceAgent::bind()));
|
||||
}
|
||||
|
||||
frame.bytes = message.write_to_bytes().unwrap().as_slice().into();
|
||||
EitherS::A(EitherS::A(stream::once(Ok(Frame::Server(frame)))))
|
||||
}
|
||||
mumble::MSG_WEBRTC => {
|
||||
let mut message: Mumble::WebRTC = protobuf::parse_from_bytes(&frame.bytes).unwrap();
|
||||
println!("Got WebRTC: {:?}", message);
|
||||
if let Some(ref mut agent) = self.ice {
|
||||
let f1 = agent.set_remote_pwd(message.take_ice_pwd());
|
||||
let f2 = agent.set_remote_ufrag(message.take_ice_ufrag());
|
||||
// FIXME trigger ICE-restart if required
|
||||
// FIXME store and use remote dtls fingerprint
|
||||
EitherS::B(EitherS::A(
|
||||
f1.join(f2)
|
||||
.map(|_| stream::empty())
|
||||
.map_err(|_| {
|
||||
io::Error::new(io::ErrorKind::Other, "failed to set ice creds")
|
||||
})
|
||||
.from_err()
|
||||
.flatten_stream(),
|
||||
))
|
||||
} else {
|
||||
EitherS::A(EitherS::B(stream::empty()))
|
||||
}
|
||||
}
|
||||
mumble::MSG_ICE_CANDIDATE => {
|
||||
let mut message: Mumble::IceCandidate =
|
||||
protobuf::parse_from_bytes(&frame.bytes).unwrap();
|
||||
let candidate = message.take_content();
|
||||
println!("Got ice candidate: {:?}", candidate);
|
||||
if let Some(ref mut agent) = self.ice {
|
||||
EitherS::B(EitherS::B(
|
||||
agent
|
||||
.add_remote_ice_candidate(candidate)
|
||||
.map(|_| stream::empty())
|
||||
.map_err(|_| {
|
||||
io::Error::new(io::ErrorKind::Other, "failed to add ice candidate")
|
||||
})
|
||||
.from_err()
|
||||
.flatten_stream(),
|
||||
))
|
||||
} else {
|
||||
EitherS::A(EitherS::B(stream::empty()))
|
||||
}
|
||||
}
|
||||
mumble::MSG_TALKING_STATE => {
|
||||
let mut message: Mumble::TalkingState =
|
||||
protobuf::parse_from_bytes(&frame.bytes).unwrap();
|
||||
self.target = if message.has_target() {
|
||||
Some(message.get_target() as u8)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
EitherS::A(EitherS::B(stream::empty()))
|
||||
}
|
||||
_ => EitherS::A(EitherS::A(stream::once(Ok(Frame::Server(frame))))),
|
||||
}
|
||||
}
|
||||
|
||||
fn process_rtp_packet(&mut self, buf: &[u8]) -> impl Stream<Item = Frame, Error = Error> {
|
||||
stream::iter_result(match self.rtp_reader.read_packet(&mut &buf[..]) {
|
||||
Ok(MuxedPacket::Rtp(rtp)) => {
|
||||
if let Some(target) = self.target {
|
||||
// FIXME derive mumble seq_num from rtp timestamp to properly handle
|
||||
// packet reordering and loss (done). But maybe keep it low?
|
||||
let seq_num = rtp.header.timestamp / 480;
|
||||
|
||||
let header = 128_u8 | target;
|
||||
let mut vec: Vec<u8> = Vec::new();
|
||||
vec.push(header);
|
||||
write_varint32(&mut vec, seq_num as u32).unwrap();
|
||||
write_varint32(&mut vec, rtp.payload.len() as u32).unwrap();
|
||||
vec.extend(rtp.payload);
|
||||
|
||||
Some(Ok(Frame::Server(MumbleFrame {
|
||||
id: mumble::MSG_UDP_TUNNEL,
|
||||
bytes: vec.into(),
|
||||
})))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Ok(MuxedPacket::Rtcp(_rtcp)) => None,
|
||||
Err(_err) => None, // FIXME maybe not silently drop the error?
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Future for Connection {
|
||||
type Item = ();
|
||||
type Error = Error;
|
||||
|
||||
fn poll(&mut self) -> Poll<(), Error> {
|
||||
'poll: loop {
|
||||
// If there's a frame pending to be sent, sent it before everything else
|
||||
if let Some(frame) = self.next_serverbound_frame.take() {
|
||||
match self.outbound_server.start_send(frame)? {
|
||||
AsyncSink::NotReady(frame) => {
|
||||
self.next_serverbound_frame = Some(frame);
|
||||
return Ok(Async::NotReady);
|
||||
}
|
||||
AsyncSink::Ready => {}
|
||||
}
|
||||
}
|
||||
if let Some(frame) = self.next_clientbound_frame.take() {
|
||||
match self.outbound_client.start_send(frame)? {
|
||||
AsyncSink::NotReady(frame) => {
|
||||
self.next_clientbound_frame = Some(frame);
|
||||
return Ok(Async::NotReady);
|
||||
}
|
||||
AsyncSink::Ready => {}
|
||||
}
|
||||
}
|
||||
if let Some(frame) = self.next_rtp_frame.take() {
|
||||
if let Some(ref mut dtls_srtp) = self.dtls_srtp {
|
||||
match dtls_srtp.start_send(frame)? {
|
||||
AsyncSink::NotReady(frame) => {
|
||||
self.next_rtp_frame = Some(frame);
|
||||
return Ok(Async::NotReady);
|
||||
}
|
||||
AsyncSink::Ready => {}
|
||||
}
|
||||
} else {
|
||||
// RTP not yet setup, just drop the frame
|
||||
}
|
||||
}
|
||||
|
||||
// Send out all pending frames
|
||||
if self.stream_to_be_sent.is_some() {
|
||||
match self.stream_to_be_sent.as_mut().unwrap().poll()? {
|
||||
Async::NotReady => return Ok(Async::NotReady),
|
||||
Async::Ready(Some(frame)) => {
|
||||
match frame {
|
||||
Frame::Server(frame) => self.next_serverbound_frame = Some(frame),
|
||||
Frame::Client(frame) => self.next_clientbound_frame = Some(frame),
|
||||
Frame::Rtp(frame) => {
|
||||
let mut buf = Vec::new();
|
||||
self.rtp_writer.write_packet(&mut buf, &frame)?;
|
||||
self.next_rtp_frame = Some(buf)
|
||||
}
|
||||
}
|
||||
continue 'poll;
|
||||
}
|
||||
Async::Ready(None) => {
|
||||
self.stream_to_be_sent = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All frames have been sent (or queued), flush any buffers in the output path
|
||||
self.outbound_client.poll_complete()?;
|
||||
self.outbound_server.poll_complete()?;
|
||||
if let Some(ref mut dtls_srtp) = self.dtls_srtp {
|
||||
dtls_srtp.poll_complete()?;
|
||||
}
|
||||
|
||||
// Check/register voice timeouts
|
||||
// Note that this must be ran if any new sessions are added or timeouts are
|
||||
// modified as otherwise we may be blocking on IO and won't get notified of
|
||||
// timeouts. In particular, this means that it has to always be called if
|
||||
// we suspect that we may be blocking on inbound IO (outbound is less critical
|
||||
// since any action taken as a result of timeouts will have to wait for it
|
||||
// anyway), hence this being positioned above the code for incoming packets below.
|
||||
// (same applies to the other futures directly below it)
|
||||
for session in self.sessions.values_mut() {
|
||||
if let Async::Ready(Some(())) = session.timeout.poll()? {
|
||||
let stream = session.set_inactive();
|
||||
self.stream_to_be_sent = Some(Box::new(stream));
|
||||
continue 'poll;
|
||||
}
|
||||
}
|
||||
|
||||
// Poll ice future if required
|
||||
if self.ice_future.is_some() {
|
||||
if let Async::Ready((agent, stream)) = self.ice_future.as_mut().unwrap().poll()? {
|
||||
self.ice_future = None;
|
||||
|
||||
println!("ICE ready.");
|
||||
|
||||
let stream = self.setup_ice(agent, stream);
|
||||
self.stream_to_be_sent = Some(Box::new(stream));
|
||||
continue 'poll;
|
||||
} else {
|
||||
// wait for ice before processing futher packets to ensure
|
||||
// that the WebRTC init message isn't sent too late
|
||||
return Ok(Async::NotReady);
|
||||
}
|
||||
}
|
||||
|
||||
// Poll dtls_srtp future if required
|
||||
if let Async::Ready(Some(mut dtls_srtp)) = self.dtls_srtp_future.poll()? {
|
||||
self.dtls_srtp_future = None;
|
||||
|
||||
println!("DTLS-SRTP connection established.");
|
||||
|
||||
dtls_srtp.add_incoming_unknown_ssrcs(self.next_ssrc as usize);
|
||||
dtls_srtp.add_outgoing_unknown_ssrcs(self.next_ssrc as usize);
|
||||
|
||||
self.dtls_srtp = Some(dtls_srtp);
|
||||
}
|
||||
|
||||
// Finally check for incoming packets
|
||||
match self.inbound_server.poll()? {
|
||||
Async::NotReady => {}
|
||||
Async::Ready(Some(frame)) => {
|
||||
let stream = self.process_packet_from_server(frame);
|
||||
self.stream_to_be_sent = Some(Box::new(stream));
|
||||
continue 'poll;
|
||||
}
|
||||
Async::Ready(None) => return Ok(Async::Ready(())),
|
||||
}
|
||||
match self.inbound_client.poll()? {
|
||||
Async::NotReady => {}
|
||||
Async::Ready(Some(frame)) => {
|
||||
let stream = self.process_packet_from_client(frame);
|
||||
self.stream_to_be_sent = Some(Box::new(stream));
|
||||
continue 'poll;
|
||||
}
|
||||
Async::Ready(None) => return Ok(Async::Ready(())),
|
||||
}
|
||||
if self.dtls_srtp.is_some() {
|
||||
match self.dtls_srtp.as_mut().unwrap().poll()? {
|
||||
Async::NotReady => {}
|
||||
Async::Ready(Some(frame)) => {
|
||||
let stream = self.process_rtp_packet(&frame);
|
||||
self.stream_to_be_sent = Some(Box::new(stream));
|
||||
continue 'poll;
|
||||
}
|
||||
Async::Ready(None) => return Ok(Async::Ready(())),
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(Async::NotReady);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
enum Frame {
|
||||
Server(MumbleFrame),
|
||||
Client(MumbleFrame),
|
||||
Rtp(MuxedPacket<RtpPacket, RtcpCompoundPacket<RtcpPacket>>),
|
||||
}
|
61
src/error.rs
Normal file
61
src/error.rs
Normal file
|
@ -0,0 +1,61 @@
|
|||
use futures::sync::mpsc;
|
||||
use websocket;
|
||||
|
||||
// FIXME clean this up
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Io(std::io::Error),
|
||||
ServerTls(native_tls::Error),
|
||||
ClientConnection(websocket::result::WebSocketError),
|
||||
Protobuf(protobuf::ProtobufError),
|
||||
Misc(Box<std::error::Error>),
|
||||
}
|
||||
|
||||
impl From<websocket::result::WebSocketError> for Error {
|
||||
fn from(e: websocket::result::WebSocketError) -> Self {
|
||||
Error::ClientConnection(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
Error::Io(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<native_tls::Error> for Error {
|
||||
fn from(e: native_tls::Error) -> Self {
|
||||
Error::ServerTls(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<protobuf::ProtobufError> for Error {
|
||||
fn from(e: protobuf::ProtobufError) -> Self {
|
||||
Error::Protobuf(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<tokio::timer::Error> for Error {
|
||||
fn from(e: tokio::timer::Error) -> Self {
|
||||
Error::Misc(Box::new(e))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<rtp::Error> for Error {
|
||||
fn from(e: rtp::Error) -> Self {
|
||||
Error::Misc(Box::new(e))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<()> for Error {
|
||||
fn from(_: ()) -> Self {
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<mpsc::SendError<T>> for Error {
|
||||
fn from(_: mpsc::SendError<T>) -> Self {
|
||||
panic!();
|
||||
}
|
||||
}
|
202
src/ice.rs
Normal file
202
src/ice.rs
Normal file
|
@ -0,0 +1,202 @@
|
|||
// FIXME replace with proper libnice bindings or pure-rust ICE/STUN lib
|
||||
use error::Error;
|
||||
use future::Either;
|
||||
use futures::sync::{mpsc, oneshot};
|
||||
use futures::{Future, Sink, Stream};
|
||||
use nice::api_agent::Agent;
|
||||
use nice::api_gobject::GMainLoop;
|
||||
use nice::bindings_agent as ice_ffi;
|
||||
use std::clone::Clone;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
use tokio::io;
|
||||
use tokio::prelude::*;
|
||||
|
||||
pub struct IceAgent {
|
||||
ufrag: String,
|
||||
pwd: String,
|
||||
sdp: String,
|
||||
remote_sdp_sender: mpsc::Sender<String>,
|
||||
remote_ice_candidates: Vec<String>,
|
||||
remote_ufrag: Option<String>,
|
||||
remote_pwd: Option<String>,
|
||||
}
|
||||
|
||||
pub struct IceStream {
|
||||
receiver: mpsc::Receiver<Vec<u8>>,
|
||||
sender: mpsc::Sender<Vec<u8>>,
|
||||
}
|
||||
|
||||
impl IceAgent {
|
||||
pub fn bind() -> impl Future<Item = (Self, IceStream), Error = Error> {
|
||||
let (tokio_sender, thread_receiver) = mpsc::channel(10);
|
||||
let (thread_sender, tokio_receiver) = mpsc::channel(10);
|
||||
let (cred_sender, cred_receiver) = oneshot::channel();
|
||||
let (remote_sdp_sender, remote_sdp_receiver) = mpsc::channel(10);
|
||||
|
||||
thread::spawn(move || {
|
||||
let thread_sender = Mutex::new(thread_sender);
|
||||
let mut recv_callback = Box::new(move |buf: &[u8]| {
|
||||
let result = thread_sender.lock().unwrap().try_send(buf.to_vec());
|
||||
if let Err(err) = result {
|
||||
eprintln!("Failed to queue packet: {:?} {:?}", buf, err);
|
||||
}
|
||||
});
|
||||
|
||||
let main_loop = GMainLoop::new();
|
||||
let context = main_loop.get_context();
|
||||
thread::spawn(move || {
|
||||
// FIXME stop at some point
|
||||
main_loop.run();
|
||||
});
|
||||
|
||||
let agent = Arc::new(Agent::new(&context, ice_ffi::NICE_COMPATIBILITY_RFC5245));
|
||||
agent.set_software("mumble-web-proxy");
|
||||
|
||||
let stream_id = agent.add_stream(1).unwrap();
|
||||
let (ufrag, pwd) = agent.get_local_credentials(stream_id).unwrap();
|
||||
|
||||
agent.set_stream_name(stream_id, "audio");
|
||||
agent.gather_candidates(stream_id);
|
||||
agent.attach_recv(stream_id, 1, &context, &mut recv_callback);
|
||||
|
||||
// ok, here's the thing: libnice.rs is a giant train wreck.
|
||||
// It doesn't require any of the closures which it takes to be Send
|
||||
// even though, considering they're called from the GMainLoop,
|
||||
// they really should be. That's going to explode sooner or later.
|
||||
// I have no clue how many other things are broken but one of them
|
||||
// is on_candidate_gathering_done which just segfaults.
|
||||
// Since I can neither be bothered to debug that mess nor to write
|
||||
// new bindings or a pure-rust ice lib (yet), we'll work around the
|
||||
// issue by periodically polling. FIXME
|
||||
// It turns out attach_recv is also broken, so I had to go in and fix
|
||||
// that but now I've already written this workaround so it's here to
|
||||
// stay (at least until there's a better libnice binding).
|
||||
// This will probably only give non-turn candidates which should
|
||||
// be enough for our use-case.
|
||||
loop {
|
||||
let maybe_sdp = agent.generate_local_stream_sdp(stream_id, false);
|
||||
if let Some(sdp) = maybe_sdp {
|
||||
cred_sender.send((sdp, ufrag, pwd)).unwrap(); // FIXME handle shutdown
|
||||
break;
|
||||
}
|
||||
::std::thread::sleep(::std::time::Duration::from_millis(100));
|
||||
}
|
||||
|
||||
let remote_sdp_handler = remote_sdp_receiver.for_each(|remote_sdp: String| {
|
||||
// FIXME do we need to handle invalid sdp?
|
||||
agent.parse_remote_sdp(&remote_sdp).unwrap();
|
||||
Ok(())
|
||||
});
|
||||
let packet_send_handler = thread_receiver.for_each(|packet: Vec<u8>| {
|
||||
agent.send(stream_id, 1, &packet[..]);
|
||||
Ok(())
|
||||
});
|
||||
remote_sdp_handler.join(packet_send_handler).wait().unwrap();
|
||||
});
|
||||
|
||||
cred_receiver
|
||||
.map(|(sdp, ufrag, pwd): (String, String, String)| {
|
||||
(
|
||||
Self {
|
||||
ufrag,
|
||||
pwd,
|
||||
sdp,
|
||||
remote_sdp_sender,
|
||||
remote_ice_candidates: Vec::new(),
|
||||
remote_ufrag: None,
|
||||
remote_pwd: None,
|
||||
},
|
||||
IceStream {
|
||||
receiver: tokio_receiver,
|
||||
sender: tokio_sender,
|
||||
},
|
||||
)
|
||||
})
|
||||
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))
|
||||
.from_err()
|
||||
}
|
||||
|
||||
pub fn pwd(&self) -> &str {
|
||||
&self.pwd
|
||||
}
|
||||
|
||||
pub fn ufrag(&self) -> &str {
|
||||
&self.ufrag
|
||||
}
|
||||
|
||||
pub fn sdp(&self) -> &str {
|
||||
&self.sdp
|
||||
}
|
||||
|
||||
pub fn set_remote_pwd(&mut self, pwd: String) -> impl Future<Item = (), Error = ()> {
|
||||
self.remote_pwd = Some(pwd);
|
||||
self.update_remote_sdp()
|
||||
}
|
||||
|
||||
pub fn set_remote_ufrag(&mut self, ufrag: String) -> impl Future<Item = (), Error = ()> {
|
||||
self.remote_ufrag = Some(ufrag);
|
||||
self.update_remote_sdp()
|
||||
}
|
||||
|
||||
pub fn add_remote_ice_candidate(
|
||||
&mut self,
|
||||
candidate: String,
|
||||
) -> impl Future<Item = (), Error = ()> {
|
||||
self.remote_ice_candidates.push(candidate);
|
||||
self.update_remote_sdp()
|
||||
}
|
||||
|
||||
pub fn update_remote_sdp(&self) -> impl Future<Item = (), Error = ()> {
|
||||
if let (Some(pwd), Some(ufrag)) = (&self.remote_pwd, &self.remote_ufrag) {
|
||||
let mut sdp = Vec::new();
|
||||
sdp.push("a=ice-options:trickle".to_owned());
|
||||
sdp.push("m=audio".to_owned());
|
||||
for candidate in &self.remote_ice_candidates {
|
||||
sdp.push("a=".to_owned() + candidate);
|
||||
}
|
||||
sdp.push("a=ice-pwd:".to_owned() + pwd);
|
||||
sdp.push("a=ice-ufrag:".to_owned() + ufrag);
|
||||
let f = self.remote_sdp_sender.clone().send(sdp.join("\n"));
|
||||
Either::A(f.map(|_| ()).map_err(|_| ()))
|
||||
} else {
|
||||
Either::B(future::ok(()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Read for IceStream {
|
||||
fn read(&mut self, dst: &mut [u8]) -> io::Result<usize> {
|
||||
match self.receiver.poll() {
|
||||
Ok(Async::Ready(Some(buf))) => (&buf[..]).read(dst),
|
||||
Ok(Async::Ready(None)) => Ok(0),
|
||||
Ok(Async::NotReady) => Err(io::Error::new(io::ErrorKind::WouldBlock, "")),
|
||||
Err(err) => panic!(err), // FIXME should we really panic here? when can this happen?
|
||||
}
|
||||
}
|
||||
}
|
||||
impl AsyncRead for IceStream {}
|
||||
|
||||
impl Write for IceStream {
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||
match self.sender.start_send(buf.to_vec()) {
|
||||
Ok(AsyncSink::Ready) => Ok(buf.len()),
|
||||
Ok(AsyncSink::NotReady(_)) => Err(io::Error::new(io::ErrorKind::WouldBlock, "")),
|
||||
Err(err) => Err(io::Error::new(io::ErrorKind::Other, err)),
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
match self.sender.poll_complete() {
|
||||
Ok(Async::Ready(())) => Ok(()),
|
||||
Ok(Async::NotReady) => Err(io::Error::new(io::ErrorKind::WouldBlock, "")),
|
||||
Err(err) => Err(io::Error::new(io::ErrorKind::Other, err)),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl AsyncWrite for IceStream {
|
||||
fn shutdown(&mut self) -> io::Result<Async<()>> {
|
||||
Ok(Async::Ready(())) // FIXME actually shutdown ice
|
||||
}
|
||||
}
|
||||
|
190
src/main.rs
Normal file
190
src/main.rs
Normal file
|
@ -0,0 +1,190 @@
|
|||
// FIXME don't just unwrap protobuf results
|
||||
// FIXME for some reason, reconnecting without reloading the page fails DTLS handshake (FF)
|
||||
extern crate argparse;
|
||||
extern crate byteorder;
|
||||
extern crate bytes;
|
||||
extern crate futures;
|
||||
extern crate native_tls;
|
||||
extern crate nice;
|
||||
extern crate openssl;
|
||||
extern crate protobuf;
|
||||
extern crate rtp;
|
||||
extern crate tokio;
|
||||
extern crate tokio_codec;
|
||||
extern crate tokio_core;
|
||||
extern crate tokio_tls;
|
||||
extern crate websocket;
|
||||
|
||||
use argparse::{ArgumentParser, Store};
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use futures::{Future, Sink, Stream};
|
||||
use native_tls::TlsConnector;
|
||||
use std::net::ToSocketAddrs;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::prelude::*;
|
||||
use tokio_codec::Decoder;
|
||||
use tokio_core::reactor::Core;
|
||||
use tokio_tls::TlsConnectorExt;
|
||||
use websocket::async::Server;
|
||||
use websocket::message::OwnedMessage;
|
||||
use websocket::server::InvalidConnection;
|
||||
|
||||
mod connection;
|
||||
mod error;
|
||||
mod ice;
|
||||
mod mumble;
|
||||
mod utils;
|
||||
mod protos {
|
||||
pub mod Mumble;
|
||||
}
|
||||
use connection::Connection;
|
||||
use error::Error;
|
||||
use mumble::{MumbleCodec, MumbleFrame};
|
||||
|
||||
fn main() {
|
||||
let mut ws_port = 0_u16;
|
||||
let mut upstream = "".to_string();
|
||||
|
||||
{
|
||||
let mut ap = ArgumentParser::new();
|
||||
ap.set_description("Run the Mumble-WebRTC proxy");
|
||||
ap.refer(&mut ws_port)
|
||||
.add_option(
|
||||
&["--listen-ws"],
|
||||
Store,
|
||||
"Port to listen for WebSocket (non TLS) connections on",
|
||||
)
|
||||
.required();
|
||||
ap.refer(&mut upstream)
|
||||
.add_option(
|
||||
&["--server"],
|
||||
Store,
|
||||
"Hostname and port of upstream mumble server",
|
||||
)
|
||||
.required();
|
||||
ap.parse_args_or_exit();
|
||||
}
|
||||
|
||||
let mut upstream_parts = upstream.rsplitn(2, ':');
|
||||
let upstream_port: u16 = upstream_parts
|
||||
.next()
|
||||
.expect("Missing upstream port")
|
||||
.parse()
|
||||
.expect("Failed to parse upstream port");
|
||||
let upstream_host = upstream_parts.next().expect("Missing upstream host name");
|
||||
let upstream_host = Box::leak(Box::new(upstream_host.to_owned())).as_str();
|
||||
let upstream_addr = (upstream_host, upstream_port)
|
||||
.to_socket_addrs()
|
||||
.expect("Failed to parse upstream address")
|
||||
.next()
|
||||
.expect("Failed to resolve upstream address");
|
||||
|
||||
let mut core = Core::new().unwrap();
|
||||
let handle = core.handle();
|
||||
let server = Server::bind(("0.0.0.0", ws_port), &handle).unwrap();
|
||||
let f = server
|
||||
.incoming()
|
||||
.map_err(|InvalidConnection { error, .. }| error)
|
||||
.for_each(move |(upgrade, addr)| {
|
||||
println!("New connection from {}", addr);
|
||||
let server_sock = TcpStream::connect(&upstream_addr);
|
||||
let f = upgrade
|
||||
.use_protocol("binary") // FIXME can we be more specific? *looks at chrome*
|
||||
.accept()
|
||||
.from_err()
|
||||
.join(server_sock.from_err().and_then(move |stream| {
|
||||
let connector: TlsConnector = TlsConnector::builder()
|
||||
.unwrap()
|
||||
//.danger_accept_invalid_certs(true)
|
||||
.build()
|
||||
.unwrap();
|
||||
connector.connect_async(upstream_host, stream).from_err()
|
||||
}))
|
||||
.and_then(move |((client, _), server)| {
|
||||
let (client_sink, client_stream) = client.split();
|
||||
// buffered client sink to prevent temporary lag on the control
|
||||
// channel from lagging the otherwise independent audio channel
|
||||
let client_sink = client_sink.buffer(10).with(|m: MumbleFrame| {
|
||||
let bytes = &m.bytes;
|
||||
let len = bytes.len();
|
||||
let mut buf = BytesMut::with_capacity(6 + len);
|
||||
buf.put_u16_be(m.id);
|
||||
buf.put_u32_be(len as u32);
|
||||
buf.put(bytes);
|
||||
Ok::<OwnedMessage, Error>(OwnedMessage::Binary(buf.freeze().to_vec()))
|
||||
});
|
||||
let client_stream = client_stream
|
||||
.from_err()
|
||||
.take_while(|m| Ok(!m.is_close()))
|
||||
.filter_map(|m| {
|
||||
match m {
|
||||
OwnedMessage::Binary(ref b) if b.len() >= 6 => {
|
||||
let id = BigEndian::read_u16(b);
|
||||
// b[2..6] is length which is implicit in websocket msgs
|
||||
let bytes = b[6..].into();
|
||||
Some(MumbleFrame { id, bytes })
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
});
|
||||
|
||||
let server = MumbleCodec::new().framed(server);
|
||||
let (server_sink, server_stream) = server.split();
|
||||
let server_sink = server_sink.sink_from_err();
|
||||
let server_stream = server_stream.from_err();
|
||||
|
||||
Connection::new(client_sink, client_stream, server_sink, server_stream)
|
||||
})
|
||||
.map_err(move |e: Error| println!("Error on connection {}: {:?}", addr, e))
|
||||
.map(move |_| println!("Client connection closed: {}", addr));
|
||||
handle.spawn(f);
|
||||
Ok(())
|
||||
});
|
||||
core.run(f).unwrap();
|
||||
}
|
||||
|
||||
macro_rules! define_packet_mappings {
|
||||
( $id:expr, $head:ident ) => {
|
||||
#[allow(dead_code)]
|
||||
const $head: u16 = $id;
|
||||
};
|
||||
( $id:expr, $head:ident, $( $tail:ident ),* ) => {
|
||||
#[allow(dead_code)]
|
||||
const $head: u16 = $id;
|
||||
define_packet_mappings!($id + 1, $($tail),*);
|
||||
};
|
||||
}
|
||||
|
||||
define_packet_mappings![
|
||||
0,
|
||||
MSG_VERSION,
|
||||
MSG_UDP_TUNNEL,
|
||||
MSG_AUTHENTICATE,
|
||||
MSG_PING,
|
||||
MSG_REJECT,
|
||||
MSG_SERVER_SYNC,
|
||||
MSG_CHANNEL_REMOVE,
|
||||
MSG_CHANNEL_STATE,
|
||||
MSG_USER_REMOVE,
|
||||
MSG_USER_STATE,
|
||||
MSG_BAN_LIST,
|
||||
MSG_TEXT_MESSAGE,
|
||||
MSG_PERMISSION_DENIED,
|
||||
MSG_ACL,
|
||||
MSG_QUERY_USERS,
|
||||
MSG_CRYPT_SETUP,
|
||||
MSG_CONTEXT_ACTION_MODIFY,
|
||||
MSG_CONTEXT_ACTION,
|
||||
MSG_USER_LIST,
|
||||
MSG_VOICE_TARGET,
|
||||
MSG_PERMISSION_QUERY,
|
||||
MSG_CODEC_VERSION,
|
||||
MSG_USER_STATS,
|
||||
MSG_REQUEST_BLOB,
|
||||
MSG_SERVER_CONFIG,
|
||||
MSG_SUGGEST_CONFIG,
|
||||
MSG_WEBRTC,
|
||||
MSG_ICE_CANDIDATE,
|
||||
MSG_TALKING_STATE
|
||||
];
|
103
src/mumble.rs
Normal file
103
src/mumble.rs
Normal file
|
@ -0,0 +1,103 @@
|
|||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||
use std::io::Cursor;
|
||||
use tokio::io;
|
||||
use tokio_codec::{Decoder, Encoder};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MumbleFrame {
|
||||
pub id: u16,
|
||||
pub bytes: Bytes,
|
||||
}
|
||||
|
||||
pub struct MumbleCodec;
|
||||
|
||||
impl MumbleCodec {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl Decoder for MumbleCodec {
|
||||
type Item = MumbleFrame;
|
||||
type Error = io::Error;
|
||||
|
||||
fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<MumbleFrame>, io::Error> {
|
||||
let buf_len = buf.len();
|
||||
if buf_len >= 6 {
|
||||
let mut buf = Cursor::new(buf);
|
||||
let id = buf.get_u16_be();
|
||||
let len = buf.get_u32_be() as usize;
|
||||
if buf_len >= 6 + len {
|
||||
let mut bytes = buf.into_inner().split_to(6 + len);
|
||||
bytes.advance(6);
|
||||
let bytes = bytes.freeze();
|
||||
Ok(Some(MumbleFrame { id, bytes }))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Encoder for MumbleCodec {
|
||||
type Item = MumbleFrame;
|
||||
type Error = io::Error;
|
||||
|
||||
fn encode(&mut self, item: MumbleFrame, dst: &mut BytesMut) -> Result<(), io::Error> {
|
||||
let id = item.id;
|
||||
let bytes = &item.bytes;
|
||||
let len = bytes.len();
|
||||
dst.reserve(6 + len);
|
||||
dst.put_u16_be(id);
|
||||
dst.put_u32_be(len as u32);
|
||||
dst.put(bytes);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! define_packet_mappings {
|
||||
( $id:expr, $head:ident ) => {
|
||||
#[allow(dead_code)]
|
||||
pub const $head: u16 = $id;
|
||||
};
|
||||
( $id:expr, $head:ident, $( $tail:ident ),* ) => {
|
||||
#[allow(dead_code)]
|
||||
pub const $head: u16 = $id;
|
||||
define_packet_mappings!($id + 1, $($tail),*);
|
||||
};
|
||||
}
|
||||
|
||||
define_packet_mappings![
|
||||
0,
|
||||
MSG_VERSION,
|
||||
MSG_UDP_TUNNEL,
|
||||
MSG_AUTHENTICATE,
|
||||
MSG_PING,
|
||||
MSG_REJECT,
|
||||
MSG_SERVER_SYNC,
|
||||
MSG_CHANNEL_REMOVE,
|
||||
MSG_CHANNEL_STATE,
|
||||
MSG_USER_REMOVE,
|
||||
MSG_USER_STATE,
|
||||
MSG_BAN_LIST,
|
||||
MSG_TEXT_MESSAGE,
|
||||
MSG_PERMISSION_DENIED,
|
||||
MSG_ACL,
|
||||
MSG_QUERY_USERS,
|
||||
MSG_CRYPT_SETUP,
|
||||
MSG_CONTEXT_ACTION_MODIFY,
|
||||
MSG_CONTEXT_ACTION,
|
||||
MSG_USER_LIST,
|
||||
MSG_VOICE_TARGET,
|
||||
MSG_PERMISSION_QUERY,
|
||||
MSG_CODEC_VERSION,
|
||||
MSG_USER_STATS,
|
||||
MSG_REQUEST_BLOB,
|
||||
MSG_SERVER_CONFIG,
|
||||
MSG_SUGGEST_CONFIG,
|
||||
MSG_WEBRTC,
|
||||
MSG_ICE_CANDIDATE,
|
||||
MSG_TALKING_STATE
|
||||
];
|
107
src/utils.rs
Normal file
107
src/utils.rs
Normal file
|
@ -0,0 +1,107 @@
|
|||
use futures::Stream;
|
||||
use tokio::prelude::*;
|
||||
|
||||
pub fn read_varint(buf: &[u8]) -> Option<(u64, &[u8])> {
|
||||
let (b0, buf) = buf.split_first()?;
|
||||
let result = if (b0 & 0x80) == 0x00 {
|
||||
(u64::from(b0 & 0x7F), buf)
|
||||
} else {
|
||||
let (b1, buf) = buf.split_first()?;
|
||||
if (b0 & 0xC0) == 0x80 {
|
||||
(u64::from(b0 & 0x3F) << 8 | u64::from(*b1), buf)
|
||||
} else {
|
||||
let (b2, buf) = buf.split_first()?;
|
||||
if (b0 & 0xF0) == 0xF0 {
|
||||
match b0 & 0xFC {
|
||||
0xF0 => {
|
||||
let (b3, buf) = buf.split_first()?;
|
||||
let (b4, buf) = buf.split_first()?;
|
||||
(
|
||||
u64::from(*b1) << 24
|
||||
| u64::from(*b2) << 16
|
||||
| u64::from(*b3) << 8
|
||||
| u64::from(*b4),
|
||||
buf,
|
||||
)
|
||||
}
|
||||
0xF4 => {
|
||||
let (b3, buf) = buf.split_first()?;
|
||||
let (b4, buf) = buf.split_first()?;
|
||||
let (b5, buf) = buf.split_first()?;
|
||||
let (b6, buf) = buf.split_first()?;
|
||||
let (b7, buf) = buf.split_first()?;
|
||||
let (b8, buf) = buf.split_first()?;
|
||||
(
|
||||
u64::from(*b1) << 56
|
||||
| u64::from(*b2) << 48
|
||||
| u64::from(*b3) << 40
|
||||
| u64::from(*b4) << 32
|
||||
| u64::from(*b5) << 24
|
||||
| u64::from(*b6) << 16
|
||||
| u64::from(*b7) << 8
|
||||
| u64::from(*b8),
|
||||
buf,
|
||||
)
|
||||
}
|
||||
0xF8 => {
|
||||
let (val, buf) = read_varint(buf)?;
|
||||
(!val, buf)
|
||||
}
|
||||
0xFC => (!u64::from(b0 & 0x03), buf),
|
||||
_ => {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
} else if (b0 & 0xF0) == 0xE0 {
|
||||
let (b3, buf) = buf.split_first()?;
|
||||
(
|
||||
u64::from(b0 & 0x0F) << 24
|
||||
| u64::from(*b1) << 16
|
||||
| u64::from(*b2) << 8
|
||||
| u64::from(*b3),
|
||||
buf,
|
||||
)
|
||||
} else if (b0 & 0xE0) == 0xC0 {
|
||||
(
|
||||
u64::from(b0 & 0x1F) << 16 | u64::from(*b1) << 8 | u64::from(*b2),
|
||||
buf,
|
||||
)
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
};
|
||||
Some(result)
|
||||
}
|
||||
|
||||
pub fn write_varint32<T: Write>(buf: &mut T, value: u32) -> std::io::Result<()> {
|
||||
// FIXME: actually implement the variable part
|
||||
buf.write_all(&[
|
||||
240,
|
||||
(value >> 24) as u8,
|
||||
(value >> 16) as u8,
|
||||
(value >> 8) as u8,
|
||||
value as u8,
|
||||
])
|
||||
}
|
||||
|
||||
/// Like `futures::future::Either` but for Streams
|
||||
pub enum EitherS<A, B> {
|
||||
A(A),
|
||||
B(B),
|
||||
}
|
||||
|
||||
impl<A, B> Stream for EitherS<A, B>
|
||||
where
|
||||
A: Stream,
|
||||
B: Stream<Item = A::Item, Error = A::Error>,
|
||||
{
|
||||
type Item = A::Item;
|
||||
type Error = A::Error;
|
||||
fn poll(&mut self) -> Result<Async<Option<Self::Item>>, Self::Error> {
|
||||
match self {
|
||||
EitherS::A(s) => s.poll(),
|
||||
EitherS::B(s) => s.poll(),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue