helmet, external_ip, emergency_shutdown added
This commit is contained in:
@@ -33,6 +33,7 @@ module.exports.create_session = async (req, res, next) => {
|
||||
throw new Error('session limit reached')
|
||||
|
||||
var session_id = crypto.randomBytes(16).toString('hex')
|
||||
|
||||
|
||||
// create session on session server
|
||||
http_client.get({
|
||||
@@ -59,7 +60,8 @@ module.exports.create_session = async (req, res, next) => {
|
||||
connection_link:answer.link,
|
||||
connection_code:code
|
||||
})
|
||||
res.json({msg:'SESSION_CREATED', link:answer.link})
|
||||
// SHALL REMOVE CONNECTION CODE BECAUSE IN WEB WE DO NOT NEED IT
|
||||
res.json({msg:'SESSION_CREATED', link:answer.link, connection_code:code})
|
||||
}, function(err) {
|
||||
next(Error('session server not working'))
|
||||
})
|
||||
@@ -69,7 +71,15 @@ module.exports.create_session = async (req, res, next) => {
|
||||
}
|
||||
|
||||
module.exports.connect_session = async (req, res, next) => {
|
||||
|
||||
try {
|
||||
const db = await db_connection.get_db()
|
||||
var session = await db.collection('session_active').findOne({connection_code:parseInt(req.query.connection_code)})
|
||||
if (!session)
|
||||
throw new Error('sessions not found')
|
||||
res.json({connection_link:session.connection_link})
|
||||
} catch (e) {
|
||||
next (e)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.close_session = async (req, res, next) => {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
const db_connection = require('../database/connection.js')
|
||||
const crypto = require('crypto')
|
||||
|
||||
module.exports.emergency_shutdown = async (req, res, next) => {
|
||||
const db = await db_connection.get_db()
|
||||
var id = crypto.createHash('md5').update(req.query.ip+req.query.port).digest('hex')
|
||||
var query = {server_id:{$in:[id]}}
|
||||
await db.collection('session_active').deleteMany(query)
|
||||
res.json({msg:'SESSIONS_CLOSED'})
|
||||
}
|
||||
Reference in New Issue
Block a user