INNER CODE UNIT · Python
exp
selkies-project/selkies · addons/turn-rest/app.py:149
exp = int(time.time()) + ttl
username = "{}:{}".format(exp, user)
# coturn's use-auth-secret scheme: password = b64(HMAC-SHA1(secret, username)).
hashed = hmac.new(bytes(shared_secret, "utf-8"), bytes(username, "utf-8"), hashlib.sha1).digest()
password = base64.b64encode(hashed).decode()
turn_uri = "{}:{}:{}?transport={}".format('turns' if turn_tls else 'turn', format_ice_host(host), port, protocol)
rtc_config = {}
rtc_config["username"] = username
rtc_config["password"] = password
rtc_config["ttl"] = ttl
rtc_config["uris"] = [turn_uri]
return jsonify(rtc_config)
def _development_servers(addr: str, port: int) -> list: