Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const _ = require('lodash')
const ircFramework = require('irc-framework')
const config = require('../config')
const { versionText } = require('../version')
const ircClient = new ircFramework.Client({
host: config.irc.host,
port: config.irc.port,
nick: config.irc.nick,
username: config.irc.username,
password: config.irc.password,
tls: config.irc.tls,
gecos: config.irc.gecos,
auto_reconnect: true,
// Tries to reconnect for at least 5 hours.
auto_reconnect_wait: 2000 + Math.round(Math.random() * 2000),
auto_reconnect_max_retries: 9000,
version: versionText,
})
let ctx = {
connectionTime: null,
Network.prototype.createIrcFramework = function(client) {
this.irc = new IrcFramework.Client({
version: false, // We handle it ourselves
host: this.host,
port: this.port,
nick: this.nick,
username: Helper.config.useHexIp ? Helper.ip2hex(client.config.browser.ip) : this.username,
gecos: this.realname,
password: this.password,
tls: this.tls,
outgoing_addr: Helper.config.bind,
rejectUnauthorized: this.rejectUnauthorized,
enable_chghost: true,
enable_echomessage: true,
auto_reconnect: true,
auto_reconnect_wait: 10000 + Math.floor(Math.random() * 1000), // If multiple users are connected to the same network, randomize their reconnections a little
auto_reconnect_max_retries: 360, // At least one hour (plus timeouts) worth of reconnections
webirc: this.createWebIrc(client),
var newClient = function(msgCallback, channels, conf) {
var nodeIrc = new NodeIrc.Client();
nodeIrc.connect({
host: conf.ircServer,
nick: config.ircNick,
port: config.ircOptions.port,
tls: config.ircOptions.secure,
password: config.ircOptions.password,
username: config.ircOptions.userName,
gecos: config.ircOptions.realName,
});
nodeIrc.on('error', function(error) {
logger.error('unhandled IRC error:', error);
});
nodeIrc.on('registered', function() {
// IRC perform on connect
port: cf.port || 6667,
username: cf.username,
gecos: cf.realname || cf.nickname || cf.username,
password: decryptedPassword || "",
tls: cf.secure || false,
rejectUnauthorized: !cf.selfSigned || !cf.certExpired || false,
auto_reconnect_max_retries: 999
};
main.plugins().handleEvent(
"ircFrameworkConfig",
{ config: frameworkConfig }
);
let client = {
irc: new irc.Client(frameworkConfig),
config: cf,
joinedChannels: []
};
clients.push(client);
main.plugins().handleEvent("client", { client });
client.irc.connect();
return client;
}
return null;
};