spantaleev / matrix-docker-ansible-deploy

🐳 Matrix (An open network for secure, decentralized communication) server setup using Ansible and Docker
GNU Affero General Public License v3.0
4.78k stars 1.03k forks source link

Using IP:port values in coturn bind_port vars breaks prosody config #3504

Closed sarah4d2 closed 3 weeks ago

sarah4d2 commented 3 weeks ago

I am using the playbook on a machine with multiple external IP addresses. In my vars.yml I have lines like the following:

matrix_coturn_container_stun_plain_host_bind_port: 'a.b.c.d:3478'
matrix_coturn_container_stun_tls_host_bind_port: 'a.b.c.d:5349'

This works as expected to cause coturn to bind to a.b.c.d, instead of trying to bind 0.0.0.0. However, the complete IP:port string is also passed unchanged into jitsi/prosody/config/conf.d/jitsi-meet.cfg.lua, resulting in broken syntax like this:

external_services = {
        { type = "turn", host = "turn.abc", port = a.b.c.d:3478, transport = "tcp", secret = true, ttl = 86400, algorithm = "turn" },
        { type = "turns", host = "turn.abc", port = a.b.c.d:5349, transport = "tcp", secret = true, ttl = 86400, algorithm = "turn" }
};

Instead of the correct syntax:

external_services = {
        { type = "turn", host = "turn.abc", port = 3478, transport = "tcp", secret = true, ttl = 86400, algorithm = "turn" },
        { type = "turns", host = "turn.abc", port = 5349, transport = "tcp", secret = true, ttl = 86400, algorithm = "turn" }
};

This causes Prosody to output a config parse error and fail to start.

The Jitsi vars are being set at group_vars/matrix_servers:3556:

jitsi_turn_port: "{{ matrix_coturn_container_stun_plain_host_bind_port if matrix_coturn_enabled else '' }}"
jitsi_turns_port: "{{ matrix_coturn_container_stun_tls_host_bind_port if matrix_coturn_enabled else '' }}"

OS: Arch Architecture: amd64

spantaleev commented 3 weeks ago

Thank you for the detailed report!

Could you check if the following changes to group_vars/matrix_servers fix the issue for you:

-jitsi_turn_port: "{{ matrix_coturn_container_stun_plain_host_bind_port if matrix_coturn_enabled else '' }}"
-jitsi_turns_port: "{{ matrix_coturn_container_stun_tls_host_bind_port if matrix_coturn_enabled else '' }}"
+jitsi_turn_port: "{{ matrix_coturn_container_stun_plain_host_bind_port.split(':')[-1] if matrix_coturn_enabled else '' }}"
+jitsi_turns_port: "{{ matrix_coturn_container_stun_tls_host_bind_port.split(':')[-1] if matrix_coturn_enabled else '' }}"
sarah4d2 commented 3 weeks ago

That does appear to fix it. Thank you!