mirror of
https://github.com/thelounge/thelounge.git
synced 2024-05-18 06:06:36 +02:00
Disable connecting to the same network multiple times if lockNetwork is enabled
This commit is contained in:
parent
6221f96ff2
commit
85f83a7c9a
|
@ -34,7 +34,10 @@ export default defineComponent({
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (store.state.serverConfiguration?.lockNetwork) {
|
if (
|
||||||
|
store.state.serverConfiguration?.lockNetwork &&
|
||||||
|
store.state.serverConfiguration?.allowMultipleSameHostConnections
|
||||||
|
) {
|
||||||
if (store.state.networks.length > 0) {
|
if (store.state.networks.length > 0) {
|
||||||
disabled.value = true;
|
disabled.value = true;
|
||||||
disabledReason.value = "You have already connected and cannot connect again.";
|
disabledReason.value = "You have already connected and cannot connect again.";
|
||||||
|
|
|
@ -285,6 +285,15 @@ module.exports = {
|
||||||
// This value is set to `false` by default.
|
// This value is set to `false` by default.
|
||||||
lockNetwork: false,
|
lockNetwork: false,
|
||||||
|
|
||||||
|
// ### `sameHostLockedNetworkConnections`
|
||||||
|
//
|
||||||
|
// When set to `true`, users will be able to connect to the configured
|
||||||
|
// network multiple times. This can be useful if you connect to
|
||||||
|
// a bouncer like ZNC. Requires `lockNetwork` to be set to `true`.
|
||||||
|
//
|
||||||
|
// This value is set to `false` by default.
|
||||||
|
allowMultipleSameHostConnections: false,
|
||||||
|
|
||||||
// ## User management
|
// ## User management
|
||||||
|
|
||||||
// ### `messageStorage`
|
// ### `messageStorage`
|
||||||
|
|
|
@ -96,6 +96,7 @@ export type ConfigType = {
|
||||||
leaveMessage: string;
|
leaveMessage: string;
|
||||||
defaults: Defaults;
|
defaults: Defaults;
|
||||||
lockNetwork: boolean;
|
lockNetwork: boolean;
|
||||||
|
allowMultipleSameHostConnections: boolean;
|
||||||
messageStorage: string[];
|
messageStorage: string[];
|
||||||
useHexIp: boolean;
|
useHexIp: boolean;
|
||||||
webirc?: WebIRC;
|
webirc?: WebIRC;
|
||||||
|
|
|
@ -48,7 +48,12 @@ type IndexTemplateConfiguration = ServerConfiguration & {
|
||||||
|
|
||||||
export type ClientConfiguration = Pick<
|
export type ClientConfiguration = Pick<
|
||||||
ConfigType,
|
ConfigType,
|
||||||
"public" | "lockNetwork" | "useHexIp" | "prefetch" | "defaults"
|
| "public"
|
||||||
|
| "lockNetwork"
|
||||||
|
| "useHexIp"
|
||||||
|
| "prefetch"
|
||||||
|
| "defaults"
|
||||||
|
| "allowMultipleSameHostConnections"
|
||||||
> & {
|
> & {
|
||||||
fileUpload: boolean;
|
fileUpload: boolean;
|
||||||
ldapEnabled: boolean;
|
ldapEnabled: boolean;
|
||||||
|
@ -478,7 +483,7 @@ function initializeClient(
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("network:new", (data) => {
|
socket.on("network:new", (data) => {
|
||||||
if (Config.values.lockNetwork) {
|
if (Config.values.lockNetwork && Config.values.allowMultipleSameHostConnections) {
|
||||||
if (client.networks.length > 0) {
|
if (client.networks.length > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -869,6 +874,8 @@ function getClientConfiguration(): ClientConfiguration {
|
||||||
"lockNetwork",
|
"lockNetwork",
|
||||||
"useHexIp",
|
"useHexIp",
|
||||||
"prefetch",
|
"prefetch",
|
||||||
|
"allowMultipleSameHostConnections",
|
||||||
|
// TODO: remove this type cast
|
||||||
]) as ClientConfiguration;
|
]) as ClientConfiguration;
|
||||||
|
|
||||||
config.fileUpload = Config.values.fileUpload.enable;
|
config.fileUpload = Config.values.fileUpload.enable;
|
||||||
|
|
|
@ -131,6 +131,7 @@ describe("Server", function () {
|
||||||
expect(data.defaultTheme).to.equal("default");
|
expect(data.defaultTheme).to.equal("default");
|
||||||
expect(data.themes).to.be.an("array");
|
expect(data.themes).to.be.an("array");
|
||||||
expect(data.lockNetwork).to.equal(false);
|
expect(data.lockNetwork).to.equal(false);
|
||||||
|
|
||||||
expect(data.useHexIp).to.equal(false);
|
expect(data.useHexIp).to.equal(false);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
|
Loading…
Reference in a new issue