-
-
Notifications
You must be signed in to change notification settings - Fork 869
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tweaked the php turn server code a bit to make it slightly easier
- Loading branch information
1 parent
694d761
commit 4cfe930
Showing
2 changed files
with
55 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
<?php | ||
// If using static-auth-secret for your turn server, modify this file as needed; also rename to "turn-credentials.php" | ||
// If using static-auth-secret for your turn server, modify this file as needed; also rename to "turn-credentials.php" | ||
|
||
$expiry = 86400; | ||
$username = time() + $expiry; | ||
$secret = '<static-auth-secret>'; | ||
$password = base64_encode ( hash_hmac ( 'sha1', $username, $secret, true ) ); | ||
|
||
$turn_server = "turns:<turn-server>:<https-turn-port>"; // "turns" or "turn", depending on your turn server setup | ||
$stun_server = "stun:<stun-server>:<stun-port>"; // We're assuming our turn server also offers stun; uses the same username/password | ||
|
||
$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); | ||
$arr = array($username, $password, $turn_server, $stun_server); | ||
|
||
// $arr = array($username, $password, $turn_server); // We can use this instead if using Google STUN | ||
|
||
echo json_encode($arr); | ||
?> | ||
|
||
// sample output: [1674572313,"iTofoKaflP\/pjyJOgUwstTUoT2Q=","turns:<turn-server>:<https-turn-port>","stun:<stun-server>:<stun-port>"] | ||
?> |
4cfe930
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may change this again in the future, to make it not so rigid and compressed in structure, but it should currently still meet the needs of the target audience. This change was made so that google stun servers can be used, and no javascript coding knowledge is needed to tweak things -- by a user's request.