Merge pull request #2075 from thelounge/xpaw/rejectUnauthorized

Allow setting `rejectUnauthorized` per network
This commit is contained in:
Jérémie Astori 2018-03-04 18:13:16 -05:00 committed by GitHub
commit cbf82a1bc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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"
); );