mirror of
https://github.com/eliasstepanik/vdo.ninja.git
synced 2026-01-26 04:48:29 +00:00
move turn-credentials request to index.html
main.js remove the section with the request to the turn-credentials.php script index.html add and uncomment the request to the turn-credentials.php script
This commit is contained in:
parent
11ad42bf34
commit
b6c966197a
37
index.html
37
index.html
@ -1577,8 +1577,41 @@
|
||||
// turn.urls = ["turn:turn2.obs.ninja:443"]; // US WEST
|
||||
// session.configuration.iceServers.push(turn);
|
||||
|
||||
// session.turnmode == "twilio" // uncomment to use credentials for the turn-server provided by Twilio
|
||||
// session.turnmode = "php-credentials" // uncomment to distribute the turn-username, -password and -server via running turn-credentials.php, e.g., if you have a turn-server with a static-auth-secret
|
||||
// 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
|
||||
|
||||
|
||||
41
main.js
41
main.js
@ -2474,7 +2474,7 @@ if (urlParams.has('speedtest')){ // forces essentially UDP mode, unless TCP is s
|
||||
|
||||
if (urlParams.has('turn')) {
|
||||
var turnstring = urlParams.get('turn');
|
||||
if (turnstring == "twilio" || session.turnmode == "twilio") { // a sample function on loading remote credentials for TURN servers.
|
||||
if (turnstring == "twilio") { // a sample function on loading remote credentials for TURN servers.
|
||||
try {
|
||||
|
||||
session.ws = false; // prevents connection
|
||||
@ -2515,45 +2515,6 @@ if (urlParams.has('turn')) {
|
||||
errorlog("Twilio Failed");
|
||||
}
|
||||
|
||||
} else if (turnstring == "php-credentials" || session.turnmode == "php-credentials") { // a function loading the turn server credentials from the provided php-script "turn-credentials.php"
|
||||
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");
|
||||
}
|
||||
|
||||
} else if ((turnstring == "false") || (turnstring == "off") || (turnstring == "0")) { // disable TURN servers
|
||||
session.configuration = {
|
||||
iceServers: [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user