voip.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. section = "voip"
  17. def read_config(self, config, **kwargs):
  18. self.turn_uris = config.get("turn_uris", [])
  19. self.turn_shared_secret = config.get("turn_shared_secret")
  20. self.turn_username = config.get("turn_username")
  21. self.turn_password = config.get("turn_password")
  22. self.turn_user_lifetime = self.parse_duration(
  23. config.get("turn_user_lifetime", "1h")
  24. )
  25. self.turn_allow_guests = config.get("turn_allow_guests", True)
  26. def generate_config_section(self, **kwargs):
  27. return """\
  28. ## TURN ##
  29. # The public URIs of the TURN server to give to clients
  30. #
  31. #turn_uris: []
  32. # The shared secret used to compute passwords for the TURN server
  33. #
  34. #turn_shared_secret: "YOUR_SHARED_SECRET"
  35. # The Username and password if the TURN server needs them and
  36. # does not use a token
  37. #
  38. #turn_username: "TURNSERVER_USERNAME"
  39. #turn_password: "TURNSERVER_PASSWORD"
  40. # How long generated TURN credentials last
  41. #
  42. #turn_user_lifetime: 1h
  43. # Whether guests should be allowed to use the TURN server.
  44. # This defaults to True, otherwise VoIP will be unreliable for guests.
  45. # However, it does introduce a slight security risk as it allows users to
  46. # connect to arbitrary endpoints without having first signed up for a
  47. # valid account (e.g. by passing a CAPTCHA).
  48. #
  49. #turn_allow_guests: true
  50. """