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) => {
|
this.networks.forEach((network) => {
|
||||||
if (network.irc) {
|
network.quit(Helper.config.leaveMessage);
|
||||||
network.irc.quit(Helper.config.leaveMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
network.destroy();
|
network.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -373,6 +373,17 @@ Network.prototype.addChannel = function(newChan) {
|
|||||||
return index;
|
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() {
|
Network.prototype.exportForEdit = function() {
|
||||||
let fieldsToReturn;
|
let fieldsToReturn;
|
||||||
|
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const Helper = require("../../helper");
|
|
||||||
|
|
||||||
exports.commands = ["disconnect"];
|
exports.commands = ["disconnect"];
|
||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function(network, chan, cmd, args) {
|
||||||
const quitMessage = args[0] ? args.join(" ") : Helper.config.leaveMessage;
|
const quitMessage = args[0] ? args.join(" ") : null;
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
network.quit(quitMessage);
|
||||||
network.userDisconnected = true;
|
network.userDisconnected = true;
|
||||||
|
|
||||||
this.save();
|
this.save();
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const _ = require("lodash");
|
const _ = require("lodash");
|
||||||
const Helper = require("../../helper");
|
|
||||||
|
|
||||||
exports.commands = ["quit"];
|
exports.commands = ["quit"];
|
||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
@ -16,10 +15,8 @@ exports.input = function(network, chan, cmd, args) {
|
|||||||
network: network.uuid,
|
network: network.uuid,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (network.irc) {
|
const quitMessage = args[0] ? args.join(" ") : null;
|
||||||
const quitMessage = args[0] ? args.join(" ") : Helper.config.leaveMessage;
|
network.quit(quitMessage);
|
||||||
network.irc.quit(quitMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -23,6 +23,7 @@ class STSPolicies {
|
|||||||
if (value.expires > now) {
|
if (value.expires > now) {
|
||||||
this.policies.set(value.host, {
|
this.policies.set(value.host, {
|
||||||
port: value.port,
|
port: value.port,
|
||||||
|
duration: value.duration,
|
||||||
expires: value.expires,
|
expires: value.expires,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -49,6 +50,7 @@ class STSPolicies {
|
|||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
this.policies.set(host, {
|
this.policies.set(host, {
|
||||||
port: port,
|
port: port,
|
||||||
|
duration: duration,
|
||||||
expires: Date.now() + duration * 1000,
|
expires: Date.now() + duration * 1000,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -58,6 +60,16 @@ class STSPolicies {
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshExpiration(host) {
|
||||||
|
const policy = this.policies.get(host);
|
||||||
|
|
||||||
|
if (typeof policy === "undefined") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
policy.expires = Date.now() + policy.duration * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
saveFile() {
|
saveFile() {
|
||||||
const policiesToStore = [];
|
const policiesToStore = [];
|
||||||
|
|
||||||
@ -65,6 +77,7 @@ class STSPolicies {
|
|||||||
policiesToStore.push({
|
policiesToStore.push({
|
||||||
host: key,
|
host: key,
|
||||||
port: value.port,
|
port: value.port,
|
||||||
|
duration: value.duration,
|
||||||
expires: value.expires,
|
expires: value.expires,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user