client: add certificate parameters

This commit is contained in:
Username
2026-02-24 14:15:24 +01:00
parent e9944c88eb
commit 6467f5fe32
2 changed files with 30 additions and 3 deletions

View File

@@ -48,11 +48,15 @@ class MumbleClient:
port: int = 64738,
username: str = "tuimble-user",
password: str = "",
certfile: str = "",
keyfile: str = "",
):
self._host = host
self._port = port
self._username = username
self._password = password
self._certfile = certfile
self._keyfile = keyfile
self._mumble = None
self._connected = False
self._dispatcher: Callable | None = None
@@ -137,12 +141,19 @@ class MumbleClient:
"""Connect to the Mumble server (blocking)."""
import pymumble_py3 as pymumble
kwargs = {
"port": self._port,
"password": self._password,
"reconnect": False,
}
if self._certfile:
kwargs["certfile"] = self._certfile
if self._keyfile:
kwargs["keyfile"] = self._keyfile
self._mumble = pymumble.Mumble(
self._host,
self._username,
port=self._port,
password=self._password,
reconnect=False,
**kwargs,
)
self._mumble.set_codec_profile("audio")
self._mumble.set_receive_sound(True)

View File

@@ -67,3 +67,19 @@ def test_set_self_deaf_noop_when_disconnected():
client = MumbleClient(host="localhost")
# Should not raise when not connected
client.set_self_deaf(True)
def test_cert_defaults():
client = MumbleClient(host="localhost")
assert client._certfile == ""
assert client._keyfile == ""
def test_cert_custom():
client = MumbleClient(
host="localhost",
certfile="/path/cert.pem",
keyfile="/path/key.pem",
)
assert client._certfile == "/path/cert.pem"
assert client._keyfile == "/path/key.pem"