[mod] Mumble Bridge [mumble_bridge]

Post Reply
User avatar
apercy
Member
Posts: 638
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

[mod] Mumble Bridge [mumble_bridge]

by apercy » Post

Mumble Bridge for positional audio

First: This only works with mumble 1.4 or above (and for while, only for linux)

I know about the Elkiens mumble wrapper and how it's more efficient, but I need something more transparent and I'll work on a plugin in future. So lets go:

This mod is divided into two parts.
The first part, in lua, runs on the server, creating an UDP connection, which when it receives a username, returns with positional coordinates.
It can be tested using the command on linux "nc -u address 44000".
So just type a username that is logged into the server and the "nc" will list positional data as the user moves.
In this part of the mod was used the formatting pattern of the mod "minetest-mumble-wrapper", created by Elkien3.
This plugin needs to be added to minetest.conf in the "secure.trusted_mods" list, as it uses a compiled socket library
And you have to adjust the lines 14 and 15 for your server context. I'll try a more elegant way in future, I'm lazy today.

The second part of the mod is a binary, which the source code is in the wrapper directory for those who want to compile it for themselves.
This binary connects to the UDP port created on the server by the mod in lua. Then it processes the formatted data and sends it to mumble's "Link" plugin.
This binary called "wrapper" needs 2 parameters: the first is the address of the minetest server, and the second the username of the user on the server.
It should be used like this: "wrapper minetest.server.address Sam".
Before running it, you must have mumble loaded and logged in. Ideally, all users are logged into the same mumble server, so they can find each other.
When running the wrapper, we will have positional audio WITHOUT using a CSM or saturating the log with information.
But for obvious reasons the Elkien3 mod is much faster, as it does not depend on the server to retrieve this positional data.
So, to this wrapper works, the server have to support it, running the lua mod.


But before we put all to work together, lets set some options on mumble:
Open "Configure" menu and go to "Audio Output". Once there, mark "Positional Audio" checkbox.
Then go to "Plugins" and first mark "Link To Game and Transmit Position" option.
And mark as "active" the plugin named "Link".
Again at Audio Output, we recommend the following configuration:
Minimal distance as 1m
Max distance = 40m
Min volume = 0


Then you have just open and connect the mumble first, enter at the world/server on minetest as a second step, and finally execute the wrapper with the required parameters.

I compiled the wrapper for linux, but I suggest you to compile for yourself. And if someone could adjust it for windows, I'll be gratefull.

github:
https://github.com/APercy/mumble_bridge

The mod itself uses MIT licence
The socket lib uses MIT licence
The SharedMemory lib used by the wrapper, uses the mumble licence.
Last edited by apercy on Sat Mar 05, 2022 10:08, edited 2 times in total.

User avatar
Festus1965
Member
Posts: 4181
Joined: Sun Jan 03, 2016 11:58
GitHub: Festus1965
In-game: Festus1965 Thomas Thailand Explorer
Location: Thailand ChiangMai
Contact:

Re: [mod] Mumble Bridge [mumble_bridge]

by Festus1965 » Post

Oh, yes ... that I will test, as e still use this after 5 years ... free software.
Human has no future (climate change)
If urgend, you find me in Roblox (as CNXThomas)

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [mod] Mumble Bridge [mumble_bridge]

by Desour » Post

You are not using the insecure environment correctly, some easily found vulnerabilities:
* You are writing the require of the insecure env into the global env. _G can have a metatable set by mods to catch this, so you are leaking the insecure require to other mods.
* Any function from the global environment can be overwritten (ie. assert, pairs, ...). You should use the functions from the insecure env instead. luacheck can help to catch this.
* The minetest global (including the one in the insecure env) can not be trusted either. Ie. get_modpath can return anything.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
apercy
Member
Posts: 638
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Mumble Bridge [mumble_bridge]

by apercy » Post

DS-minetest wrote:
Sat Mar 05, 2022 16:14
You are not using the insecure environment correctly, some easily found vulnerabilities:
* You are writing the require of the insecure env into the global env. _G can have a metatable set by mods to catch this, so you are leaking the insecure require to other mods.
* Any function from the global environment can be overwritten (ie. assert, pairs, ...). You should use the functions from the insecure env instead. luacheck can help to catch this.
* The minetest global (including the one in the insecure env) can not be trusted either. Ie. get_modpath can return anything.
okay, I'll fix

User avatar
apercy
Member
Posts: 638
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Mumble Bridge [mumble_bridge]

by apercy » Post

I believe it's okay now. Could you see if are all okay now, please?

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [mod] Mumble Bridge [mumble_bridge]

by Desour » Post

apercy wrote:
Sat Mar 05, 2022 18:27
I believe it's okay now. Could you see if are all okay now, please?
It's not.
Global `require` is still overridden. Things like `assert(socket.udp())` leak stuff to other mods.

Btw. you can do std = {read_globals = {"_G"}} in luacheck, and then use _G.stuff() instead of stuff().
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
apercy
Member
Posts: 638
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Mumble Bridge [mumble_bridge]

by apercy » Post

DS-minetest wrote:
Sat Mar 05, 2022 19:38
apercy wrote:
Sat Mar 05, 2022 18:27
I believe it's okay now. Could you see if are all okay now, please?
It's not.
Global `require` is still overridden. Things like `assert(socket.udp())` leak stuff to other mods.

Btw. you can do std = {read_globals = {"_G"}} in luacheck, and then use _G.stuff() instead of stuff().
right, but I need overwrite "require" to load socket lua lib, because request_insecure_environment can only be called from mod main scope and inside socket lib the require is needed to load more 3 libs
error.png
error.png (41.31 KiB) Viewed 2572 times
error2.png
error2.png (18.21 KiB) Viewed 2572 times
So it's why I have to do this and return it after
error3.png
error3.png (12.66 KiB) Viewed 2571 times

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [mod] Mumble Bridge [mumble_bridge]

by Desour » Post

apercy wrote:
Sat Mar 05, 2022 20:24
DS-minetest wrote:
Sat Mar 05, 2022 19:38
apercy wrote:
Sat Mar 05, 2022 18:27
I believe it's okay now. Could you see if are all okay now, please?
It's not.
Global `require` is still overridden. Things like `assert(socket.udp())` leak stuff to other mods.

Btw. you can do std = {read_globals = {"_G"}} in luacheck, and then use _G.stuff() instead of stuff().
right, but I need overwrite "require" to load socket lua lib, because request_insecure_environment can only be called from mod main scope and inside socket lib the require is needed to load more 3 libs
Well, using the insec env in minetest is not really easy.

I haven't used require for a lib implemented in lua yet in minetest.
But maybe setfenv can be used.

Btw. _G.assert(socket.udp()) is not better than _G.assert(socket.udp()). With IE being the insec env, you can replace it with IE.assert(socket.udp()).

Edit: Because of own needs I've tried to write a require() wrapper. I really hope I didn't misunderstand something about envs.
Edit2: Code removed. See issue instead.
Last edited by Desour on Sun Mar 06, 2022 20:33, edited 2 times in total.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
apercy
Member
Posts: 638
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Mumble Bridge [mumble_bridge]

by apercy » Post

Thank you, I will fix it when I’m in home later

User avatar
apercy
Member
Posts: 638
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Mumble Bridge [mumble_bridge]

by apercy » Post

DS-minetest wrote:
Sat Mar 05, 2022 22:30
apercy wrote:
Sat Mar 05, 2022 20:24
DS-minetest wrote:
Sat Mar 05, 2022 19:38


It's not.
Global `require` is still overridden. Things like `assert(socket.udp())` leak stuff to other mods.

Btw. you can do std = {read_globals = {"_G"}} in luacheck, and then use _G.stuff() instead of stuff().
right, but I need overwrite "require" to load socket lua lib, because request_insecure_environment can only be called from mod main scope and inside socket lib the require is needed to load more 3 libs
Well, using the insec env in minetest is not really easy.

I haven't used require for a lib implemented in lua yet in minetest.
But maybe setfenv can be used.

Btw. _G.assert(socket.udp()) is not better than _G.assert(socket.udp()). With IE being the insec env, you can replace it with IE.assert(socket.udp()).

Edit: Because of own needs I've tried to write a require() wrapper. I really hope I didn't misunderstand something about envs.

Code: Select all

-- the same as `IE.require(...)`, but sets the env to IE
local function require_with_IE_env(...)
	local old_thread_env = IE.getfenv(0)

	-- set env of thread
	-- (the loader used by IE.require will probably use the thread env for
	-- the loaded functions)
	IE.setfenv(0, IE)

	-- (IE.require's env is neither _G, nor IE. we need to leave it like this,
	-- otherwise it won't find the loaders (it uses the global `loaders`, not
	-- `package.loaders` btw. (see luajit/src/lib_package.c)))

	-- we might be pcall()ed, so we need to pcall to make sure that we reset
	-- the thread env afterwards
	local ok, ret = IE.pcall(IE.require, ...)

	-- reset env of thread
	IE.setfenv(0, old_thread_env)

	if not ok then
		IE.error(ret)
	end
	return ret
end
It doesn't recognize IE. I'll look for tomorrow where I'm wrong
error.png
error.png (41.14 KiB) Viewed 2478 times

User avatar
apercy
Member
Posts: 638
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Mumble Bridge [mumble_bridge]

by apercy » Post

fixed the assert today. But that require wrapper don't work yet :( .
And about the overwrite of the require function, I found this issue created by rubenwardy, pointing out the vulnerability.
https://github.com/minetest/minetest/issues/10877

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [mod] Mumble Bridge [mumble_bridge]

by Desour » Post

IE was supposed to be the insec env, I thought it was clear our of context.

Thanks for linking the issue!
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
apercy
Member
Posts: 638
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Mumble Bridge [mumble_bridge]

by apercy » Post

done. And thank you!

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [mod] Mumble Bridge [mumble_bridge]

by Desour » Post

FYI, I forgot some stuff. The issue now hosts the code.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
sparky
Member
Posts: 154
Joined: Sun Oct 05, 2014 00:54
GitHub: Elkien3
IRC: ircSparky
In-game: sparky
Location: USA
Contact:

Re: [mod] Mumble Bridge [mumble_bridge]

by sparky » Post

Ooo nice, glad people are working on more solutions for mumble pa.

User avatar
apercy
Member
Posts: 638
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

Re: [mod] Mumble Bridge [mumble_bridge]

by apercy » Post

sparky wrote:
Wed Aug 10, 2022 15:56
Ooo nice, glad people are working on more solutions for mumble pa.
I stopped it for a while, I was testing a more drastic and dangerous solution:

viewtopic.php?f=9&t=27875

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 13 guests