diff options
-rw-r--r-- | kvmd/apps/__init__.py | 2 | ||||
-rw-r--r-- | kvmd/apps/janus/runner.py | 18 |
2 files changed, 14 insertions, 6 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 323b8334..7d786bc4 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -723,7 +723,7 @@ def _get_config_scheme() -> dict: "--plugins-folder=/usr/lib/ustreamer/janus", "--configs-folder=/etc/kvmd/janus", "--interface={src_ip}", - "--stun-server={stun_host}:{stun_port}", + "{o_stun_server}", ], type=valid_command), "cmd_remove": Option([], type=valid_options), "cmd_append": Option([], type=valid_options), diff --git a/kvmd/apps/janus/runner.py b/kvmd/apps/janus/runner.py index c2d01dad..af7e064d 100644 --- a/kvmd/apps/janus/runner.py +++ b/kvmd/apps/janus/runner.py @@ -78,11 +78,11 @@ class JanusRunner: # pylint: disable=too-many-instance-attributes if netcfg != prev_netcfg: logger.info("Got new %s", netcfg) - if netcfg.src_ip and netcfg.ext_ip: + if netcfg.src_ip: await self.__stop_janus() await self.__start_janus(netcfg) else: - logger.error("Empty src_ip or ext_ip; stopping Janus ...") + logger.error("Empty src_ip; stopping Janus ...") await self.__stop_janus() prev_netcfg = netcfg @@ -160,12 +160,20 @@ class JanusRunner: # pylint: disable=too-many-instance-attributes async def __start_janus_proc(self, netcfg: _Netcfg) -> None: assert self.__janus_proc is None placeholders = { - key: str(value) - for (key, value) in dataclasses.asdict(netcfg).items() + "o_stun_server": f"--stun-server={netcfg.stun_host}:{netcfg.stun_port}", + **{ + key: str(value) + for (key, value) in dataclasses.asdict(netcfg).items() + }, } + cmd = list(self.__cmd) + if not netcfg.ext_ip: + placeholders["o_stun_server"] = "" + while "{o_stun_server}" in cmd: + cmd.remove("{o_stun_server}") cmd = [ part.format(**placeholders) - for part in self.__cmd + for part in cmd ] self.__janus_proc = await aioproc.run_process(cmd) get_logger(0).info("Started Janus pid=%d: %s", self.__janus_proc.pid, tools.cmdfmt(cmd)) |