Refresh STS policy expiration on network quit
This commit is contained in:
parent
568427ca98
commit
db866f9823
@ -617,10 +617,7 @@ Client.prototype.quit = function(signOut) {
|
||||
}
|
||||
|
||||
this.networks.forEach((network) => {
|
||||
if (network.irc) {
|
||||
network.irc.quit(Helper.config.leaveMessage);
|
||||
}
|
||||
|
||||
network.quit(Helper.config.leaveMessage);
|
||||
network.destroy();
|
||||
});
|
||||
|
||||
|
@ -373,6 +373,17 @@ Network.prototype.addChannel = function(newChan) {
|
||||
return index;
|
||||
};
|
||||
|
||||
Network.prototype.quit = function(quitMessage) {
|
||||
if (!this.irc) {
|
||||
return;
|
||||
}
|
||||
|
||||
// https://ircv3.net/specs/extensions/sts#rescheduling-expiry-on-disconnect
|
||||
STSPolicies.refreshExpiration(this.host);
|
||||
|
||||
this.irc.quit(quitMessage || Helper.config.leaveMessage);
|
||||
};
|
||||
|
||||
Network.prototype.exportForEdit = function() {
|
||||
let fieldsToReturn;
|
||||
|
||||
|
@ -1,19 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
const Helper = require("../../helper");
|
||||
|
||||
exports.commands = ["disconnect"];
|
||||
exports.allowDisconnected = true;
|
||||
|
||||
exports.input = function(network, chan, cmd, args) {
|
||||
const quitMessage = args[0] ? args.join(" ") : Helper.config.leaveMessage;
|
||||
|
||||
// Even if we are disconnected, but there is an internal connection object
|
||||
// pass the quit/end to it, so the reconnection timer stops
|
||||
if (network.irc && network.irc.connection) {
|
||||
network.irc.quit(quitMessage);
|
||||
}
|
||||
const quitMessage = args[0] ? args.join(" ") : null;
|
||||
|
||||
network.quit(quitMessage);
|
||||
network.userDisconnected = true;
|
||||
|
||||
this.save();
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const _ = require("lodash");
|
||||
const Helper = require("../../helper");
|
||||
|
||||
exports.commands = ["quit"];
|
||||
exports.allowDisconnected = true;
|
||||
@ -16,10 +15,8 @@ exports.input = function(network, chan, cmd, args) {
|
||||
network: network.uuid,
|
||||
});
|
||||
|
||||
if (network.irc) {
|
||||
const quitMessage = args[0] ? args.join(" ") : Helper.config.leaveMessage;
|
||||
network.irc.quit(quitMessage);
|
||||
}
|
||||
const quitMessage = args[0] ? args.join(" ") : null;
|
||||
network.quit(quitMessage);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
@ -23,6 +23,7 @@ class STSPolicies {
|
||||
if (value.expires > now) {
|
||||
this.policies.set(value.host, {
|
||||
port: value.port,
|
||||
duration: value.duration,
|
||||
expires: value.expires,
|
||||
});
|
||||
}
|
||||
@ -49,6 +50,7 @@ class STSPolicies {
|
||||
if (duration > 0) {
|
||||
this.policies.set(host, {
|
||||
port: port,
|
||||
duration: duration,
|
||||
expires: Date.now() + duration * 1000,
|
||||
});
|
||||
} else {
|
||||
@ -58,6 +60,16 @@ class STSPolicies {
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
refreshExpiration(host) {
|
||||
const policy = this.policies.get(host);
|
||||
|
||||
if (typeof policy === "undefined") {
|
||||
return null;
|
||||
}
|
||||
|
||||
policy.expires = Date.now() + policy.duration * 1000;
|
||||
}
|
||||
|
||||
saveFile() {
|
||||
const policiesToStore = [];
|
||||
|
||||
@ -65,6 +77,7 @@ class STSPolicies {
|
||||
policiesToStore.push({
|
||||
host: key,
|
||||
port: value.port,
|
||||
duration: value.duration,
|
||||
expires: value.expires,
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user