voip.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright 2014-2016 OpenMarket Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from ._base import Config
  15. class VoipConfig(Config):
  16. def read_config(self, config):
  17. self.turn_uris = config.get("turn_uris", [])
  18. self.turn_shared_secret = config.get("turn_shared_secret")
  19. self.turn_username = config.get("turn_username")
  20. self.turn_password = config.get("turn_password")
  21. self.turn_user_lifetime = self.parse_duration(config["turn_user_lifetime"])
  22. self.turn_allow_guests = config.get("turn_allow_guests", True)
  23. def default_config(self, **kwargs):
  24. return """\
  25. ## Turn ##
  26. # The public URIs of the TURN server to give to clients
  27. turn_uris: []
  28. # The shared secret used to compute passwords for the TURN server
  29. turn_shared_secret: "YOUR_SHARED_SECRET"
  30. # The Username and password if the TURN server needs them and
  31. # does not use a token
  32. #turn_username: "TURNSERVER_USERNAME"
  33. #turn_password: "TURNSERVER_PASSWORD"
  34. # How long generated TURN credentials last
  35. turn_user_lifetime: "1h"
  36. # Whether guests should be allowed to use the TURN server.
  37. # This defaults to True, otherwise VoIP will be unreliable for guests.
  38. # However, it does introduce a slight security risk as it allows users to
  39. # connect to arbitrary endpoints without having first signed up for a
  40. # valid account (e.g. by passing a CAPTCHA).
  41. turn_allow_guests: True
  42. """