client: add certificate parameters
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user