secure connections

This commit is contained in:
Evert Prants 2016-09-25 17:13:14 +03:00
parent bcc0b86ed9
commit f688465164
5 changed files with 29 additions and 6 deletions

View File

@ -8,3 +8,8 @@
default_quit_msg="Teemant IRC"
default_part_msg="Bye!"
secure_by_default=false
timeout=3000
encoding="utf-8"
[tls]
rejectUnauthorized=false

View File

@ -31,6 +31,8 @@
<input type="text" name="server" id="server" value="irc.icynet.ml">
<label for="port">Port</label>
<input type="number" name="port" id="port" value="6667">
<label for="secure">Secure connection</label>
Use SSL <input type="checkbox" name="secure" id="secure">
<input type="submit" value="Connect">
</form>
</div>

View File

@ -750,7 +750,7 @@ class IRCConnector {
server: server,
port: port,
password: null,
secure: false });
secure: clientdom.connector.secure.checked });
return true;
}
@ -1250,6 +1250,7 @@ window.onload = function() {
clientdom.connector['channel'] = clientdom.connector.form.querySelector('#channel');
clientdom.connector['server'] = clientdom.connector.form.querySelector('#server');
clientdom.connector['port'] = clientdom.connector.form.querySelector('#port');
clientdom.connector['secure'] = clientdom.connector.form.querySelector('#secure');
clientdom['tabby'] = irc.primaryFrame.querySelector('.tabby')
clientdom['frame'] = irc.primaryFrame.querySelector('#chat');
clientdom['letterbox'] = clientdom.frame.querySelector('.letterbox');

View File

@ -1,5 +1,6 @@
let EventEmitter = require('events').EventEmitter;
let net = require('net');
let tls = require('tls');
let configuration = require(__dirname+"/config");
let parse = require(__dirname+"/parser");
let webirc = require(__dirname+"/webirc");
@ -357,7 +358,8 @@ class IRCConnection extends EventEmitter {
autojoin: [],
secure: configuration.client.secure_by_default,
password: "",
address: "0.0.0.0"
address: "0.0.0.0",
rejectUnauthorized: configuration.tls.rejectUnauthorized
};
this.userInfo = userInfo;
@ -379,6 +381,7 @@ class IRCConnection extends EventEmitter {
max_channel_length: 64,
supportedModes: {}
};
this.authorizationError = '';
this.queue = {};
}
@ -391,13 +394,14 @@ class IRCConnection extends EventEmitter {
}
connect() {
this.socket = net.createConnection(this.config.port, this.config.server, () => {
this.socket = (this.config.secure ? tls : net).connect({port: this.config.port, host: this.config.server,
rejectUnauthorized: this.config.rejectUnauthorized}, () => {
this.connected = true;
this.authenticate();
});
this.socket.setEncoding('utf8');
this.socket.setTimeout(3000);
this.socket.setEncoding(configuration.client.encoding);
this.socket.setTimeout(configuration.client.timeout);
this.socket.on('error', (data) => {
this.emit('connerror', {type: "sock_error", message: "A socket error occured.", raw: data});

View File

@ -109,6 +109,10 @@ io.sockets.on('connection', function (socket) {
newConnection.on('line', function(line) {
console.log("["+socket.id+"] <-", line);
});
newConnection.on('debug_log', function(data) {
console.log("["+socket.id+"] <-", data);
});
}
newConnection.on('connerror', (data) => {
@ -123,6 +127,9 @@ io.sockets.on('connection', function (socket) {
inconnect = false;
}
if(config.server.debug)
console.log(data);
socket.emit('act_client', {type: (inconnect == true ? 'server_message' : 'connect_message'), server: connectiondata.server, message: message, error: true});
});
@ -136,6 +143,10 @@ io.sockets.on('connection', function (socket) {
if(newConnection.authenticated == false) {
message = "Failed to connect to the server!";
if(config.server.debug)
console.log(data);
inconnect = false;
}