Commit 1d633fe7 authored by r03ert0's avatar r03ert0

add changes from pasteur vm

parent 7f131272
......@@ -3,13 +3,13 @@ const os = require('os');
const zlib = require('zlib');
const tracer = require('tracer').console({format: '[{{file}}:{{line}}] {{message}}'});
const jpeg = require('jpeg-js'); // jpeg-js library: https://github.com/eugeneware/jpeg-js
const keypress = require('keypress');
const Struct = require('struct');
const childProcess = require('child_process');
const merge = require('merge');
const path = require('path');
const monk = require('monk');
const db = monk('localhost:27017/brainbox');
const keypress = require('keypress');
// Get whitelist and blacklist
const useWhitelist = false;
......@@ -22,16 +22,33 @@ tracer.log("Use blacklist:", useBlacklist);
tracer.log(blacklist);
var http = require('http');
//const server = http.createServer(),
const server = http.createServer(function(req, res) {
let server;
const ws_cfg = JSON.parse(fs.readFileSync('ws_cfg.json'));
const {secure, port} = ws_cfg;
if(secure) {
// wss
var http = require('https');
server = http.createServer({
key: fs.readFileSync(ws_cfg.ssl_key),
cert: fs.readFileSync(ws_cfg.ssl_cert),
ca: fs.readFileSync(ws_cfg.ssl_chain)
}, function(req, res) {
var ip = req.ip
|| req.connection.remoteAddress
|| req.socket.remoteAddress
|| req.connection.socket.remoteAddress;
}).listen(ws_cfg.port);
} else {
var http = require('http');
server = http.createServer(function(req, res) {
var ip = req.ip
|| req.connection.remoteAddress
|| req.socket.remoteAddress
|| req.connection.socket.remoteAddress;
});
});
}
const WebSocketServer = require('ws').Server;
var websocket;
const port = 8080;
server.on("upgrade", function(req, socket, head) {
var ip = req.ip
......@@ -2325,7 +2342,11 @@ const atlasMakerServer = (function() {
Init WS connection
*/
try {
websocket = new WebSocketServer({ server: server, verifyClient: me.verifyClient });
if(secure) {
websocket = new WebSocketServer({server: server});
} else {
websocket = new WebSocketServer({ server: server, verifyClient: me.verifyClient });
}
websocket.on("connection", function connectionFromInitSocketConnection(s, req) {
me.traceLog(connectionFromInitSocketConnection);
......
......@@ -367,7 +367,7 @@ const apiMriGet = function (req, res) {
return;
}
req.db.get('mri').findOne({source: myurl, backup: {$exists: 0}}, {_id: 0})
req.db.get('mri').findOne({source: myurl, backup: {$exists: backups}}, {_id: 0})
.then(json => {
if (!json) {
console.log("MRI not present in DB");
......
......@@ -672,4 +672,4 @@ var projectController = function(){
this.delete_project = delete_project;
}
module.exports = new projectController();
\ No newline at end of file
module.exports = new projectController();
{
"secure": false,
"port": 8080,
"ssl_key": "/path/to/privkey.pem",
"ssl_cert": "/path/to/fullchain.pem",
"ssl_chain": "/path/to/chain.pem"
"ssl_key": "privkey.pem",
"ssl_cert": "fullchain.pem",
"ssl_chain": "chain.pem"
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment