class plinth.modules.coturn.components.TurnConsumer(component_id)[source]

Component to manage coturn configuration.

In order to provide audio/video calling functionality, communication servers very often use an external server such as Coturn for implementing the STUN/TURN protocol. To use Coturn, the server needs to be configured with a set of URIs provided by Coturn along with a shared secret.

This component when added to an app allows the app to retrieve the current Coturn configuration and respond to any future configuration changes.


Initialize the component.

component_id should be a unique ID across all components of an app and across all components.


Return current coturn configuration.

classmethod list()list[source]

Return a list of all Coturn components.

on_config_change(config: plinth.modules.coturn.components.TurnConfiguration)[source]

Add or update STUN/TURN configuration.

Override this method and change app’s configuration.

class plinth.modules.coturn.components.TurnConfiguration(domain: Optional[str] = None, uris: list = <factory>, shared_secret: Optional[str] = None)[source]

Data class to hold TURN server configuration.

domain is the string representing the domain name with which Coturn has been configured. This is necessary to associate the correct TLS certificate with Coturn communication. STUN/TURN URIs are generated using this.

shared_secret is a string that must be used by a server to be accepted by Coturn server. This is the value set in Coturn configuration file.

uris are a list of strings that represent the full set of STUN/TURN URIs that must be used by a STUN/TURN client after advice from the server.


Return a JSON representation of the configuration.

static validate_turn_uris(turn_uris: list)bool[source]

Return whether the given TURN URI is valid.