Trying to check useragent

This commit is contained in:
Kasper Rynning-Tønnesen
2018-06-05 10:35:25 +02:00
parent 4e77585a27
commit 94182ddaf7
2 changed files with 6 additions and 3 deletions

View File

@@ -71,6 +71,7 @@ app.get('/robots.txt', function (req, res) {
}); });
app.use(function (req, res, next) { app.use(function (req, res, next) {
console.log("User agent", req.get("User-Agent"));
var cookie = req.cookies._uI; var cookie = req.cookies._uI;
if (cookie === undefined) { if (cookie === undefined) {
var user_name = Functions.hash_pass(Functions.rndName(uniqid.time(), 15)); var user_name = Functions.hash_pass(Functions.rndName(uniqid.time(), 15));

View File

@@ -22,6 +22,7 @@ var db = require(pathThumbnails + '/handlers/db.js');
module.exports = function() { module.exports = function() {
io.on('connection', function(socket){ io.on('connection', function(socket){
try { try {
console.log("Full cookies", cookie.parse(socket.handshake.headers.cookie));
var parsedCookies = cookie.parse(socket.handshake.headers.cookie); var parsedCookies = cookie.parse(socket.handshake.headers.cookie);
socket.cookie_id = parsedCookies["_uI"]; socket.cookie_id = parsedCookies["_uI"];
//return socket.guid; //return socket.guid;
@@ -88,6 +89,7 @@ module.exports = function() {
msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" && msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel") && typeof(msg.guid) == "string" &&
typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") { typeof(msg.channel) == "string" && typeof(msg.socket_id) == "string" && msg.channel != "") {
db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) { db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) {
console.log("another error");
console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel) console.log("test: ", connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel.length > 0, connected_users_channel[0].users.indexOf(msg.guid) > -1, connected_users_channel)
if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) { if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) {
coll = msg.channel.toLowerCase();//.replace(/ /g,''); coll = msg.channel.toLowerCase();//.replace(/ /g,'');
@@ -99,7 +101,7 @@ module.exports = function() {
/*Functions.setChromecastHost(socket.cookie_id, msg.guid, msg.channel, function(results) { /*Functions.setChromecastHost(socket.cookie_id, msg.guid, msg.channel, function(results) {
console.log("setChromecastHost: ", results); console.log("setChromecastHost: ", results);
});*/ });*/
socket.cookie_id = msg.guid; //socket.cookie_id = msg.guid;
guid = msg.guid; guid = msg.guid;
socketid = msg.socket_id; socketid = msg.socket_id;
socket.zoff_id = socketid; socket.zoff_id = socketid;
@@ -114,14 +116,14 @@ module.exports = function() {
}); });
} }
} catch(e) { } catch(e) {
console.log(e); console.log("this is the crash" + e);
return; return;
} }
}); });
socket.on("get_id", function() { socket.on("get_id", function() {
console.log("gotten request from mobile", Functions.getSession(socket)); console.log("gotten request from mobile", Functions.getSession(socket));
socket.emit("id_chromecast", guid); socket.emit("id_chromecast", Functions.getSession(socket));
}); });
socket.on("error_video", function(msg) { socket.on("error_video", function(msg) {