Allow locking network configuration
This commit is contained in:
parent
36f2ee3617
commit
aab7f298d8
@ -103,11 +103,11 @@
|
||||
<label>Server</label>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xs-8">
|
||||
<input class="input" name="host" value="<%= defaults.host %>">
|
||||
<input class="input" name="host" value="<%= defaults.host %>" <%= typeof(lockNetwork) !== "undefined" && lockNetwork ? 'disabled' : ''%>>
|
||||
</div>
|
||||
<div class="col-sm-3 col-xs-4">
|
||||
<div class="port">
|
||||
<input class="input" name="port" value="<%= defaults.port %>">
|
||||
<input class="input" name="port" value="<%= defaults.port %>" <%= typeof(lockNetwork) !== "undefined" && lockNetwork ? 'disabled' : ''%>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
@ -120,7 +120,7 @@
|
||||
<div class="col-sm-3"></div>
|
||||
<div class="col-sm-9">
|
||||
<label class="tls">
|
||||
<input type="checkbox" name="tls" <%= defaults.tls ? 'checked="checked"' : '' %>>
|
||||
<input type="checkbox" name="tls" <%= defaults.tls ? 'checked="checked"' : '' %> <%= typeof(lockNetwork) !== "undefined" && lockNetwork ? 'disabled' : ''%>>
|
||||
Enable TLS/SSL
|
||||
</label>
|
||||
</div>
|
||||
|
@ -79,14 +79,24 @@ module.exports = {
|
||||
//
|
||||
// Display network
|
||||
//
|
||||
// If set to false The Lounge will not expose network settings in login
|
||||
// form, limiting client to connect to the configured network.
|
||||
// If set to false network settings will not be shown in the login form.
|
||||
//
|
||||
// @type boolean
|
||||
// @default true
|
||||
//
|
||||
displayNetwork: true,
|
||||
|
||||
//
|
||||
// Lock network
|
||||
//
|
||||
// If set to true, users will not be able to modify host, port and tls
|
||||
// settings and will be limited to the configured network.
|
||||
//
|
||||
// @type boolean
|
||||
// @default false
|
||||
//
|
||||
lockNetwork: false,
|
||||
|
||||
//
|
||||
// Log settings
|
||||
//
|
||||
|
@ -123,13 +123,43 @@ Client.prototype.find = function(id) {
|
||||
Client.prototype.connect = function(args) {
|
||||
var config = Helper.getConfig();
|
||||
var client = this;
|
||||
|
||||
if (config.lockNetwork) {
|
||||
// This check is needed to prevent invalid user configurations
|
||||
if (args.host && args.host.length > 0 && args.host !== config.defaults.host) {
|
||||
var invalidHostnameMsg = new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
text: "Hostname you specified is not allowed."
|
||||
});
|
||||
client.emit("msg", {
|
||||
msg: invalidHostnameMsg
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
args.host = config.defaults.host;
|
||||
args.port = config.defaults.port;
|
||||
args.tls = config.defaults.tls;
|
||||
}
|
||||
|
||||
var server = {
|
||||
name: args.name || "",
|
||||
host: args.host || "chat.freenode.net",
|
||||
port: args.port || (args.tls ? 6697 : 6667),
|
||||
host: args.host || "",
|
||||
port: parseInt(args.port, 10) || (args.tls ? 6697 : 6667),
|
||||
rejectUnauthorized: false
|
||||
};
|
||||
|
||||
if (server.host.length === 0) {
|
||||
var emptyHostnameMsg = new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
text: "You must specify a hostname to connect."
|
||||
});
|
||||
client.emit("msg", {
|
||||
msg: emptyHostnameMsg
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.bind) {
|
||||
server.localAddress = config.bind;
|
||||
if (args.tls) {
|
||||
|
Loading…
Reference in New Issue
Block a user