Joseph Nuthalapati 2ffde1b646
matrix-synapse: Auto configure STUN/TURN using coturn server
- Matrix Synapse will automatically pick up the locally installed coturn server
during its installation. This handles only the case where coturn is installed
and configured with a valid TLS domain name before matrix-synapse is installed.

- Allow overriding STUN/TURN config. Matrix Synapse uses the local coturn
server's configuration by default. However, an administrator can override the
STUN/TURN configuration from FreedomBox web interface. Allow administrator's
overrides to co-exist with FreedomBox's managed STUN/TURN configuration.
Administrator's configuration, if it exists, always overrides FreedomBox's
managed configuration. Any updates to FreedomBox's managed configuration will
have no impact on the administrator's configuration since the latter takes
precedence.

Sunil:

- Collapse multiple turn actions into a single one for simplicity. Sending empty
configuration means removal of the configuration.

- Ensure that when removing configuration file is idempotent.

- Manage TURN configuration even when app setup is not yet completed. This fixes
issue with TURN configuration not getting setup on app installation and setup.

- Fix issue with TURN configuration getting updated on form submission even when
the field is not changed. This is due to mismatch between the browser submitted
\r\n with the internal \n.

- Simplify JavaScript for the form and attach handlers only after DOM is ready.

- Drop the no-JS message since the loss of functionality is trivial and to
reduce translation burden.

- Fix issue with URIs and secret parameters not getting updated unless the
managed checkbox changes.

- Drop specialized success messages for TURN configuration update to reduce
translation burden.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-02-28 16:28:53 -08:00

44 lines
1.7 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Forms for the Matrix Synapse module.
"""
from django import forms
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from plinth.utils import format_lazy
class MatrixSynapseForm(forms.Form):
enable_public_registration = forms.BooleanField(
label=_('Enable Public Registration'), required=False, help_text=_(
'Enabling public registration means that anyone on the Internet '
'can register a new account on your Matrix server. Disable this '
'if you only want existing users to be able to use it.'))
enable_managed_turn = forms.BooleanField(
label=_('Automatically manage audio/video call setup'), required=False,
help_text=format_lazy(
_('Configures the local <a href={coturn_url}>coturn</a> app as '
'the STUN/TURN server for Matrix Synapse. Disable this if you '
'want to use a different STUN/TURN server.'),
coturn_url=reverse_lazy('coturn:index')))
# STUN/TURN server setup
turn_uris = forms.CharField(
label=_('STUN/TURN Server URIs'), required=False, strip=True,
widget=forms.Textarea(attrs={'rows': 4}),
help_text=_('List of public URIs of the STUN/TURN server, one on each '
'line.'))
shared_secret = forms.CharField(
label=_('Shared Authentication Secret'), required=False, strip=True,
help_text=_('Shared secret used to compute passwords for the '
'TURN server.'))
def clean_turn_uris(self):
"""Normalize newlines in URIs."""
data = self.cleaned_data['turn_uris']
return '\n'.join([uri.strip() for uri in data.splitlines()])