// Set any random numbers if needed\r
defaults.nick = defaults.nick.replace('?', Math.floor(Math.random() * 100000).toString());\r
\r
+ if (getQueryVariable('encoding'))\r
+ defaults.encoding = getQueryVariable('encoding');\r
+\r
// Populate the server select box with defaults\r
new_connection_dialog.view.populateFields(defaults);\r
};\r
password: connection_info.password\r
};\r
\r
+ // A few optional parameters\r
+ if (connection_info.options.encoding)\r
+ server_info.encoding = connection_info.options.encoding;\r
+\r
this.socket.emit('kiwi', server_info, function (err, server_num) {\r
if (!err) {\r
callback_fn && callback_fn(err, server_num);\r
host: new_connection_event.server,
port: new_connection_event.port,
ssl: new_connection_event.ssl,
- password: new_connection_event.password
+ password: new_connection_event.password,
+ options: new_connection_event.options
}, function(err, network) {
that.onNewNetwork(err, network);
});
ssl: $('input.ssl', this.$el).prop('checked'),
password: $('input.password', this.$el).val(),
channel: $('input.channel', this.$el).val(),
- channel_key: $('input.channel_key', this.$el).val()
+ channel_key: $('input.channel_key', this.$el).val(),
+ options: this.server_options
};
this.trigger('server_connect', values);
if (!(!channel_key)) {
$('tr.key', this.$el).show();
}
+
+ // Temporary values
+ this.server_options = {};
+
+ if (defaults.encoding)
+ this.server_options.encoding = defaults.encoding;
},
hide: function () {
switch (command.command) {
case 'connect':
if (command.hostname && command.port && command.nick) {
- var con;
+ var options = {};
+
+ // Get any optional parameters that may have been passed
+ if (command.encoding)
+ options.encoding = command.encoding;
+
+ options.password = global.config.restrict_server_password || command.password;
this.state.connect(
(global.config.restrict_server || command.hostname),
command.ssl),
command.nick,
{hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address},
- (global.config.restrict_server_password || command.password),
+ options,
callback);
} else {
return callback('Hostname, port and nickname must be specified');
Socks = require('socksjs');
}
-var IrcConnection = function (hostname, port, ssl, nick, user, pass, state, con_num) {
+var IrcConnection = function (hostname, port, ssl, nick, user, options, state, con_num) {
var that = this;
EE.call(this,{
});
this.setMaxListeners(0);
- // Set the first configured encoding as the default encoding
- this.encoding = global.config.default_encoding;
-
+ options = options || {};
+
// Socket state
this.connected = false;
this.nick = nick;
this.user = user; // Contains users real hostname and address
this.username = this.nick.replace(/[^0-9a-zA-Z\-_.\/]/, '');
- this.password = pass;
+ this.password = options.password || '';
+
+ // Set the passed encoding. or the default if none giving or it fails
+ if (!options.encoding || !this.setEncoding(options.encoding)) {
+ this.setEncoding(global.config.default_encoding);
+ }
// State object
this.state = state;
line = iconv.decode(bufs[i], this.encoding);
bufs[i] = null;
if (!line) break;
-
+
// Parse the complete line, removing any carriage returns
msg = parse_regex.exec(line.replace(/^\r+|\r+$/, ''));
module.exports = State;
-State.prototype.connect = function (hostname, port, ssl, nick, user, pass, callback) {
+State.prototype.connect = function (hostname, port, ssl, nick, user, options, callback) {
var that = this;
var con, con_num;
ssl,
nick,
user,
- pass,
+ options,
this,
con_num);