From 8ce558f701387eb615011642f34e5c961db8d348 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 10 Mar 2016 22:07:04 -0800 Subject: [PATCH] Uniqueid should be a 64-bit hex number, not a UUID --- static/js/index.js | 20 ++++++++++---------- static/js/utils.js | 7 +++++++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 10698b0..6c9c45d 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -1,7 +1,7 @@ var target = ""; var hosts = []; var pairingCert; -var myGuuid; +var myUniqueid; // Called by the common.js module. function attachListeners() { @@ -31,10 +31,10 @@ function moduleDidLoad() { console.log("Generated new cert.") }); } - if(!myGuuid) { - console.log("Failed to get guuid. Generating new one"); - myGuuid = guuid(); - storeData('guuid', myGuuid, null); + if(!myUniqueid) { + console.log("Failed to get uniqueId. Generating new one"); + myUniqueid = uniqueid(); + storeData('uniqueid', myUniqueid, null); } } @@ -60,7 +60,7 @@ function pairPushed() { target = e.options[e.selectedIndex].value; } console.log("Attempting to pair to: " + target); - sendMessage('httpInit', [pairingCert.cert, pairingCert.privateKey, myGuuid]).then(function (ret) { + sendMessage('httpInit', [pairingCert.cert, pairingCert.privateKey, myUniqueid]).then(function (ret) { console.log('httpInit function completed. it returned: ' + ret); sendMessage('pair', [target, "1233"]).then(function (ret2) { console.log("pair attempt to to " + target + " has returned."); @@ -107,8 +107,8 @@ function startPushed() { console.log('startRequest:' + target + ":" + streamWidth + ":" + streamHeight + ":" + frameRate + ":" + bitrate); - sendMessage('httpInit', [pairingCert.cert, pairingCert.privateKey, myGuuid]).then(function (ret) { sendMessage('startRequest', [target, streamWidth, streamHeight, frameRate, bitrate.toString()]); + sendMessage('httpInit', [pairingCert.cert, pairingCert.privateKey, myUniqueid]).then(function (ret) { }); // we just finished the gameSelection section. only expose the NaCl section @@ -233,9 +233,9 @@ function onWindowLoad(){ pairingCert = savedCert.cert; } }); - chrome.storage.sync.get('guuid', function(savedGuuid) { - if (savedGuuid.guuid != null) { // we have a saved guuid - myGuuid = savedGuuid.guuid; + chrome.storage.sync.get('uniqueid', function(savedUniqueid) { + if (savedUniqueid.uniqueid != null) { // we have a saved uniqueid + myUniqueid = savedUniqueid.uniqueid; } }) } diff --git a/static/js/utils.js b/static/js/utils.js index a5d30d8..842d4d9 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -5,6 +5,13 @@ function guuid() { }); } +function uniqueid() { + return 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function(c) { + var r = Math.random()*16|0; + return r.toString(16); + }); +} + String.prototype.toHex = function() { var hex = ''; for(var i = 0; i < this.length; i++) {