Do not reconnect if STS cap is received in CAP NEW
This commit is contained in:
parent
db866f9823
commit
8976fa163e
@ -7,14 +7,14 @@ module.exports = function(irc, network) {
|
|||||||
const client = this;
|
const client = this;
|
||||||
|
|
||||||
irc.on("cap ls", (data) => {
|
irc.on("cap ls", (data) => {
|
||||||
handleSTS(data);
|
handleSTS(data, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("cap new", (data) => {
|
irc.on("cap new", (data) => {
|
||||||
handleSTS(data);
|
handleSTS(data, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleSTS(data) {
|
function handleSTS(data, shouldReconnect) {
|
||||||
if (!Object.prototype.hasOwnProperty.call(data.capabilities, "sts")) {
|
if (!Object.prototype.hasOwnProperty.call(data.capabilities, "sts")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -50,8 +50,12 @@ module.exports = function(irc, network) {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// Forcefully end the connection
|
// Forcefully end the connection if STS is seen in CAP LS
|
||||||
|
// We will update the port and tls setting if we see CAP NEW,
|
||||||
|
// but will not force a reconnection
|
||||||
|
if (shouldReconnect) {
|
||||||
irc.connection.end();
|
irc.connection.end();
|
||||||
|
}
|
||||||
|
|
||||||
// Update the port
|
// Update the port
|
||||||
network.port = port;
|
network.port = port;
|
||||||
@ -63,8 +67,10 @@ module.exports = function(irc, network) {
|
|||||||
irc.options.tls = true;
|
irc.options.tls = true;
|
||||||
irc.options.rejectUnauthorized = true;
|
irc.options.rejectUnauthorized = true;
|
||||||
|
|
||||||
|
if (shouldReconnect) {
|
||||||
// Start a new connection
|
// Start a new connection
|
||||||
irc.connect();
|
irc.connect();
|
||||||
|
}
|
||||||
|
|
||||||
client.save();
|
client.save();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user