Skip to content

Instantly share code, notes, and snippets.

@hongkongkiwi
Last active August 29, 2015 14:05
Show Gist options
  • Save hongkongkiwi/2b736e4045f2123c3051 to your computer and use it in GitHub Desktop.
Save hongkongkiwi/2b736e4045f2123c3051 to your computer and use it in GitHub Desktop.
var moment = require('moment'),
crypto = require('crypto');
function getICEServerJSON(username) {
var ttl = 86400;
var expiry = moment().add(ttl, 'seconds').unix();
var usernameToken = expiry + ":" + username;
var secret = "mysupersecret";
var nonce = crypto.createHmac("sha1", secret).update(usernameToken).digest("base64");
return {
"username" : usernameToken,
"password" : nonce,
"ttl" : ttl,
"uris" : [
"stun:127.0.0.1",
"turn:127.0.0.1"
]
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment