mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 09:50:24 +00:00
Fixed issue with unique id crashing server
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
0 info it worked if it ends with ok
|
||||
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
|
||||
2 info using npm@3.10.10
|
||||
3 info using node@v6.10.3
|
||||
4 verbose stack Error: missing script: start
|
||||
4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:151:19)
|
||||
4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:61:5
|
||||
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:356:5
|
||||
4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:320:45)
|
||||
4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:354:3)
|
||||
4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:5)
|
||||
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:311:12
|
||||
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
|
||||
4 verbose stack at tryToString (fs.js:456:3)
|
||||
4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:443:12)
|
||||
5 verbose cwd /Users/kasperrt/zoff
|
||||
6 error Darwin 16.6.0
|
||||
7 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
|
||||
8 error node v6.10.3
|
||||
9 error npm v3.10.10
|
||||
10 error missing script: start
|
||||
11 error If you need help, you may report this error at:
|
||||
11 error <https://github.com/npm/npm/issues>
|
||||
12 verbose exit [ 1, true ]
|
||||
@@ -20,6 +20,7 @@
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-uglifyjs": "^0.6.2",
|
||||
"gulp-util": "^3.0.8"
|
||||
"gulp-util": "^3.0.8",
|
||||
"uniqid": "^4.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,32 +17,11 @@ function remove_from_array(array, element){
|
||||
}
|
||||
}
|
||||
|
||||
function get_short_id(seed, minlen, socket) {
|
||||
var len = minlen;
|
||||
var id = rndName(seed, minlen, socket);
|
||||
function get_short_id(socket) {
|
||||
var new_short_id = uniqid.time().toLowerCase();
|
||||
|
||||
db.collection("unique_ids").update({"_id": "unique_ids"}, {$addToSet: {unique_ids: id}}, {upsert: true}, function(err, updated) {
|
||||
if(updated.nModified == 1) {
|
||||
short_id = id;
|
||||
socket.join(short_id);
|
||||
socket.emit("id", short_id);
|
||||
} else {
|
||||
get_short_id(rndName(String(len)+id, len + 0.1, socket));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function uniqueID(seed, minlen){
|
||||
var len = minlen;
|
||||
var id = rndName(seed, minlen);
|
||||
|
||||
db.collection("unique_ids").update({"_id": "unique_ids"}, {$addToSet: {unique_ids: id}}, function(err, updated) {
|
||||
if(updated.nModified == 1) {
|
||||
return id;
|
||||
} else {
|
||||
return uniqueID(rndName(String(len)+id, len + 0.1));
|
||||
}
|
||||
});
|
||||
socket.join(new_short_id);
|
||||
socket.emit("id", new_short_id);
|
||||
}
|
||||
|
||||
function check_inlist(coll, guid, socket, offline)
|
||||
|
||||
@@ -19,7 +19,6 @@ io.on('connection', function(socket){
|
||||
var name = "";
|
||||
var short_id;
|
||||
get_name(guid, {announce: false});
|
||||
get_short_id(socketid, 4, socket);
|
||||
var offline = false;
|
||||
var chromecast_object = false;
|
||||
|
||||
@@ -175,7 +174,7 @@ io.on('connection', function(socket){
|
||||
socket.on('id', function(arr)
|
||||
{
|
||||
if(typeof(arr) == 'object')
|
||||
io.to(arr.id).emit(arr.id, {type: arr.type, value: arr.value});
|
||||
io.to(arr.id).emit(arr.id.toLowerCase(), {type: arr.type, value: arr.value});
|
||||
});
|
||||
|
||||
socket.on('list', function(msg)
|
||||
@@ -191,6 +190,7 @@ io.on('connection', function(socket){
|
||||
return;
|
||||
}
|
||||
list(msg, guid, coll, offline, socket);
|
||||
get_short_id(socket);
|
||||
});
|
||||
|
||||
socket.on('end', function(obj)
|
||||
|
||||
@@ -75,6 +75,7 @@ var io = require('socket.io')(server, {
|
||||
pingTimeout: 25000,
|
||||
}); //, "origins": ("https://zoff.me:443*,https://zoff.me:8080*,zoff.me:8080*,https://remote.zoff.me:443*,https://remote.zoff.me:8080*,https://fb.zoff.me:443*,https://fb.zoff.me:8080*,https://admin.zoff.me:443*,https://admin.zoff.me:8080*" + add)});
|
||||
var request = require('request');
|
||||
var uniqid = require('uniqid');
|
||||
|
||||
var crypto = require('crypto');
|
||||
var node_cryptojs = require('node-cryptojs-aes');
|
||||
@@ -116,6 +117,7 @@ db.on('error',function(err) {
|
||||
});
|
||||
|
||||
/* Resetting usernames, and connected users */
|
||||
db.collection("unique_ids").update({"_id": "unique_ids"}, {$set: {unique_ids: []}}, {multi: true, upsert: true}, function(err, docs){});
|
||||
db.collection("user_names").remove({"guid": {$exists: true}}, {multi: true, upsert: true}, function(err, docs){});
|
||||
db.collection("user_names").update({"_id": "all_names"}, {$set: {names: []}}, {multi: true, upsert: true}, function(err, docs){});
|
||||
db.collection("connected_users").update({users: {$exists: true}}, {$set: {users: []}}, {multi: true, upsert: true}, function(err, docs){});
|
||||
|
||||
@@ -87,6 +87,7 @@ var io = require('socket.io')(server, {
|
||||
pingTimeout: 25000,
|
||||
}); //, "origins": ("https://zoff.me:443*,https://zoff.me:8080*,zoff.me:8080*,https://remote.zoff.me:443*,https://remote.zoff.me:8080*,https://fb.zoff.me:443*,https://fb.zoff.me:8080*,https://admin.zoff.me:443*,https://admin.zoff.me:8080*" + add)});
|
||||
var request = require('request');
|
||||
var uniqid = require('uniqid');
|
||||
|
||||
var crypto = require('crypto');
|
||||
var node_cryptojs = require('node-cryptojs-aes');
|
||||
@@ -128,6 +129,7 @@ db.on('error',function(err) {
|
||||
});
|
||||
|
||||
/* Resetting usernames, and connected users */
|
||||
db.collection("unique_ids").update({"_id": "unique_ids"}, {$set: {unique_ids: []}}, {multi: true, upsert: true}, function(err, docs){});
|
||||
db.collection("user_names").remove({"guid": {$exists: true}}, {multi: true, upsert: true}, function(err, docs){});
|
||||
db.collection("user_names").update({"_id": "all_names"}, {$set: {names: []}}, {multi: true, upsert: true}, function(err, docs){});
|
||||
db.collection("connected_users").update({users: {$exists: true}}, {$set: {users: []}}, {multi: true, upsert: true}, function(err, docs){});
|
||||
@@ -155,7 +157,6 @@ io.on('connection', function(socket){
|
||||
var name = "";
|
||||
var short_id;
|
||||
get_name(guid, {announce: false});
|
||||
get_short_id(socketid, 4, socket);
|
||||
var offline = false;
|
||||
var chromecast_object = false;
|
||||
|
||||
@@ -311,7 +312,7 @@ io.on('connection', function(socket){
|
||||
socket.on('id', function(arr)
|
||||
{
|
||||
if(typeof(arr) == 'object')
|
||||
io.to(arr.id).emit(arr.id, {type: arr.type, value: arr.value});
|
||||
io.to(arr.id).emit(arr.id.toLowerCase(), {type: arr.type, value: arr.value});
|
||||
});
|
||||
|
||||
socket.on('list', function(msg)
|
||||
@@ -327,6 +328,7 @@ io.on('connection', function(socket){
|
||||
return;
|
||||
}
|
||||
list(msg, guid, coll, offline, socket);
|
||||
get_short_id(socket);
|
||||
});
|
||||
|
||||
socket.on('end', function(obj)
|
||||
@@ -572,32 +574,11 @@ function remove_from_array(array, element){
|
||||
}
|
||||
}
|
||||
|
||||
function get_short_id(seed, minlen, socket) {
|
||||
var len = minlen;
|
||||
var id = rndName(seed, minlen, socket);
|
||||
function get_short_id(socket) {
|
||||
var new_short_id = uniqid.time().toLowerCase();
|
||||
|
||||
db.collection("unique_ids").update({"_id": "unique_ids"}, {$addToSet: {unique_ids: id}}, {upsert: true}, function(err, updated) {
|
||||
if(updated.nModified == 1) {
|
||||
short_id = id;
|
||||
socket.join(short_id);
|
||||
socket.emit("id", short_id);
|
||||
} else {
|
||||
get_short_id(rndName(String(len)+id, len + 0.1, socket));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function uniqueID(seed, minlen){
|
||||
var len = minlen;
|
||||
var id = rndName(seed, minlen);
|
||||
|
||||
db.collection("unique_ids").update({"_id": "unique_ids"}, {$addToSet: {unique_ids: id}}, function(err, updated) {
|
||||
if(updated.nModified == 1) {
|
||||
return id;
|
||||
} else {
|
||||
return uniqueID(rndName(String(len)+id, len + 0.1));
|
||||
}
|
||||
});
|
||||
socket.join(new_short_id);
|
||||
socket.emit("id", new_short_id);
|
||||
}
|
||||
|
||||
function check_inlist(coll, guid, socket, offline)
|
||||
|
||||
Reference in New Issue
Block a user