Correctly save ip and hostname in user config

This commit is contained in:
Pavel Djundik 2016-11-19 22:23:51 +02:00
parent 708788338c
commit 4078abb085
1 changed files with 9 additions and 3 deletions

View File

@ -176,6 +176,9 @@ Client.prototype.connect = function(args) {
}); });
} }
args.ip = args.ip || (client.config && client.config.ip) || client.ip;
args.hostname = args.hostname || (client.config && client.config.hostname) || client.hostname;
var network = new Network({ var network = new Network({
name: args.name || "", name: args.name || "",
host: args.host || "", host: args.host || "",
@ -220,8 +223,9 @@ Client.prototype.connect = function(args) {
} }
if (config.webirc && network.host in config.webirc) { if (config.webirc && network.host in config.webirc) {
args.ip = args.ip || (client.config && client.config.ip) || client.ip; if (!args.hostname) {
args.hostname = args.hostname || (client.config && client.config.hostname) || client.hostname || args.ip; args.hostname = args.ip;
}
if (args.ip) { if (args.ip) {
if (config.webirc[network.host] instanceof Function) { if (config.webirc[network.host] instanceof Function) {
@ -260,7 +264,7 @@ Client.prototype.connect = function(args) {
host: network.host, host: network.host,
port: network.port, port: network.port,
nick: nick, nick: nick,
username: config.useHexIp ? Helper.ip2hex(client.ip) : network.username, username: config.useHexIp ? Helper.ip2hex(args.ip) : network.username,
gecos: network.realname, gecos: network.realname,
password: network.password, password: network.password,
tls: network.tls, tls: network.tls,
@ -271,6 +275,8 @@ Client.prototype.connect = function(args) {
auto_reconnect_max_retries: 360, // At least one hour (plus timeouts) worth of reconnections auto_reconnect_max_retries: 360, // At least one hour (plus timeouts) worth of reconnections
webirc: webirc, webirc: webirc,
}); });
client.save();
}; };
Client.prototype.updateToken = function(callback) { Client.prototype.updateToken = function(callback) {