diff --git a/client/index.html b/client/index.html
index 9d434103..c8159d14 100644
--- a/client/index.html
+++ b/client/index.html
@@ -103,11 +103,11 @@
-
+ >
@@ -120,7 +120,7 @@
diff --git a/defaults/config.js b/defaults/config.js
index c62eb851..6afb1953 100644
--- a/defaults/config.js
+++ b/defaults/config.js
@@ -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
//
diff --git a/src/client.js b/src/client.js
index 7b795800..4ae79da6 100644
--- a/src/client.js
+++ b/src/client.js
@@ -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) {