.server_select .basic label { font-size:1.3em; margin-top:4px; }
.server_select .basic { border-bottom: 1px dashed gray; margin-bottom:1em; }
.server_select .basic .show_more { display: block; width:40px; margin:10px 0 0 0; font-size:0.8em; background: url(../img/more.png) no-repeat right 7px; }
+.server_select.single_server .basic { border:none; }
.server_select .status { text-align: center; font-weight: bold; padding:1em; }
.server_select .status .ok {
border:1px solid #A33F3F; background-color:#D28A8A;
var index_src = fs.readFileSync(__dirname + '/index.html.tmpl', FILE_ENCODING);\r
var vars = {\r
base_path: config.get().http_base_path,\r
- cache_buster: Math.ceil(Math.random() * 9000).toString()\r
+ cache_buster: Math.ceil(Math.random() * 9000).toString(),\r
+ server_settings: '{}'\r
};\r
\r
+if (config.get().restrict_server) {\r
+ vars.server_settings = JSON.stringify({\r
+ connection: {\r
+ server: config.get().restrict_server,\r
+ port: config.get().restrict_server_port || 6667,\r
+ ssl: config.get().restrict_server_ssl,\r
+ channel: config.get().restrict_server_channel,\r
+ nick: config.get().restrict_server_nick,\r
+ allow_change: false\r
+ }\r
+ });\r
+}\r
+\r
_.each(vars, function(value, key) {\r
index_src = index_src.replace(new RegExp('<%' + key + '%>', 'g'), value);\r
});\r
function startApp () {\r
var opts = {\r
container: $('#kiwi'),\r
- base_path: base_path\r
+ base_path: base_path,\r
\r
// Override the kiwi_server to use. (Think: running on standalone client..)\r
- //kiwi_server: 'http://kiwiirc.com:80'\r
+ //kiwi_server: 'http://kiwiirc.com:80',\r
+\r
+ server_settings: <%server_settings%>\r
};\r
\r
// Start the app\r
// The base url to the kiwi server\r
this.set('base_path', options[0].base_path ? options[0].base_path : '/kiwi');\r
\r
+ // Any options sent down from the server\r
+ this.server_settings = options[0].server_settings || {};\r
+\r
// Best guess at where the kiwi server is\r
this.detectKiwiServer();\r
};\r
}\r
}\r
\r
+ // If any settings have been given by the server.. override any auto detected settings\r
+ if (this.server_settings && this.server_settings.connection) {\r
+ if (this.server_settings.connection.server) {\r
+ defaults.server = this.server_settings.connection.server;\r
+ }\r
+\r
+ if (this.server_settings.connection.port) {\r
+ defaults.port = this.server_settings.connection.port;\r
+ }\r
+\r
+ if (this.server_settings.connection.ssl) {\r
+ defaults.ssl = this.server_settings.connection.ssl;\r
+ }\r
+\r
+ if (this.server_settings.connection.channel) {\r
+ defaults.channel = this.server_settings.connection.channel;\r
+ }\r
+\r
+ if (this.server_settings.connection.nick) {\r
+ defaults.nick = this.server_settings.connection.nick;\r
+ }\r
+ }\r
+console.log('defaults', defaults, this.server_settings);\r
+\r
// Set any random numbers if needed\r
defaults.nick = defaults.nick.replace('?', Math.floor(Math.random() * 100000).toString());\r
\r
initialize: function () {\r
this.$el = $($('#tmpl_server_select').html());\r
\r
+ // Remove the 'more' link if the server has disabled server changing\r
+ if (_kiwi.app.server_settings && _kiwi.app.server_settings.connection) {\r
+ if (!_kiwi.app.server_settings.connection.allow_change) {\r
+ this.$el.find('.show_more').remove();\r
+ this.$el.addClass('single_server');\r
+ }\r
+ }\r
+\r
+\r
_kiwi.gateway.bind('onconnect', this.networkConnected, this);\r
_kiwi.gateway.bind('connecting', this.networkConnecting, this);\r
\r
conf.quit_message = "http://www.kiwiirc.com/ - A hand-crafted IRC client";
-
+// If not empty, the client may only connect to this 1 IRC server
+//conf.restrict_server = "irc.kiwiirc.com";
+//conf.restrict_server_port = 6667;
+//conf.restrict_server_ssl = false;
+//conf.restrict_server_channel = "#kiwiirc";
+//conf.restrict_server_password = "";
+//conf.restrict_server_nick = "kiwi_";
/*
callback = function () {};
}
switch (command.command) {
- case 'connect':
- if (command.hostname && command.port && command.nick) {
- var con = new IrcConnection(command.hostname, command.port, command.ssl,
- command.nick, {hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address},
- command.password);
-
- var con_num = this.next_connection++;
- this.irc_connections[con_num] = con;
-
- var irc_commands = new IrcCommands(con, con_num, this);
- irc_commands.bindEvents();
-
- con.on('connected', function () {
- return callback(null, con_num);
- });
-
- con.on('error', function (err) {
+ case 'connect':
+ if (command.hostname && command.port && command.nick) {
+ var con;
+
+ if (global.config.restrict_server) {
+ con = new IrcConnection(
+ global.config.restrict_server,
+ global.config.restrict_server_port,
+ global.config.restrict_server_ssl,
+ command.nick,
+ {hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address},
+ global.config.restrict_server_password);
+
+ } else {
+ con = new IrcConnection(
+ command.hostname,
+ command.port,
+ command.ssl,
+ command.nick,
+ {hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address},
+ command.password);
+ }
+
+ var con_num = this.next_connection++;
+ this.irc_connections[con_num] = con;
+
+ var irc_commands = new IrcCommands(con, con_num, this);
+ irc_commands.bindEvents();
+
+ con.on('connected', function () {
+ return callback(null, con_num);
+ });
+
+ con.on('error', function (err) {
console.log('irc_connection error (' + command.hostname + '):', err);
// TODO: Once multiple servers implemented, specify which server failed
//that.sendKiwiCommand('error', {server: con_num, error: err});
return callback(err.code, null);
- });
+ });
con.on('close', function () {
that.irc_connections[con_num] = null;
});
- } else {
- return callback('Hostname, port and nickname must be specified');
- }
- break;
- default:
- callback();
+ } else {
+ return callback('Hostname, port and nickname must be specified');
+ }
+ break;
+ default:
+ callback();
}
}