From eab823ba6695266bfe13d3be7b0fea9143bcaa6f Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sat, 17 Feb 2018 10:22:28 +0200 Subject: [PATCH] Allow setting rejectUnauthorized per network --- client/views/windows/connect.tpl | 8 +++++++- defaults/config.js | 11 +++++++++++ src/client.js | 4 +++- src/models/network.js | 2 ++ test/models/network.js | 2 ++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/client/views/windows/connect.tpl b/client/views/windows/connect.tpl index b79377f0..eb1f0302 100644 --- a/client/views/windows/connect.tpl +++ b/client/views/windows/connect.tpl @@ -40,7 +40,13 @@
+
+
+
diff --git a/defaults/config.js b/defaults/config.js index 28c05eb5..ad53a387 100644 --- a/defaults/config.js +++ b/defaults/config.js @@ -233,6 +233,17 @@ module.exports = { // tls: true, + // + // Enable certificate verification + // + // If true, the server certificate is verified against + // the list of supplied CAs by your node.js installation. + // + // @type boolean + // @default true + // + rejectUnauthorized: true, + // // Nick // diff --git a/src/client.js b/src/client.js index ae5dfff8..58f77c9d 100644 --- a/src/client.js +++ b/src/client.js @@ -178,6 +178,7 @@ Client.prototype.connect = function(args) { host: args.host || "", port: parseInt(args.port, 10) || (args.tls ? 6697 : 6667), tls: !!args.tls, + rejectUnauthorized: !args.allowUnauthorized, password: args.password, username: args.username || nick.replace(/[^a-zA-Z0-9]/g, ""), realname: args.realname || "The Lounge User", @@ -206,6 +207,7 @@ Client.prototype.connect = function(args) { network.host = Helper.config.defaults.host; network.port = Helper.config.defaults.port; network.tls = Helper.config.defaults.tls; + network.rejectUnauthorized = Helper.config.defaults.rejectUnauthorized; } if (network.host.length === 0) { @@ -248,7 +250,7 @@ Client.prototype.connect = function(args) { password: network.password, tls: network.tls, outgoing_addr: Helper.config.bind, - rejectUnauthorized: false, + rejectUnauthorized: network.rejectUnauthorized, enable_chghost: true, enable_echomessage: true, auto_reconnect: true, diff --git a/src/models/network.js b/src/models/network.js index 5737ce24..9aadb319 100644 --- a/src/models/network.js +++ b/src/models/network.js @@ -24,6 +24,7 @@ function Network(attr) { host: "", port: 6667, tls: false, + rejectUnauthorized: false, password: "", awayMessage: "", commands: [], @@ -130,6 +131,7 @@ Network.prototype.export = function() { "host", "port", "tls", + "rejectUnauthorized", "password", "username", "realname", diff --git a/test/models/network.js b/test/models/network.js index 6adb861e..32d49d4c 100644 --- a/test/models/network.js +++ b/test/models/network.js @@ -29,6 +29,7 @@ describe("Network", function() { host: "", port: 6667, tls: false, + rejectUnauthorized: false, password: "", username: "", realname: "", @@ -124,6 +125,7 @@ describe("Network", function() { "serverOptions", "status", "tls", + "rejectUnauthorized", "username" );