Added queue debugging.
This commit is contained in:
parent
db3ec58ad9
commit
f95a0ae48c
|
|
@ -8,6 +8,7 @@
|
||||||
"ytdlpPath": "/home/canopy/.local/pipx/venvs/yt-dlp/bin/yt-dlp",
|
"ytdlpPath": "/home/canopy/.local/pipx/venvs/yt-dlp/bin/yt-dlp",
|
||||||
"migrate": false,
|
"migrate": false,
|
||||||
"dropLegacyTokes": false,
|
"dropLegacyTokes": false,
|
||||||
|
"debug": false,
|
||||||
"secrets":{
|
"secrets":{
|
||||||
"passwordSecret": "CHANGE_ME",
|
"passwordSecret": "CHANGE_ME",
|
||||||
"rememberMeSecret": "CHANGE_ME",
|
"rememberMeSecret": "CHANGE_ME",
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,11 @@
|
||||||
//Requires migration to be disabled before it takes effect.
|
//Requires migration to be disabled before it takes effect.
|
||||||
//WARNING: this does NOT affect user toke counts, migrated or otherwise. Use carefully!
|
//WARNING: this does NOT affect user toke counts, migrated or otherwise. Use carefully!
|
||||||
"dropLegacyTokes": false,
|
"dropLegacyTokes": false,
|
||||||
|
//Enters the server into debug mode, allows specific commands to be emitted from the client-side dev console
|
||||||
|
//Usually to get the server to dump some sort of internal data for debugging purposes.
|
||||||
|
//Obviously, this means enabling this can have some gnar implications.
|
||||||
|
//Probably don't enable this on your production server unless you REALLY REALLY have to, and you probably don't.
|
||||||
|
"debug": false,
|
||||||
//Server Secrets
|
//Server Secrets
|
||||||
//Be careful with what you keep in secrets, you should use special chars, but test your deployment, as some chars may break account registration
|
//Be careful with what you keep in secrets, you should use special chars, but test your deployment, as some chars may break account registration
|
||||||
//An update to either kill the server and bitch about the issue in console is planned so it's not so confusing for new admins
|
//An update to either kill the server and bitch about the issue in console is planned so it's not so confusing for new admins
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||||
const validator = require('validator');
|
const validator = require('validator');
|
||||||
|
|
||||||
//Local imports
|
//Local imports
|
||||||
|
const config = require('../../../../config.json');
|
||||||
const queuedMedia = require('./queuedMedia');
|
const queuedMedia = require('./queuedMedia');
|
||||||
const yanker = require('../../../utils/media/yanker');
|
const yanker = require('../../../utils/media/yanker');
|
||||||
const loggerUtils = require('../../../utils/loggerUtils');
|
const loggerUtils = require('../../../utils/loggerUtils');
|
||||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||||
|
const permissionModel = require('../../../schemas/permissionSchema');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object represneting a single channel's media queue
|
* Object represneting a single channel's media queue
|
||||||
|
|
@ -114,6 +116,11 @@ class queue{
|
||||||
socket.on("move", (data) => {this.moveMedia(socket, data)});
|
socket.on("move", (data) => {this.moveMedia(socket, data)});
|
||||||
socket.on("lock", () => {this.toggleLock(socket)});
|
socket.on("lock", () => {this.toggleLock(socket)});
|
||||||
socket.on("goLive", (data) => {this.goLive(socket, data)});
|
socket.on("goLive", (data) => {this.goLive(socket, data)});
|
||||||
|
|
||||||
|
//If debug mode is enabled
|
||||||
|
if(config.debug){
|
||||||
|
socket.on("dumpQueue", (data) => {this.dumpQueue(socket, data)});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--- USER FACING QUEUEING FUNCTIONS ---
|
//--- USER FACING QUEUEING FUNCTIONS ---
|
||||||
|
|
@ -404,6 +411,44 @@ class queue{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async dumpQueue(socket, data){
|
||||||
|
//If we somehow got here while config.debug is disabled, or the user isn't allowed to preform server-side debugging
|
||||||
|
if(!(config.debug && await permissionModel.permCheck(socket.user, "debug"))){
|
||||||
|
//FUCKIN' CHEESE IT!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If a full data dump was requested
|
||||||
|
if(data != null && data.full){
|
||||||
|
//Pull the channel DB doc
|
||||||
|
const chanDB = await channelModel.findOne({name:this.channel.name});
|
||||||
|
|
||||||
|
//Cook and emit a new object from all of the data
|
||||||
|
socket.emit("dumpQueue", {
|
||||||
|
cache: {
|
||||||
|
schedule: Array.from(this.schedule),
|
||||||
|
nowPlaying: this.nowPlaying
|
||||||
|
},
|
||||||
|
DB: {
|
||||||
|
schedule: chanDB.media.scheduled,
|
||||||
|
nowPlaying: chanDB.media.nowPlaying,
|
||||||
|
archived: chanDB.media.archived,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//DONE.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Otherwise, just dump whats in RAM
|
||||||
|
socket.emit("dumpQueue", {
|
||||||
|
cache: {
|
||||||
|
schedule: Array.from(this.schedule),
|
||||||
|
nowPlaying: this.nowPlaying
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//--- INTERNAL USE ONLY QUEUEING FUNCTIONS ---
|
//--- INTERNAL USE ONLY QUEUEING FUNCTIONS ---
|
||||||
/**
|
/**
|
||||||
* Clears and scheduling timers
|
* Clears and scheduling timers
|
||||||
|
|
@ -1788,7 +1833,9 @@ class queue{
|
||||||
chanDB.media.scheduled = newSched;
|
chanDB.media.scheduled = newSched;
|
||||||
|
|
||||||
//Save the DB
|
//Save the DB
|
||||||
await chanDB.save();
|
await chanDB.save()
|
||||||
|
|
||||||
|
//End the media;
|
||||||
|
|
||||||
//if something fucked up
|
//if something fucked up
|
||||||
}catch(err){
|
}catch(err){
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,12 @@ const permissionSchema = new mongoose.Schema({
|
||||||
type: channelPermissionSchema,
|
type: channelPermissionSchema,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
},
|
},
|
||||||
|
debug: {
|
||||||
|
type: mongoose.SchemaTypes.String,
|
||||||
|
enum: rankEnum,
|
||||||
|
default: "admin",
|
||||||
|
required: true
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
//Statics
|
//Statics
|
||||||
|
|
|
||||||
|
|
@ -78,9 +78,6 @@ const config = require('../config.json');
|
||||||
const port = config.port;
|
const port = config.port;
|
||||||
const dbUrl = `mongodb://${config.db.user}:${config.db.pass}@${config.db.address}:${config.db.port}/${config.db.database}`;
|
const dbUrl = `mongodb://${config.db.user}:${config.db.pass}@${config.db.address}:${config.db.port}/${config.db.database}`;
|
||||||
|
|
||||||
//Check for insecure config
|
|
||||||
configCheck.securityCheck();
|
|
||||||
|
|
||||||
//Define express
|
//Define express
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
|
@ -234,6 +231,9 @@ async function asyncKickStart(){
|
||||||
//Kick off scheduled-jobs
|
//Kick off scheduled-jobs
|
||||||
scheduler.kickoff();
|
scheduler.kickoff();
|
||||||
|
|
||||||
|
//Check for insecure config
|
||||||
|
configCheck.securityCheck();
|
||||||
|
|
||||||
//Increment launch counter
|
//Increment launch counter
|
||||||
await statModel.incrementLaunchCount();
|
await statModel.incrementLaunchCount();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,4 +74,9 @@ module.exports.securityCheck = function(){
|
||||||
if(!validator.isStrongPassword(config.mail.pass) || config.mail.pass == "CHANGE_ME"){
|
if(!validator.isStrongPassword(config.mail.pass) || config.mail.pass == "CHANGE_ME"){
|
||||||
loggerUtil.consoleWarn("Insecure Email Password! Change Email password!");
|
loggerUtil.consoleWarn("Insecure Email Password! Change Email password!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check debug mode
|
||||||
|
if(config.debug){
|
||||||
|
loggerUtil.consoleWarn("Debug mode enabled! Understand the risks and security implications before enabling on production servers!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue