-
Notifications
You must be signed in to change notification settings - Fork 0
/
evilbit.js
40 lines (31 loc) · 893 Bytes
/
evilbit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var fs = require('fs');
var http = require('http');
var https = require('https');
var express = require('express');
var creds = require('./creds');
var credentials = {};
var app = express();
app.use(express.static('./webroot/'));
function sni(name) {
var creds = credentials[name];
if (creds && 'context' in creds) {
return creds.context;
}
}
function start(httpPort, httpsPort, devLogger) {
var options = {
key: fs.readFileSync('keys/evilbit.io.key'),
cert: fs.readFileSync('certs/evilbit.io.certs'),
SNICallback: sni,
};
if (devLogger) {
app.use(express.logger('dev'));
} else {
var logFile = fs.createWriteStream('./log', {flags: 'a'});
app.use(express.logger({stream: logFile}));
}
credentials = creds.init();
http.createServer(app).listen(httpPort);
https.createServer(options, app).listen(httpsPort);
}
exports.start = start;