Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('fs');
- const https = require('https');
- const websocket = require('ws');
- class Server {
- constructor(options) {
- console.log('[#] Initializing services on port %d...', options.port);
- this.initHttpsServer(options);
- this.initWebsocketServer();
- }
- initHttpsServer(options) {
- this.httpServer = new https.createServer(options, function (request, response) {
- response.writeHead(200, {'Content-Type': 'text/html'});
- response.end();
- });
- this.httpServer.listen(options.port);
- }
- initWebsocketServer() {
- this.wsServer = new websocket.Server(this.httpServer);
- }
- }
- const options = {
- port: 8080,
- key: fs.readFileSync('keys/key.pem', 'utf8'),
- cert: fs.readFileSync('keys/cert.pem', 'utf8'),
- passphrase: 'test123'
- };
- var server = new Server(options);
Advertisement
Add Comment
Please, Sign In to add comment