mirror of
https://gitlab.silvrtree.co.uk/martind2000/censis-archive.git
synced 2025-01-11 07:05:09 +00:00
”2016-09-07”
This commit is contained in:
parent
ece31a8d49
commit
b7195280a5
@ -16,11 +16,11 @@ var log4js = require('log4js');
|
||||
var logger = log4js.getLogger();
|
||||
var authentication = require('basic-authentication');
|
||||
|
||||
var WebSocketServer = require('websocket').server;
|
||||
|
||||
var EventEmitter = require('events');
|
||||
var busEmitter = new EventEmitter();
|
||||
|
||||
var socketHandler = require('./lib/socketeer')(busEmitter);
|
||||
|
||||
// Var apn = require('apn');
|
||||
|
||||
require('sugar-date');
|
||||
|
@ -10,6 +10,8 @@ var cache = require('gulp-cache');
|
||||
var livereload = require('gulp-livereload');
|
||||
var htmlmin = require('gulp-htmlmin');
|
||||
var inject = require('gulp-inject');
|
||||
var update = require('gulp-banner');
|
||||
var atob = require('atob');
|
||||
var del = require('del');
|
||||
var htmlreplace = require('gulp-html-replace');
|
||||
var stripDebug = require('gulp-strip-debug');
|
||||
@ -48,6 +50,7 @@ gulp.task('appJS', function() {
|
||||
warnings: true, // Warn about potentially dangerous optimizations/code
|
||||
global_defs: {} // global definitions
|
||||
}}))
|
||||
.pipe(update(atob('LyogPT09PT09PQ0KDQpEZXZlbG9wZWQgYnkgTWFydGluIERvbm5lbGx5IG1hcnRpbmQyMDAwe2F0fWdtYWlsLmNvbQ0KDQo9PT09PT09ICovDQoNCg==')))
|
||||
.pipe(gulp.dest('dist/js'));
|
||||
});
|
||||
|
||||
|
59
mdot/mDotServer.censis/mDotServer.censis/lib/socketeer.js
Normal file
59
mdot/mDotServer.censis/mDotServer.censis/lib/socketeer.js
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
*
|
||||
* User: Martin Donnelly
|
||||
* Date: 2016-09-07
|
||||
* Time: 15:33
|
||||
*
|
||||
*/
|
||||
|
||||
var WebSocketServer = require('websocket').server;
|
||||
var http = require('http');
|
||||
|
||||
var logger = require('log4js').getLogger();
|
||||
|
||||
var Sugar = require('sugar-date');
|
||||
|
||||
var server = http.createServer(function(request, response) {
|
||||
logger.info((new Date()) + ' Received request for ' + request.url);
|
||||
response.writeHead(404);
|
||||
response.end();
|
||||
});
|
||||
|
||||
server.listen(3001, function() {
|
||||
logger.info((new Date()) + ' Server is listening on port 3001');
|
||||
});
|
||||
|
||||
var wsServer = new WebSocketServer({
|
||||
httpServer: server, // You should not use autoAcceptConnections for production
|
||||
// applications, as it defeats all standard cross-origin protection
|
||||
// facilities built into the protocol and the browser. You should
|
||||
// *always* verify the connection's origin and decide whether or not
|
||||
// to accept it.
|
||||
autoAcceptConnections: true
|
||||
});
|
||||
|
||||
module.exports = function(events) {
|
||||
'use strict';
|
||||
|
||||
function originIsAllowed(origin) {
|
||||
// Put logic here to detect whether the specified origin is allowed.
|
||||
return true;
|
||||
}
|
||||
wsServer.on('request', function(request) {
|
||||
|
||||
if (!originIsAllowed(request.origin)) {
|
||||
// Make sure we only accept requests from an allowed origin
|
||||
request.reject();
|
||||
logger.info((new Date()) + ' Connection from origin ' + request.origin + ' rejected.');
|
||||
return;
|
||||
}
|
||||
|
||||
var connection = request.accept('stream', request.origin);
|
||||
logger.info((new Date()) + ' Connection accepted.');
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
return module;
|
||||
};
|
@ -18,6 +18,7 @@
|
||||
"events": "^1.1.1",
|
||||
"express": "^4.13.4",
|
||||
"express-session": "*",
|
||||
"gulp-banner": "^0.1.3",
|
||||
"htmlparser": "^1.7.7",
|
||||
"log4js": "^0.6.36",
|
||||
"method-override": "*",
|
||||
@ -79,7 +80,7 @@
|
||||
"scripts": {
|
||||
"test": "mocha --recursive --reporter spec --bail --check-leaks --timeout 3000",
|
||||
"start": "node app.js",
|
||||
"prepublish" : "gulp default"
|
||||
"prepublish": "gulp default"
|
||||
},
|
||||
"author": "Martin Donnelly",
|
||||
"license": "ISC",
|
||||
|
Loading…
Reference in New Issue
Block a user