rename endpoint to better reflect what it is and allow specifying multiple uris

This commit is contained in:
David Baker 2014-09-24 16:01:36 +01:00
parent b42b0d3fe5
commit 5383ba5587
2 changed files with 6 additions and 8 deletions

View File

@ -19,7 +19,7 @@ class VoipConfig(Config):
def __init__(self, args): def __init__(self, args):
super(VoipConfig, self).__init__(args) super(VoipConfig, self).__init__(args)
self.turn_uri = args.turn_uri self.turn_uris = args.turn_uris.split(",")
self.turn_shared_secret = args.turn_shared_secret self.turn_shared_secret = args.turn_shared_secret
self.turn_user_lifetime = args.turn_user_lifetime self.turn_user_lifetime = args.turn_user_lifetime
@ -28,8 +28,8 @@ class VoipConfig(Config):
super(VoipConfig, cls).add_arguments(parser) super(VoipConfig, cls).add_arguments(parser)
group = parser.add_argument_group("voip") group = parser.add_argument_group("voip")
group.add_argument( group.add_argument(
"--turn-uri", type=str, default=None, "--turn-uris", type=str, default=None,
help="The public URI of the TURN server to give to clients" help="The public URIs of the TURN server to give to clients"
) )
group.add_argument( group.add_argument(
"--turn-shared-secret", type=str, default=None, "--turn-shared-secret", type=str, default=None,

View File

@ -24,13 +24,13 @@ import base64
class VoipRestServlet(RestServlet): class VoipRestServlet(RestServlet):
PATTERN = client_path_pattern("/voip/turnuris$") PATTERN = client_path_pattern("/voip/turnServers$")
@defer.inlineCallbacks @defer.inlineCallbacks
def on_GET(self, request): def on_GET(self, request):
auth_user = yield self.auth.get_user_by_req(request) auth_user = yield self.auth.get_user_by_req(request)
turnUri = self.hs.config.turn_uri turnUris = self.hs.config.turn_uris
turnSecret = self.hs.config.turn_shared_secret turnSecret = self.hs.config.turn_shared_secret
userLifetime = self.hs.config.turn_user_lifetime userLifetime = self.hs.config.turn_user_lifetime
if not turnUri or not turnSecret or not userLifetime: if not turnUri or not turnSecret or not userLifetime:
@ -49,9 +49,7 @@ class VoipRestServlet(RestServlet):
'username': username, 'username': username,
'password': password, 'password': password,
'ttl': userLifetime / 1000, 'ttl': userLifetime / 1000,
'uris': [ 'uris': turnUris,
turnUri,
]
}) ) }) )
def on_OPTIONS(self, request): def on_OPTIONS(self, request):