mirror of
https://github.com/eliasstepanik/vdo.ninja.git
synced 2026-01-11 13:48:38 +00:00
Merge pull request #860 from Jumper78/feature/turn-server_with_static-auth-secret
turn-server with static-auth-secret in a separate php script
This commit is contained in:
commit
92197d6033
38
index.html
38
index.html
@ -2282,7 +2282,43 @@
|
||||
// session.configuration.iceServers.push(turn);
|
||||
/////////////// ------------ END OF TURN SETUP SECTION -------
|
||||
|
||||
// session.configuration.iceTransportPolicy = "relay"; // uncomment to enable "&privacy" and force the TURN server
|
||||
// use this section if you plan to use the turn-credentials.php to provide usename and password of the turn-server, e.g., because you use a turn-server that uses use-auth-secret and static-auth-secret
|
||||
// try {
|
||||
// session.ws = false; // prevents connection
|
||||
// var phpcredentialsRequest = new XMLHttpRequest();
|
||||
// phpcredentialsRequest.onreadystatechange = function() {
|
||||
// if (phpcredentialsRequest.status === 200) {
|
||||
// try{
|
||||
// var res = JSON.parse(phpcredentialsRequest.responseText);
|
||||
// } catch(e){return;}
|
||||
// session.configuration = {
|
||||
// iceServers: [{
|
||||
// "username": res["1"],
|
||||
// "credential": res["2"],
|
||||
// "urls": res["3"]
|
||||
// },
|
||||
// {
|
||||
// "username": res["1"],
|
||||
// "credential": res["2"],
|
||||
// "urls": res["4"]
|
||||
// }
|
||||
// ],
|
||||
// sdpSemantics: 'unified-plan' // future-proofing
|
||||
// };
|
||||
// if (session.ws===false){
|
||||
// session.ws=null; // allows connection (clears state)
|
||||
// session.connect(); // connect if not already connected.
|
||||
// }
|
||||
// }
|
||||
// // system does not connect if php script does not respond.
|
||||
// };
|
||||
// phpcredentialsRequest.open('GET', 'turn-credentials.php', true); // `false` makes the request synchronous
|
||||
// phpcredentialsRequest.send();
|
||||
// } catch (e) {
|
||||
// errorlog("php-credentials script Failed");
|
||||
// }
|
||||
|
||||
// session.configuration.iceTransportPolicy = "relay"; // uncomment to enable "&privacy" and force the TURN server
|
||||
|
||||
// session.wss = "wss://api.vdo.ninja:443"; // US-East (Default)
|
||||
|
||||
|
||||
13
turn-credentials-php.sample
Normal file
13
turn-credentials-php.sample
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
// If using static-auth-secret for your turn server, modify this file as needed; also rename to "turn-credentials.php"
|
||||
|
||||
$stun_server = "stun:<stun-server>:<stun-port>";
|
||||
$turn_server = "turns:<turn-server>:<https-turn-port>";
|
||||
$turn_expiry = 86400;
|
||||
$turn_username = time() + $turn_expiry;
|
||||
$turn_secret = '<turn-server static-auth-secret>';
|
||||
$turn_password = base64_encode ( hash_hmac ( 'sha1', $turn_username, $turn_secret, true ) );
|
||||
|
||||
$arr = array('1' => $turn_username, '2' => $turn_password, '3' => $stun_server, '4' => $turn_server);
|
||||
echo json_encode($arr);
|
||||
?>
|
||||
Loading…
x
Reference in New Issue
Block a user