Skip to content

Commit

Permalink
MAINT: Rename Murmur.ice to MumbleServer.ice
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzmbrzl committed Sep 10, 2022
1 parent 1852692 commit b81b060
Show file tree
Hide file tree
Showing 10 changed files with 564 additions and 556 deletions.
2 changes: 1 addition & 1 deletion auxiliary_files/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if(server)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mumble-server.service" DESTINATION "${SYSTEMD_SERVICE_DIR}" COMPONENT mumble_server)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mumble-server-user-wrapper" DESTINATION "${MUMBLE_INSTALL_EXECUTABLEDIR}" COMPONENT mumble_server)
install(FILES "config_files/mumble-server.conf" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/system.d" COMPONENT mumble_server)
install(FILES "${CMAKE_SOURCE_DIR}/src/murmur/Murmur.ice" DESTINATION "${MUMBLE_INSTALL_SYSCONFDIR}" COMPONENT mumble_server)
install(FILES "${CMAKE_SOURCE_DIR}/src/murmur/MumbleServer.ice" DESTINATION "${MUMBLE_INSTALL_SYSCONFDIR}" COMPONENT mumble_server)
endif()
endif()

91 changes: 41 additions & 50 deletions docs/dev/ExtendingTheIceInterface.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,73 +8,58 @@ Note: If not stated otherwise all referenced files live in `src/murmur/`.
The files involved in extending the Ice interface are
| **File** | **Description** |
| -------- | --------------- |
| `Murmur.ice` | Contains the formal definition of the interface |
| `Murmur.h` | Contains the C++ interface definition (abstract base classes). This file is automatically generated based on `Murmur.ice` when invoking cmake (via `slice2cpp`). It lives in `<build directory>/src/murmur`. This file is needed to generate `MurmurIceWrapper.cpp` |
| `Murmur.cpp` | Contains some boilerplate and Ice-internal implementation code. This file is generated and lives alongside `Murmur.h` |
| `MurmurI.h` | Contains the definition of the actually implemented API classes (`ServerI` and `MetaI`). These extend the abstract base classes from `Murmur.h` |
| `MurmurIceWrapper.cpp` | Contains wrapper implementation of the `*I` API classes. This file is auto-generated by the `scripts/generateIceWrapper.py` script |
| `MurmurIce.h` | Contains the definition of a statically used helper class |
| `MurmurIce.cpp` | Contains the implementation of that helper class **and** _static_ functions used to actually implement the server-side functionality of the Ice API functions |
| `RPC.cpp` | Contains the implementations of the `Server` (the Mumble server, _not_ the Ice API type) class's member functions that are required to make certain functionality accessible to the static functions in `MurmurIce.cpp` |
| `MumbleServer.ice` | Contains the formal definition of the interface |
| `MumbleServer.h` | Contains the C++ interface definition (abstract base classes). This file is generated based on `MumbleServer.ice` when invoking cmake (via `slice2cpp`). |
| `MumbleServer.cpp` | Contains some boilerplate and Ice-internal implementation code. This file is automatically generated. |
| `MumbleServerI.h` | Contains the definition of the actually implemented API classes (`ServerI` and `MetaI`). These extend the abstract base classes from `MumbleServer.h` |
| `MumbleServerWrapper.cpp` | Contains wrapper implementation of the `*I` API classes. This file is automatically generated. |
| `MumbleServere.h` | Contains the definition of a statically used helper class |
| `MumbleServere.cpp` | Contains the implementation of that helper class **and** _static_ functions used to actually implement the server-side functionality of the Ice API functions |
| `RPC.cpp` | Contains the implementations of the `Server` (the Mumble server, _not_ the Ice API type) class's member functions that are required to make certain functionality accessible to the static functions in `MumbleServerIce.cpp` |

All auto-generated functions will end up in the corresponding directory inside the `build` directory.


## Overview

The steps are
1. Let cmake invoke `slice2cpp` to generate `Murmur.h` and `Murmur.cpp`
2. Invoke `generateIceWrapper.py` to generate `MurmurIceWrapper.cpp`
3. Add new function declarations to `MurmurU.h`
4. Write impl function in `MurmurIce.cpp`
5. Potentially write new public API functions (declare in `Server.h` and define in `RPC.cpp`

## Detailed instructions

Before proceeding any further you should run cmake once in order for these files to get generated as they are needed for the next step. Assuming your
build directory lives directly under the repository's root, you can do this by invoking
```bash
cmake ..
```
1. Add new function declarations to `MumbleServerI.h`
2. Write impl function in `MumbleServerIce.cpp`
3. Potentially write new public API functions (declare in `Server.h` and define in `RPC.cpp`

The next step is the generation of the `MurmurIceWrapper.cpp` file by executing the following command (assuming the call is performed from the
repository's root and the build directory is called `build`):
```bash
$ python3 scripts/generateIceWrapper.py --ice-file src/murmur/Murmur.ice --generated-ice-header build/src/murmur/Murmur.h --out-file src/murmur/MurmurIceWrapper.cpp
Using ICE-file at "src/murmur/Murmur.ice"
Using ICE-generated header file at "build/src/murmur/Murmur.h"
```
The paths that are given in the example may have to be adapted in order for it to work on your machine.
## Details

The `MurmurIceWrapper.cpp` file generates the `*_async` versions of the Ice callbacks that handle the async nature of these callbacks and also
The `MumbleServerIceWrapper.cpp` file contains the `*_async` versions of the Ice callbacks that handle the async nature of these callbacks and also
contain the boilerplate for e.g. verification of the caller and things like this. Most importantly though these functions call the `impl_*` functions
defined in `MurmurIce.cpp`. For instance a function called `updateCertificates` inside the `Server` class will call `impl_Server_updateCertificate`
which has to be defined as a `static` function inside `MurmurIce.cpp`.
defined in `MumbleServerIce.cpp`. For instance a function called `updateCertificates` inside the `Server` class will call
`impl_Server_updateCertificate` which has to be defined as a `static` function inside `MumbleServerIce.cpp`.

The declaration of the async functions generated this way are contained inside `MurmurI.h`. You have to manually add the function's declaration into
there. The easiest way to do this is to let the script generate the implementation as described above and then copy the function signature from there
into the `Murmur.h` file (make the declaration `virtual` though).
The declarations of the async functions generated this way are contained inside `MumbleServerI.h`. You have to manually add the function's declaration
into there. The easiest way to do this is to let the implementation be auto-generated and then copy the function signature from there into the
`MumbleServer.h` file (make the declaration `virtual` though).

The impl function's signature is always
```cpp
static void impl_<className>_<functionName>(const ::Murmur::AMD_<className>_<functionName>Ptr cb [, int server_id] [, <function arguments>]) {
static void impl_<className>_<functionName>(const ::MumbleServer::AMD_<className>_<functionName>Ptr cb [, int server_id] [, <function arguments>]) {
// Implementation goes here

cb->ice_response([<function return value>]);
}
```
- `<className>`: Name of the class the function is declared in (e.g. `Server` or `Meta`)
- `<functionName>`: Name of the function as declared in the `Murmur.ice` file
- `<functionName>`: Name of the function as declared in the `MumbleServer.ice` file
- `[, int server_id]`: Only needed when extending the `Server` API class (the brackets are not part of what needs to be written in code)
- `[, <function arguments>]`: To be replaced by the list of arguments the function takes
- `[<function return value>]`: To be replaced with the value this function returns or to be removed if the function does not return anything.


If you have used non-default types that are declared in `Murmur.ice` (e.g. `IdList`), you can reference them here as `::Murmur::<typeName>` (e.g.
`::Murmur::IdList`).
If you have used non-default types that are declared in `MumbleServer.ice` (e.g. `IdList`), you can reference them here as
`::MumbleServer::<typeName>` (e.g. `::MumbleServer::IdList`).

Error reporting works via the `cb->ice_exception` function and if everything went well, the function must end by calling `cb->ice_response`
(potentially passing a value to that function that shall be returned to the caller of the function).

In general it is a good idea to have a look at the existing implementation inside `MurmurIce.cpp` and take inspiration from those.
In general it is a good idea to have a look at the existing implementation inside `MumbleServerIce.cpp` and take inspiration from those.

Note that the implementations make heavy use of macros (e.g. `NEED_SERVER`, `NEED_CHANNEL`, etc.). These will initialize the corresponding variables
(`server`, `channel`, etc.) based in the parameters fed into the function (In order to obtain the channel, user, etc. you always have to initialize
Expand All @@ -91,22 +76,26 @@ public API function in the Mumble `Server` class that has the implementation in

## Testing Ice interface changes

So far, you've used `Murmur.ice` to modify and generate **server-side** code. The same file can be used to create Ice **clients**, which then interact with the server. A small amount of configuration is required, namely:
So far, you've used `MumbleServer.ice` to modify and generate **server-side** code. The same file can be used to create Ice **clients**, which then
interact with the server. A small amount of configuration is required, namely:

| **Setting** | **Example** | **Description** |
| --- | --- | --- |
| `host` | `127.0.0.1` | The IP address (or domain) to which Murmur's Ice interface is bound. (Check [`murmur.ini`'s `ice` property `-h` flag](../../scripts/murmur.ini#L65).) |
| `host` | `127.0.0.1` | The IP address (or domain) to which MumbleServer's Ice interface is bound. (Check [`murmur.ini`'s `ice` property `-h` flag](../../scripts/murmur.ini#L65).) |
| `port` | `6502` | The TCP port on which Ice's interface is listening. (Check [`murmur.ini`'s `ice` property `-p` flag](../../scripts/murmur.ini#L65).) |
| `secret` | `ice_pa55word` | A clear-text "password" used to authorize with the Ice server. (This will either be [`icesecretread`](../../scripts/murmur.ini#L79) or [`icesecretwrite`](../../scripts/murmur.ini#L80) from [`murmur.ini`](../../scripts/murmur.ini), with read-only or read-write privileges respectively.) |
| `slicefile` | `Murmur.ice` | The [`Murmur.ice`](../../src/murmur/Murmur.ice) file, containing any changes you intend to test. (This can be dynamically fetched from the Murmur server, provided it's running, has Ice exposed, and was built with the updated `Murmur.ice` file.) |
| `slicefile` | `MumbleServer.ice` | The [`MumbleServer.ice`](../../src/murmur/MumbleServer.ice) file, containing any changes you intend to test. (This can be dynamically fetched from the Mumble server, provided it's running, has Ice exposed, and was built with the updated `MumbleServer.ice` file.) |

> :warning: Since Murmur's Ice interface is clear-text, there are security factors to consider. Use a strong-ish, unique secret, not used for any other case.
> :warning: Since the server's Ice interface is clear-text, there are security factors to consider. Use a strong-ish, unique secret, not used for
> any other case.
An existing Python Ice client is [`mice.py`](https://github.com/mumble-voip/mumble-scripts/blob/master/Helpers/mice.py), which simply creates necessary Ice objects and then drops you into an interactive Python shell. (Refer to the [Wiki](https://wiki.mumble.info/wiki/Mice) and [Natenom](https://blog.natenom.com/2016/02/an-introduction-on-how-to-manage-your-mumble-server-murmur-through-ice-with-mice/) for longer guides.)
An existing Python Ice client is [`mice.py`](https://github.com/mumble-voip/mumble-scripts/blob/master/Helpers/mice.py), which simply creates
necessary Ice objects and then drops you into an interactive Python shell. (Refer to the [Wiki](https://wiki.mumble.info/wiki/Mice) and
[Natenom](https://blog.natenom.com/2016/02/an-introduction-on-how-to-manage-your-mumble-server-murmur-through-ice-with-mice/) for longer guides.)

```python
# Make sure Murmur is running (in a separate terminal)
# $ ./murmur.x86 ...
# Make sure the Mumble server is running (in a separate terminal)
# $ ./mumble-server ...

# Grab mice.py
$ wget --quiet https://raw.githubusercontent.com/mumble-voip/mumble-scripts/master/Helpers/mice.py
Expand All @@ -117,7 +106,7 @@ host = "127.0.0.1"
port = 6502
secret = "ice_pa55word"
prxstr = "Meta:tcp -h {} -p {} -t 1000".format(host, port)
slicefile = "Murmur.ice"
slicefile = "MumbleServer.ice"
EOF


Expand All @@ -129,7 +118,7 @@ Import ice... Done
Trying to retrieve slice dynamically from server... Success
Import dynamically compiled murmur class... Done
Establish ice connection... [protected]... Done
Murmur object accessible via 'murmur' or 'm'
MumbleServer object accessible via 'murmur' or 'm'
1 booted servers in 'sl', 's' contains 's/1 -t -e 1.0:tcp -h 127.0.0.1 -p 6502 -t 60000'
--- Reached interactive mode ---

Expand All @@ -155,4 +144,6 @@ In [5]: [(user.session, user.name) for user in s.getUsers().values()]
Out[5]: [(7L, 'Bob')]
```

> :information_source: Refer to [the Wiki for additional 3rd-party applications](https://wiki.mumble.info/wiki/3rd_Party_Applications) which leverage Murmur's Ice interface.
> :information_source: Refer to [the Wiki for additional 3rd-party applications](https://wiki.mumble.info/wiki/3rd_Party_Applications) which leverage
> the server's Ice interface.
2 changes: 1 addition & 1 deletion installer/ServerInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public ServerInstaller(string version, string arch) {
string upgradeGuid = "03E9476F-0F75-4661-BFC9-A9DAEB23D3A0";
string[] binaries = {
"mumble-server.exe",
"Murmur.ice"
"MumbleServer.ice"
};

string[] licenses = {
Expand Down
10 changes: 5 additions & 5 deletions scripts/generateIceWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create_disclaimerComment():
return "// This file was auto-generated by scripts/generateIceWrapper.py on " + datetime.now().strftime("%Y-%m-%d") + " -- DO NOT EDIT MANUALLY!\n"

def generateFunction(className, functionName, wrapArgs, callArgs):
function = "void ::Murmur::" + className + "I::" + functionName + "_async(" + (", ".join(wrapArgs)) + ") {\n"
function = "void ::MumbleServer::" + className + "I::" + functionName + "_async(" + (", ".join(wrapArgs)) + ") {\n"
function += "\t// qWarning() << \"" + functionName + "\" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty();\n"
function += "#ifndef ACCESS_" + className + "_" + functionName + "_ALL\n"
function += "#\tifdef ACCESS_" + className + "_" + functionName + "_READ\n"
Expand Down Expand Up @@ -84,11 +84,11 @@ def main():
rootDir = os.path.dirname(os.path.dirname(scriptPath))

if args.ice_file is None:
# Try to figure out the path to the ice-file (Murmur.ice)
args.ice_file = os.path.join(rootDir, "src", "murmur", "Murmur.ice")
# Try to figure out the path to the ice-file (MumbleServer.ice)
args.ice_file = os.path.join(rootDir, "src", "murmur", "MumbleServer.ice")
if args.generated_ice_header is None:
# Try to figure out path to the generated header file (in the build dir)
args.generated_ice_header = os.path.join(rootDir, "build", "src", "murmur", "Murmur.h")
args.generated_ice_header = os.path.join(rootDir, "build", "src", "murmur", "MumbleServer.h")

if not args.quiet:
print("Using ICE-file at \"%s\"" % args.ice_file)
Expand Down Expand Up @@ -185,7 +185,7 @@ def main():
wrapperContent += generateFunction(targetClass, functionName, wrapArgs, callArgs) + "\n"


wrapperContent += "void ::Murmur::MetaI::getSlice_async(const ::Murmur::AMD_Meta_getSlicePtr &cb, const Ice::Current&) {\n"
wrapperContent += "void ::MumbleServer::MetaI::getSlice_async(const ::MumbleServer::AMD_Meta_getSlicePtr &cb, const Ice::Current&) {\n"
wrapperContent += "\tcb->ice_response(std::string(\"" + iceSpec + "\"));\n"
wrapperContent += "}\n"

Expand Down
16 changes: 8 additions & 8 deletions src/murmur/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(MURMUR_PLIST "${CMAKE_CURRENT_BINARY_DIR}/murmur.plist")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/murmur.plist.in" "${MURMUR_PLIST}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/murmur.rc.in" "${MURMUR_RC}")

set(ICE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Murmur.ice")
set(ICE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/MumbleServer.ice")

include(qt-utils)

Expand Down Expand Up @@ -235,18 +235,18 @@ if(ice)
)

add_custom_target(generate_murmur_ice_wrapper
DEPENDS "MurmurIceWrapper.cpp"
DEPENDS "MumbleServerIceWrapper.cpp"
)
add_dependencies(mumble-server generate_murmur_ice_wrapper)
add_custom_command(
OUTPUT "MurmurIceWrapper.cpp"
OUTPUT "MumbleServerIceWrapper.cpp"
COMMAND ${PYTHON_INTERPRETER}
ARGS "${CMAKE_SOURCE_DIR}/scripts/generateIceWrapper.py" -i "${ICE_FILE}"
-g "${ICE_FILE_NAME}.h" -o "MurmurIceWrapper.cpp" -q
-g "${ICE_FILE_NAME}.h" -o "MumbleServerIceWrapper.cpp" -q
DEPENDS ${ICE_GENERATED_FILES}
COMMENT "Generating MurmurIceWrapper"
COMMENT "Generating MumbleServerIceWrapper"
)
# Even though the file is a .cpp, it is still being included in MurmurIce.cpp
# Even though the file is a .cpp, it is still being included in MumbleServerIce.cpp
target_include_directories(mumble-server PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")

# We explicitly tell CMake not to call any autogen tools (e.g. MOC) for the generated files.
Expand All @@ -255,8 +255,8 @@ if(ice)

target_sources(mumble-server
PRIVATE
"MurmurIce.cpp"
"MurmurIce.h"
"MumbleServerIce.cpp"
"MumbleServerIce.h"
${ICE_GENERATED_FILES}
)
target_compile_definitions(mumble-server
Expand Down
2 changes: 1 addition & 1 deletion src/murmur/Murmur.ice → src/murmur/MumbleServer.ice
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <Ice/SliceChecksumDict.ice>

module Murmur
module MumbleServer
{

/** A network address in IPv6 format.
Expand Down
Loading

0 comments on commit b81b060

Please sign in to comment.