Added SSL support
This commit is contained in:
@@ -365,6 +365,8 @@ module.exports = () => {
|
|||||||
enabled: false,
|
enabled: false,
|
||||||
serverHostname: 'mrc.bottomlessabyss.net',
|
serverHostname: 'mrc.bottomlessabyss.net',
|
||||||
serverPort: 5000,
|
serverPort: 5000,
|
||||||
|
serverSslPort: 5001,
|
||||||
|
useSsl: false,
|
||||||
retryDelay: 10000,
|
retryDelay: 10000,
|
||||||
multiplexerPort: 5000,
|
multiplexerPort: 5000,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const _ = require('lodash');
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
|
||||||
// MRC
|
// MRC
|
||||||
const protocolVersion = '1.2.9';
|
const clientVersion = '1.3.1';
|
||||||
const lineDelimiter = new RegExp('\r\n|\r|\n'); // eslint-disable-line no-control-regex
|
const lineDelimiter = new RegExp('\r\n|\r|\n'); // eslint-disable-line no-control-regex
|
||||||
|
|
||||||
const ModuleInfo = (exports.moduleInfo = {
|
const ModuleInfo = (exports.moduleInfo = {
|
||||||
@@ -35,12 +35,24 @@ exports.getModule = class MrcModule extends ServerModule {
|
|||||||
this.log = Log.child({ server: 'MRC' });
|
this.log = Log.child({ server: 'MRC' });
|
||||||
|
|
||||||
const config = Config();
|
const config = Config();
|
||||||
this.boardName = config.general.prettyBoardName || config.general.boardName;
|
this.boardName = config.general.boardName;
|
||||||
this.mrcConnectOpts = {
|
|
||||||
|
// Use prettyBoardName only if non-default
|
||||||
|
if (config.general.prettyBoardName != '|08XXXXX') this.boardName = config.general.prettyBoardName;
|
||||||
|
|
||||||
|
this.mrcConfig = {
|
||||||
host: config.chatServers.mrc.serverHostname || 'mrc.bottomlessabyss.net',
|
host: config.chatServers.mrc.serverHostname || 'mrc.bottomlessabyss.net',
|
||||||
port: config.chatServers.mrc.serverPort || 5000,
|
port: config.chatServers.mrc.serverPort || 5000,
|
||||||
|
sslport: config.chatServers.mrc.serverSslPort || 5001,
|
||||||
retryDelay: config.chatServers.mrc.retryDelay || 10000,
|
retryDelay: config.chatServers.mrc.retryDelay || 10000,
|
||||||
|
useSsl: config.chatServers.mrc.useSsl || false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.mrcConnectOpts = {
|
||||||
|
host: this.mrcConfig.host,
|
||||||
|
port: this.mrcConfig.port,
|
||||||
|
retryDelay: this.mrcConfig.retryDelay
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_connectionHandler() {
|
_connectionHandler() {
|
||||||
@@ -48,7 +60,7 @@ exports.getModule = class MrcModule extends ServerModule {
|
|||||||
|
|
||||||
const handshake = `${
|
const handshake = `${
|
||||||
this.boardName
|
this.boardName
|
||||||
}~${enigmaVersion}/${os.platform()}.${os.arch()}/${protocolVersion}`;
|
}~${enigmaVersion}/${os.platform()}.${os.arch()}/${clientVersion}`;
|
||||||
this.log.debug({ handshake: handshake }, 'Handshaking with MRC server');
|
this.log.debug({ handshake: handshake }, 'Handshaking with MRC server');
|
||||||
|
|
||||||
this.sendRaw(handshake);
|
this.sendRaw(handshake);
|
||||||
@@ -96,13 +108,29 @@ exports.getModule = class MrcModule extends ServerModule {
|
|||||||
connectToMrc() {
|
connectToMrc() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
// create connection to MRC server
|
if (this.mrcConfig.useSsl) {
|
||||||
this.mrcClient = net.createConnection(
|
this.mrcConnectOpts.port = this.mrcConfig.sslport;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(this.mrcConnectOpts);
|
||||||
|
|
||||||
|
// Create connection
|
||||||
|
this.mrcSocket = net.createConnection(
|
||||||
this.mrcConnectOpts,
|
this.mrcConnectOpts,
|
||||||
self._connectionHandler.bind(self)
|
self._connectionHandler.bind(self)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.mrcClient.requestedDisconnect = false;
|
this.mrcSocket.requestedDisconnect = false;
|
||||||
|
|
||||||
|
// Check if we upgrade the connection to SSL
|
||||||
|
if (this.mrcConfig.useSsl) {
|
||||||
|
const tls = require('tls')
|
||||||
|
this.mrcSecureSocket = new tls.TLSSocket(this.mrcSocket, { isServer: false });
|
||||||
|
this.mrcClient = this.mrcSecureSocket;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.mrcClient = this.mrcSocket;
|
||||||
|
}
|
||||||
|
|
||||||
// do things when we get data from MRC central
|
// do things when we get data from MRC central
|
||||||
let buffer = new Buffer.from('');
|
let buffer = new Buffer.from('');
|
||||||
|
|||||||
@@ -318,9 +318,13 @@
|
|||||||
// Make sure to adjust 'prettyBoardName' to your liking in your config before enabling
|
// Make sure to adjust 'prettyBoardName' to your liking in your config before enabling
|
||||||
|
|
||||||
mrc: {
|
mrc: {
|
||||||
enabled : false
|
enabled : false
|
||||||
serverHostname : 'mrc.bottomlessabyss.net'
|
serverHostname : 'mrc.bottomlessabyss.net'
|
||||||
serverPort : 5000
|
serverPort : 5000
|
||||||
|
serverSslPort : 5001
|
||||||
|
useSsl : false
|
||||||
|
retryDelay : 10000
|
||||||
|
multiplexerPort : 5000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user