Allow setting rejectUnauthorized per network

This commit is contained in:
Pavel Djundik 2018-02-17 10:22:28 +02:00
parent 68cc9a2e28
commit eab823ba66
5 changed files with 25 additions and 2 deletions

View file

@ -40,7 +40,13 @@
<div class="col-sm-9 col-sm-offset-3"> <div class="col-sm-9 col-sm-offset-3">
<label class="tls"> <label class="tls">
<input type="checkbox" name="tls" {{#if defaults.tls}}checked{{/if}} {{#if lockNetwork}}disabled{{/if}}> <input type="checkbox" name="tls" {{#if defaults.tls}}checked{{/if}} {{#if lockNetwork}}disabled{{/if}}>
Enable TLS/SSL Use secure connection (TLS)
</label>
</div>
<div class="col-sm-9 col-sm-offset-3">
<label class="tls">
<input type="checkbox" name="allowUnauthorized" {{#unless defaults.rejectUnauthorized}}checked{{/unless}} {{#if lockNetwork}}disabled{{/if}}>
Allow untrusted certificates
</label> </label>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>

View file

@ -233,6 +233,17 @@ module.exports = {
// //
tls: true, 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 // Nick
// //

View file

@ -178,6 +178,7 @@ Client.prototype.connect = function(args) {
host: args.host || "", host: args.host || "",
port: parseInt(args.port, 10) || (args.tls ? 6697 : 6667), port: parseInt(args.port, 10) || (args.tls ? 6697 : 6667),
tls: !!args.tls, tls: !!args.tls,
rejectUnauthorized: !args.allowUnauthorized,
password: args.password, password: args.password,
username: args.username || nick.replace(/[^a-zA-Z0-9]/g, ""), username: args.username || nick.replace(/[^a-zA-Z0-9]/g, ""),
realname: args.realname || "The Lounge User", realname: args.realname || "The Lounge User",
@ -206,6 +207,7 @@ Client.prototype.connect = function(args) {
network.host = Helper.config.defaults.host; network.host = Helper.config.defaults.host;
network.port = Helper.config.defaults.port; network.port = Helper.config.defaults.port;
network.tls = Helper.config.defaults.tls; network.tls = Helper.config.defaults.tls;
network.rejectUnauthorized = Helper.config.defaults.rejectUnauthorized;
} }
if (network.host.length === 0) { if (network.host.length === 0) {
@ -248,7 +250,7 @@ Client.prototype.connect = function(args) {
password: network.password, password: network.password,
tls: network.tls, tls: network.tls,
outgoing_addr: Helper.config.bind, outgoing_addr: Helper.config.bind,
rejectUnauthorized: false, rejectUnauthorized: network.rejectUnauthorized,
enable_chghost: true, enable_chghost: true,
enable_echomessage: true, enable_echomessage: true,
auto_reconnect: true, auto_reconnect: true,

View file

@ -24,6 +24,7 @@ function Network(attr) {
host: "", host: "",
port: 6667, port: 6667,
tls: false, tls: false,
rejectUnauthorized: false,
password: "", password: "",
awayMessage: "", awayMessage: "",
commands: [], commands: [],
@ -130,6 +131,7 @@ Network.prototype.export = function() {
"host", "host",
"port", "port",
"tls", "tls",
"rejectUnauthorized",
"password", "password",
"username", "username",
"realname", "realname",

View file

@ -29,6 +29,7 @@ describe("Network", function() {
host: "", host: "",
port: 6667, port: 6667,
tls: false, tls: false,
rejectUnauthorized: false,
password: "", password: "",
username: "", username: "",
realname: "", realname: "",
@ -124,6 +125,7 @@ describe("Network", function() {
"serverOptions", "serverOptions",
"status", "status",
"tls", "tls",
"rejectUnauthorized",
"username" "username"
); );