remove locks.

This commit is contained in:
Miroslav Šedivý 2024-04-21 20:37:58 +02:00
parent 014b68e1fb
commit 7cc53a0429
31 changed files with 12 additions and 660 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<ul> <ul>
<li v-if="!implicitHosting && (!controlLocked || hosting)"> <li v-if="!implicitHosting && hosting">
<i <i
:class="[ :class="[
!disabeld && shakeKbd ? 'shake' : '', !disabeld && shakeKbd ? 'shake' : '',
@ -22,9 +22,9 @@
</li> </li>
<li class="no-pointer" v-if="implicitHosting"> <li class="no-pointer" v-if="implicitHosting">
<i <i
:class="[controlLocked ? 'disabled' : '', 'fas', 'fa-mouse-pointer']" :class="['fas', 'fa-mouse-pointer']"
v-tooltip="{ v-tooltip="{
content: controlLocked ? $t('controls.hasnot') : $t('controls.has'), content: $t('controls.has'),
placement: 'top', placement: 'top',
offset: 5, offset: 5,
boundariesElement: 'body', boundariesElement: 'body',
@ -32,7 +32,7 @@
}" }"
/> />
</li> </li>
<li v-if="implicitHosting || (!implicitHosting && (!controlLocked || hosting))"> <li v-if="implicitHosting || (!implicitHosting && hosting)">
<label <label
class="switch" class="switch"
v-tooltip="{ v-tooltip="{
@ -43,7 +43,7 @@
delay: { show: 300, hide: 100 }, delay: { show: 300, hide: 100 },
}" }"
> >
<input type="checkbox" v-model="locked" :disabled="!hosting || (implicitHosting && controlLocked)" /> <input type="checkbox" v-model="locked" :disabled="!hosting || implicitHosting" />
<span /> <span />
</label> </label>
</li> </li>
@ -258,10 +258,6 @@
export default class extends Vue { export default class extends Vue {
@Prop(Boolean) readonly shakeKbd!: boolean @Prop(Boolean) readonly shakeKbd!: boolean
get controlLocked() {
return 'control' in this.$accessor.locked && this.$accessor.locked['control'] && !this.$accessor.user.admin
}
get disabeld() { get disabeld() {
return this.$accessor.remote.hosted return this.$accessor.remote.hosted
} }

View File

@ -5,45 +5,6 @@
<span><b>n</b>.eko</span> <span><b>n</b>.eko</span>
</a> </a>
<ul class="menu"> <ul class="menu">
<li>
<i
:class="[{ disabled: !admin }, { locked: isLocked('control') }, 'fas', 'fa-mouse']"
@click="toggleLock('control')"
v-tooltip="{
content: lockedTooltip('control'),
placement: 'bottom',
offset: 5,
boundariesElement: 'body',
delay: { show: 300, hide: 100 },
}"
/>
</li>
<li>
<i
:class="[{ disabled: !admin }, { locked: isLocked('login') }, locked ? 'fa-lock' : 'fa-lock-open', 'fas']"
@click="toggleLock('login')"
v-tooltip="{
content: lockedTooltip('login'),
placement: 'bottom',
offset: 5,
boundariesElement: 'body',
delay: { show: 300, hide: 100 },
}"
/>
</li>
<li v-if="fileTransfer">
<i
:class="[{ disabled: !admin }, { locked: isLocked('file_transfer') }, 'fas', 'fa-file']"
@click="toggleLock('file_transfer')"
v-tooltip="{
content: lockedTooltip('file_transfer'),
placement: 'bottom',
offset: 5,
boundariesElement: 'body',
delay: { show: 300, hide: 100 },
}"
/>
</li>
<li> <li>
<span v-if="showBadge" class="badge">&bull;</span> <span v-if="showBadge" class="badge">&bull;</span>
<i class="fas fa-bars toggle" @click="toggleMenu" /> <i class="fas fa-bars toggle" @click="toggleMenu" />
@ -162,14 +123,6 @@
@Component({ name: 'neko-settings' }) @Component({ name: 'neko-settings' })
export default class extends Vue { export default class extends Vue {
get admin() {
return this.$accessor.user.admin
}
get locked() {
return this.$accessor.locked
}
get side() { get side() {
return this.$accessor.client.side return this.$accessor.client.side
} }
@ -182,30 +135,10 @@
return !this.side && this.readTexts != this.texts return !this.side && this.readTexts != this.texts
} }
get fileTransfer() {
return this.$accessor.remote.fileTransfer
}
toggleLock(resource: AdminLockResource) {
this.$accessor.toggleLock(resource)
}
isLocked(resource: AdminLockResource): boolean {
return this.$accessor.isLocked(resource)
}
readTexts: number = 0 readTexts: number = 0
toggleMenu() { toggleMenu() {
this.$accessor.client.toggleSide() this.$accessor.client.toggleSide()
this.readTexts = this.texts this.readTexts = this.texts
} }
lockedTooltip(resource: AdminLockResource) {
if (this.admin) {
return this.$t(`locks.${resource}.` + (this.isLocked(resource) ? `unlock` : `lock`))
}
return this.$t(`locks.${resource}.` + (this.isLocked(resource) ? `locked` : `unlocked`))
}
} }
</script> </script>

View File

@ -52,33 +52,6 @@ export const controls = {
unlock: 'Steuerung entsperren', unlock: 'Steuerung entsperren',
} }
export const locks = {
control: {
lock: 'Steuerung sperren (für Nutzer)',
unlock: 'Steuerung entsperren (für Nutzer)',
locked: 'Steuerung gesperrt (für Nutzer)',
unlocked: 'Steuerung entsperrt (für Nutzer)',
notif_locked: 'Steuerung sperren für Nutzer',
notif_unlocked: 'Steuerung entsperren für Nutzer',
},
login: {
lock: 'Raum sperren (für Nutzer)',
unlock: 'Raum entsperren (für Nutzer)',
locked: 'Raum gesperrt (für Nutzer)',
unlocked: 'Raum entsperrt (für Nutzer)',
notif_locked: 'Raum gesperrt',
notif_unlocked: 'Raum entsperrt',
},
file_transfer: {
lock: 'Dateiübertragung sperren (für Nutzer)',
unlock: 'Dateiübertragung entsperren (für Nutzer)',
locked: 'Dateiübertragung gesperrt (für Nutzer)',
unlocked: 'Dateiübertragung entsperrt (für Nutzer)',
notif_locked: 'Dateiübertragung gesperrt',
notif_unlocked: 'Dateiübertragung entsperrt',
},
}
export const setting = { export const setting = {
scroll: 'Scroll-Empfindlichkeit', scroll: 'Scroll-Empfindlichkeit',
scroll_invert: 'Bildlauf umkehren', scroll_invert: 'Bildlauf umkehren',

View File

@ -54,33 +54,6 @@ export const controls = {
hasnot: 'You do not have control', hasnot: 'You do not have control',
} }
export const locks = {
control: {
lock: 'Lock Controls (for users)',
unlock: 'Unlock Controls (for users)',
locked: 'Controls Locked (for users)',
unlocked: 'Controls Unlocked (for users)',
notif_locked: 'locked controls for users',
notif_unlocked: 'unlocked controls for users',
},
login: {
lock: 'Lock Room (for users)',
unlock: 'Unlock Room (for users)',
locked: 'Room Locked (for users)',
unlocked: 'Room Unlocked (for users)',
notif_locked: 'locked the room',
notif_unlocked: 'unlocked the room',
},
file_transfer: {
lock: 'Lock File Transfer (for users)',
unlock: 'Unlock File Transfer (for users)',
locked: 'File Transfer Locked (for users)',
unlocked: 'File Transfer Unlocked (for users)',
notif_locked: 'locked file transfer',
notif_unlocked: 'unlocked file transfer',
},
}
export const setting = { export const setting = {
scroll: 'Scroll Sensitivity', scroll: 'Scroll Sensitivity',
scroll_invert: 'Invert Scroll', scroll_invert: 'Invert Scroll',

View File

@ -57,35 +57,6 @@ export const controls = {
//hasnot: 'You do not have control', //hasnot: 'You do not have control',
} }
export const locks = {
// TODO
//control: {
// lock: 'Lock Controls (for users)',
// unlock: 'Unlock Controls (for users)',
// locked: 'Controls Locked (for users)',
// unlocked: 'Controls Unlocked (for users)',
// notif_locked: 'locked controls for users',
// notif_unlocked: 'unlocked controls for users',
//},
login: {
lock: 'Bloquear sala (para usuarios)',
unlock: 'Desbloquear sala (para usuarios)',
locked: 'Sala bloqueada (para usuarios)',
unlocked: 'Sala desbloqueada (para usuarios)',
notif_locked: 'bloqueó la sala',
notif_unlocked: 'desbloqueó la sala',
},
// TODO
//file_transfer: {
// lock: 'Lock File Transfer (for users)',
// unlock: 'Unlock File Transfer (for users)',
// locked: 'File Transfer Locked (for users)',
// unlocked: 'File Transfer Unlocked (for users)',
// notif_locked: 'locked file transfer',
// notif_unlocked: 'unlocked file transfer',
//},
}
export const setting = { export const setting = {
scroll: 'Sensibilidad del Scroll', scroll: 'Sensibilidad del Scroll',
scroll_invert: 'Invertir Scroll', scroll_invert: 'Invertir Scroll',

View File

@ -54,34 +54,6 @@ export const controls = {
hasnot: 'Sinulle ei ole kontrolleja', hasnot: 'Sinulle ei ole kontrolleja',
} }
export const locks = {
control: {
lock: 'Lukitse kontrollit (käyttäjiltä)',
unlock: 'Vapauta kontrollit (käyttäjiltä)',
locked: 'Kontrollit lukittu (käyttäjiltä)',
unlocked: 'Kontrollit vapautettu (käyttäjiltä)',
notif_locked: 'kontrollit on lukittu käyttäjiltä',
notif_unlocked: 'kontrollit on vapautettu käyttäjille',
},
login: {
lock: 'Lukitse huone (käyttäjiltä)',
unlock: 'Vapauta huone (käyttäjiltä)',
locked: 'Huone lukittu (käyttäjiltä)',
unlocked: 'Huone vapautettu (käyttäjiltä)',
notif_locked: 'lukittu huone',
notif_unlocked: 'vapautettu huone',
},
// TODO
//file_transfer: {
// lock: 'Lock File Transfer (for users)',
// unlock: 'Unlock File Transfer (for users)',
// locked: 'File Transfer Locked (for users)',
// unlocked: 'File Transfer Unlocked (for users)',
// notif_locked: 'locked file transfer',
// notif_unlocked: 'unlocked file transfer',
//},
}
export const setting = { export const setting = {
scroll: 'Scrollin herkkyys', scroll: 'Scrollin herkkyys',
scroll_invert: 'Käänteinen Scroll', scroll_invert: 'Käänteinen Scroll',

View File

@ -57,35 +57,6 @@ export const controls = {
// hasnot: 'You do not have control', // hasnot: 'You do not have control',
} }
export const locks = {
// TODO
//control: {
// lock: 'Lock Controls (for users)',
// unlock: 'Unlock Controls (for users)',
// locked: 'Controls Locked (for users)',
// unlocked: 'Controls Unlocked (for users)',
// notif_locked: 'locked controls for users',
// notif_unlocked: 'unlocked controls for users',
//},
login: {
lock: 'Vérouiller la salle (pour les utilisateurs)',
unlock: 'Dévérouiller la salle (pour les utilisateurs)',
locked: 'Salle vérouillée (pour les utilisateurs)',
unlocked: 'Salle dévérouillée (pour les utilisateurs)',
notif_locked: 'a vérouillé la salle',
notif_unlocked: 'a dévérouillé la salle',
},
// TODO
//file_transfer: {
// lock: 'Lock File Transfer (for users)',
// unlock: 'Unlock File Transfer (for users)',
// locked: 'File Transfer Locked (for users)',
// unlocked: 'File Transfer Unlocked (for users)',
// notif_locked: 'locked file transfer',
// notif_unlocked: 'unlocked file transfer',
//},
}
export const setting = { export const setting = {
scroll: 'Sensibilité de défilement (scroll)', scroll: 'Sensibilité de défilement (scroll)',
scroll_invert: 'Inverser le défilement (scroll)', scroll_invert: 'Inverser le défilement (scroll)',

View File

@ -52,34 +52,6 @@ export const controls = {
unlock: '조작 잠금 해제하기', unlock: '조작 잠금 해제하기',
} }
export const locks = {
control: {
lock: '조작 잠그기 (사용자)',
unlock: '조작 잠금 해제하기 (사용자)',
locked: '조작이 잠겼습니다 (사용자)',
unlocked: '조작 잠금이 해제됐습니다 (사용자)',
notif_locked: '사용자의 조작을 잠궜습니다',
notif_unlocked: '사용자의 조작 잠금을 해제했습니다',
},
login: {
lock: '방 잠그기 (사용자)',
unlock: '방 잠금 해제하기 (사용자)',
locked: '방이 잠겼습니다 (사용자)',
unlocked: '방 잠금이 해제됐습니다 (사용자)',
notif_locked: '방이 잠겼습니다',
notif_unlocked: '방 잠금이 해제됐습니다',
},
// TODO
//file_transfer: {
// lock: 'Lock File Transfer (for users)',
// unlock: 'Unlock File Transfer (for users)',
// locked: 'File Transfer Locked (for users)',
// unlocked: 'File Transfer Unlocked (for users)',
// notif_locked: 'locked file transfer',
// notif_unlocked: 'unlocked file transfer',
//},
}
export const setting = { export const setting = {
scroll: '스크롤 감도', scroll: '스크롤 감도',
scroll_invert: '스크롤 반전', scroll_invert: '스크롤 반전',

View File

@ -57,35 +57,6 @@ export const controls = {
//hasnot: 'You do not have control', //hasnot: 'You do not have control',
} }
export const locks = {
// TODO
//control: {
// lock: 'Lock Controls (for users)',
// unlock: 'Unlock Controls (for users)',
// locked: 'Controls Locked (for users)',
// unlocked: 'Controls Unlocked (for users)',
// notif_locked: 'locked controls for users',
// notif_unlocked: 'unlocked controls for users',
//},
login: {
lock: 'Lås rommet (for brukere)',
unlock: 'Lås opp rommet (for brukere)',
locked: 'Rom låst (for brukere)',
unlocked: 'Rom opplåst (for brukere)',
notif_locked: 'låste rommet',
notif_unlocked: 'låste opp rommet',
},
// TODO
//file_transfer: {
// lock: 'Lock File Transfer (for users)',
// unlock: 'Unlock File Transfer (for users)',
// locked: 'File Transfer Locked (for users)',
// unlocked: 'File Transfer Unlocked (for users)',
// notif_locked: 'locked file transfer',
// notif_unlocked: 'unlocked file transfer',
//},
}
export const setting = { export const setting = {
scroll: 'Rullingssensitivitet', scroll: 'Rullingssensitivitet',
scroll_invert: 'Inverter rulling', scroll_invert: 'Inverter rulling',

View File

@ -54,34 +54,6 @@ export const controls = {
hasnot: 'Вы не управляете', hasnot: 'Вы не управляете',
} }
export const locks = {
control: {
lock: 'Закрепить управление (для пользователей)',
unlock: 'Открепить управление (для пользователей)',
locked: 'Управление закреплено (для пользователей)',
unlocked: 'Управление откреплено (для пользователей)',
notif_locked: 'закреплено управление для пользователей',
notif_unlocked: 'откреплено управление для пользователей',
},
login: {
lock: 'Закрыть комнату (для пользователей)',
unlock: 'Открыть комнату (для пользователей)',
locked: 'Комната закрыта (для пользователей)',
unlocked: 'Комната открыта (для пользователей)',
notif_locked: 'комната закрыта',
notif_unlocked: 'комната открыта',
},
// TODO
//file_transfer: {
// lock: 'Lock File Transfer (for users)',
// unlock: 'Unlock File Transfer (for users)',
// locked: 'File Transfer Locked (for users)',
// unlocked: 'File Transfer Unlocked (for users)',
// notif_locked: 'locked file transfer',
// notif_unlocked: 'unlocked file transfer',
//},
}
export const setting = { export const setting = {
scroll: 'Чувствительность прокрутки', scroll: 'Чувствительность прокрутки',
scroll_invert: 'Инвертировать прокрутку', scroll_invert: 'Инвертировать прокрутку',

View File

@ -57,34 +57,6 @@ export const controls = {
//hasnot: 'You do not have control', //hasnot: 'You do not have control',
} }
export const locks = {
control: {
lock: 'Zakázať ovládanie (pre používateľov)',
unlock: 'Povoliť ovládanie (pre používateľov)',
locked: 'Ovládanie je zakázané (pre používateľov)',
unlocked: 'Ovládanie je povolené (pre používateľov)',
notif_locked: 'zakázal/a ovládanie pre používateľov',
notif_unlocked: 'povolil/a ovládanie pre používateľov',
},
login: {
lock: 'Zamknúť miestnosť (pre používateľov)',
unlock: 'Odomknúť miestnosť (pre používateľov)',
locked: 'Miestnosť je zamknutá (pre používateľov)',
unlocked: 'Miestnosť odomknutá (pre používateľov)',
notif_locked: 'miestnosť bola zamknutá',
notif_unlocked: 'miestnosť bola odomknutá',
},
// TODO
//file_transfer: {
// lock: 'Lock File Transfer (for users)',
// unlock: 'Unlock File Transfer (for users)',
// locked: 'File Transfer Locked (for users)',
// unlocked: 'File Transfer Unlocked (for users)',
// notif_locked: 'locked file transfer',
// notif_unlocked: 'unlocked file transfer',
//},
}
export const setting = { export const setting = {
scroll: 'Citlivosť kolieska myši', scroll: 'Citlivosť kolieska myši',
scroll_invert: 'Invertovať koliesko myši', scroll_invert: 'Invertovať koliesko myši',

View File

@ -57,35 +57,6 @@ export const controls = {
//hasnot: 'You do not have control', //hasnot: 'You do not have control',
} }
export const locks = {
// TODO
//control: {
// lock: 'Lock Controls (for users)',
// unlock: 'Unlock Controls (for users)',
// locked: 'Controls Locked (for users)',
// unlocked: 'Controls Unlocked (for users)',
// notif_locked: 'locked controls for users',
// notif_unlocked: 'unlocked controls for users',
//},
login: {
lock: 'Lås rum (för användare)',
unlock: 'Lås upp rummet (för användare)',
locked: 'Rum låst (för användare)',
unlocked: 'Rum upplåst (för användare)',
notif_locked: 'låste rummet',
notif_unlocked: 'låste upp rummet',
},
// TODO
//file_transfer: {
// lock: 'Lock File Transfer (for users)',
// unlock: 'Unlock File Transfer (for users)',
// locked: 'File Transfer Locked (for users)',
// unlocked: 'File Transfer Unlocked (for users)',
// notif_locked: 'locked file transfer',
// notif_unlocked: 'unlocked file transfer',
//},
}
export const setting = { export const setting = {
scroll: 'Scrollkänslighet', scroll: 'Scrollkänslighet',
scroll_invert: 'Vänd Scrollen', scroll_invert: 'Vänd Scrollen',

View File

@ -54,34 +54,6 @@ export const controls = {
hasnot: '你没有控制', hasnot: '你没有控制',
} }
export const locks = {
control: {
lock: '对所有用户进行锁定控制',
unlock: '对所有用户进行解锁控制',
locked: '锁定的控制装置',
unlocked: '解锁的控制装置',
notif_locked: '为用户锁定控制',
notif_unlocked: '为用户解锁控制',
},
login: {
lock: '所有用户的锁定室',
unlock: '所有用户的解锁室',
locked: '为所有用户锁定的房间',
unlocked: '为所有用户解锁的房间',
notif_locked: '锁上房间',
notif_unlocked: '解锁房间',
},
// TODO
//file_transfer: {
// lock: 'Lock File Transfer (for users)',
// unlock: 'Unlock File Transfer (for users)',
// locked: 'File Transfer Locked (for users)',
// unlocked: 'File Transfer Unlocked (for users)',
// notif_locked: 'locked file transfer',
// notif_unlocked: 'unlocked file transfer',
//},
}
export const setting = { export const setting = {
scroll: '滚动敏感度', scroll: '滚动敏感度',
scroll_invert: '反转滚动敏感度', scroll_invert: '反转滚动敏感度',

View File

@ -54,33 +54,6 @@ export const controls = {
hasnot: '您沒有控制權', hasnot: '您沒有控制權',
} }
export const locks = {
control: {
lock: '鎖定控制(對使用者)',
unlock: '解鎖控制(對使用者)',
locked: '已鎖定控制(對使用者)',
unlocked: '已解鎖控制(對使用者)',
notif_locked: '已鎖定使用者控制',
notif_unlocked: '已解鎖使用者控制',
},
login: {
lock: '鎖定房間(對使用者)',
unlock: '解鎖房間(對使用者)',
locked: '房間已鎖定(對使用者)',
unlocked: '房間已解鎖(對使用者)',
notif_locked: '已鎖定房間',
notif_unlocked: '已解鎖房間',
},
file_transfer: {
lock: '鎖定檔案傳輸(對使用者)',
unlock: '解鎖檔案傳輸(對使用者)',
locked: '檔案傳輸已鎖定(對使用者)',
unlocked: '檔案傳輸已解鎖(對使用者)',
notif_locked: '已鎖定檔案傳輸',
notif_unlocked: '已解鎖檔案傳輸',
},
}
export const setting = { export const setting = {
scroll: '滾動靈敏度', scroll: '滾動靈敏度',
scroll_invert: '反向滾動', scroll_invert: '反向滾動',

View File

@ -51,8 +51,6 @@ export const EVENT = {
ADMIN: { ADMIN: {
BAN: 'admin/ban', BAN: 'admin/ban',
KICK: 'admin/kick', KICK: 'admin/kick',
LOCK: 'admin/lock',
UNLOCK: 'admin/unlock',
MUTE: 'admin/mute', MUTE: 'admin/mute',
UNMUTE: 'admin/unmute', UNMUTE: 'admin/unmute',
CONTROL: 'admin/control', CONTROL: 'admin/control',
@ -102,8 +100,6 @@ export type BroadcastEvents =
export type AdminEvents = export type AdminEvents =
| typeof EVENT.ADMIN.BAN | typeof EVENT.ADMIN.BAN
| typeof EVENT.ADMIN.KICK | typeof EVENT.ADMIN.KICK
| typeof EVENT.ADMIN.LOCK
| typeof EVENT.ADMIN.UNLOCK
| typeof EVENT.ADMIN.MUTE | typeof EVENT.ADMIN.MUTE
| typeof EVENT.ADMIN.UNMUTE | typeof EVENT.ADMIN.UNMUTE
| typeof EVENT.ADMIN.CONTROL | typeof EVENT.ADMIN.CONTROL

View File

@ -133,17 +133,9 @@ export class NekoClient extends BaseClient implements EventEmitter<NekoEvents> {
///////////////////////////// /////////////////////////////
// System Events // System Events
///////////////////////////// /////////////////////////////
protected [EVENT.SYSTEM.INIT]({ implicit_hosting, locks, file_transfer }: SystemInitPayload) { protected [EVENT.SYSTEM.INIT]({ implicit_hosting, file_transfer }: SystemInitPayload) {
this.$accessor.remote.setImplicitHosting(implicit_hosting) this.$accessor.remote.setImplicitHosting(implicit_hosting)
this.$accessor.remote.setFileTransfer(file_transfer) this.$accessor.remote.setFileTransfer(file_transfer)
for (const resource in locks) {
this[EVENT.ADMIN.LOCK]({
event: EVENT.ADMIN.LOCK,
resource: resource as AdminLockResource,
id: locks[resource],
})
}
} }
protected [EVENT.SYSTEM.DISCONNECT]({ message }: SystemMessagePayload) { protected [EVENT.SYSTEM.DISCONNECT]({ message }: SystemMessagePayload) {
@ -477,28 +469,6 @@ export class NekoClient extends BaseClient implements EventEmitter<NekoEvents> {
}) })
} }
protected [EVENT.ADMIN.LOCK]({ id, resource }: AdminLockMessage) {
this.$accessor.setLocked(resource)
this.$accessor.chat.newMessage({
id,
content: this.$vue.$t(`locks.${resource}.notif_locked`) as string,
type: 'event',
created: new Date(),
})
}
protected [EVENT.ADMIN.UNLOCK]({ id, resource }: AdminLockMessage) {
this.$accessor.setUnlocked(resource)
this.$accessor.chat.newMessage({
id,
content: this.$vue.$t(`locks.${resource}.notif_unlocked`) as string,
type: 'event',
created: new Date(),
})
}
protected [EVENT.ADMIN.CONTROL]({ id, target }: AdminTargetPayload) { protected [EVENT.ADMIN.CONTROL]({ id, target }: AdminTargetPayload) {
this.$accessor.remote.setHost(id) this.$accessor.remote.setHost(id)
this.$accessor.remote.changeKeyboard() this.$accessor.remote.changeKeyboard()

View File

@ -19,7 +19,6 @@ export const state = () => ({
active: false, active: false,
connecting: false, connecting: false,
connected: false, connected: false,
locked: {} as Record<string, boolean>,
}) })
export const mutations = mutationTree(state, { export const mutations = mutationTree(state, {
@ -32,14 +31,6 @@ export const mutations = mutationTree(state, {
state.password = password state.password = password
}, },
setLocked(state, resource: string) {
Vue.set(state.locked, resource, true)
},
setUnlocked(state, resource: string) {
Vue.set(state.locked, resource, false)
},
setConnnecting(state) { setConnnecting(state) {
state.connected = false state.connected = false
state.connecting = true state.connecting = true
@ -55,9 +46,7 @@ export const mutations = mutationTree(state, {
}, },
}) })
export const getters = getterTree(state, { export const getters = getterTree(state, {})
isLocked: (state) => (resource: AdminLockResource) => resource in state.locked && state.locked[resource],
})
export const actions = actionTree( export const actions = actionTree(
{ state, getters, mutations }, { state, getters, mutations },
@ -67,30 +56,6 @@ export const actions = actionTree(
accessor.settings.initialise() accessor.settings.initialise()
}, },
lock(_, resource: AdminLockResource) {
if (!accessor.connected || !accessor.user.admin) {
return
}
$client.sendMessage(EVENT.ADMIN.LOCK, { resource })
},
unlock(_, resource: AdminLockResource) {
if (!accessor.connected || !accessor.user.admin) {
return
}
$client.sendMessage(EVENT.ADMIN.UNLOCK, { resource })
},
toggleLock(_, resource: AdminLockResource) {
if (accessor.isLocked(resource)) {
accessor.unlock(resource)
} else {
accessor.lock(resource)
}
},
login(store, { displayname, password }: { displayname: string; password: string }) { login(store, { displayname, password }: { displayname: string; password: string }) {
accessor.setLogin({ displayname, password }) accessor.setLogin({ displayname, password })
$client.login(password, displayname) $client.login(password, displayname)

View File

@ -8,7 +8,6 @@ import (
type WebSocket struct { type WebSocket struct {
Password string Password string
AdminPassword string AdminPassword string
Locks []string
} }
func (WebSocket) Init(cmd *cobra.Command) error { func (WebSocket) Init(cmd *cobra.Command) error {
@ -22,16 +21,10 @@ func (WebSocket) Init(cmd *cobra.Command) error {
return err return err
} }
cmd.PersistentFlags().StringSlice("locks", []string{}, "resources, that will be locked when starting (control, login)")
if err := viper.BindPFlag("locks", cmd.PersistentFlags().Lookup("locks")); err != nil {
return err
}
return nil return nil
} }
func (s *WebSocket) Set() { func (s *WebSocket) Set() {
s.Password = viper.GetString("password") s.Password = viper.GetString("password")
s.AdminPassword = viper.GetString("password_admin") s.AdminPassword = viper.GetString("password_admin")
s.Locks = viper.GetStringSlice("locks")
} }

View File

@ -93,11 +93,6 @@ func New(conf *config.Server, webSocketHandler types.WebSocketHandler, desktop t
return return
} }
if webSocketHandler.IsLocked("login") {
http.Error(w, "room is locked", http.StatusLocked)
return
}
quality, err := strconv.Atoi(r.URL.Query().Get("quality")) quality, err := strconv.Atoi(r.URL.Query().Get("quality"))
if err != nil { if err != nil {
quality = 90 quality = 90

View File

@ -28,8 +28,6 @@ type SessionManager struct {
capture types.CaptureManager capture types.CaptureManager
members map[string]*Session members map[string]*Session
eventsChannel chan types.SessionEvent eventsChannel chan types.SessionEvent
// TODO: Handle locks in sessions as flags.
controlLocked bool
} }
func (manager *SessionManager) New(id string, admin bool, socket types.WebSocket) types.Session { func (manager *SessionManager) New(id string, admin bool, socket types.WebSocket) types.Session {
@ -118,16 +116,6 @@ func (manager *SessionManager) Get(id string) (types.Session, bool) {
return session, ok return session, ok
} }
// TODO: Handle locks in sessions as flags.
func (manager *SessionManager) SetControlLocked(locked bool) {
manager.controlLocked = locked
}
func (manager *SessionManager) CanControl(id string) bool {
session, ok := manager.Get(id)
return ok && (!manager.controlLocked || session.Admin())
}
func (manager *SessionManager) Admins() []*types.Member { func (manager *SessionManager) Admins() []*types.Member {
manager.mu.Lock() manager.mu.Lock()
defer manager.mu.Unlock() defer manager.mu.Unlock()

View File

@ -49,9 +49,7 @@ const (
const ( const (
ADMIN_BAN = "admin/ban" ADMIN_BAN = "admin/ban"
ADMIN_KICK = "admin/kick" ADMIN_KICK = "admin/kick"
ADMIN_LOCK = "admin/lock"
ADMIN_MUTE = "admin/mute" ADMIN_MUTE = "admin/mute"
ADMIN_UNLOCK = "admin/unlock"
ADMIN_UNMUTE = "admin/unmute" ADMIN_UNMUTE = "admin/unmute"
ADMIN_CONTROL = "admin/control" ADMIN_CONTROL = "admin/control"
ADMIN_RELEASE = "admin/release" ADMIN_RELEASE = "admin/release"

View File

@ -13,7 +13,6 @@ type Message struct {
type SystemInit struct { type SystemInit struct {
Event string `json:"event"` Event string `json:"event"`
ImplicitHosting bool `json:"implicit_hosting"` ImplicitHosting bool `json:"implicit_hosting"`
Locks map[string]string `json:"locks"`
} }
type SystemMessage struct { type SystemMessage struct {

View File

@ -55,8 +55,6 @@ type SessionManager interface {
ClearHost() ClearHost()
Has(id string) bool Has(id string) bool
Get(id string) (Session, bool) Get(id string) (Session, bool)
SetControlLocked(locked bool)
CanControl(id string) bool
Members() []*Member Members() []*Member
Admins() []*Member Admins() []*Member
Destroy(id string) Destroy(id string)

View File

@ -11,7 +11,6 @@ type Stats struct {
Members []*Member `json:"members"` Members []*Member `json:"members"`
Banned map[string]string `json:"banned"` // IP -> session ID (that banned it) Banned map[string]string `json:"banned"` // IP -> session ID (that banned it)
Locked map[string]string `json:"locked"` // resource name -> session ID (that locked it)
ServerStartedAt time.Time `json:"server_started_at"` ServerStartedAt time.Time `json:"server_started_at"`
LastAdminLeftAt *time.Time `json:"last_admin_left_at"` LastAdminLeftAt *time.Time `json:"last_admin_left_at"`
@ -31,6 +30,5 @@ type WebSocketHandler interface {
Shutdown() error Shutdown() error
Upgrade(w http.ResponseWriter, r *http.Request) error Upgrade(w http.ResponseWriter, r *http.Request) error
Stats() Stats Stats() Stats
IsLocked(resource string) bool
IsAdmin(password string) (bool, error) IsAdmin(password string) (bool, error)
} }

View File

@ -39,7 +39,7 @@ type PayloadKey struct {
} }
func (manager *WebRTCManager) handle(id string, msg webrtc.DataChannelMessage) error { func (manager *WebRTCManager) handle(id string, msg webrtc.DataChannelMessage) error {
if (!manager.config.ImplicitControl && !manager.sessions.IsHost(id)) || (manager.config.ImplicitControl && !manager.sessions.CanControl(id)) { if (!manager.config.ImplicitControl && !manager.sessions.IsHost(id)) || manager.config.ImplicitControl {
return nil return nil
} }

View File

@ -8,78 +8,6 @@ import (
"m1k1o/neko/internal/types/message" "m1k1o/neko/internal/types/message"
) )
func (h *MessageHandler) adminLock(id string, session types.Session, payload *message.AdminLock) error {
if !session.Admin() {
h.logger.Debug().Msg("user not admin")
return nil
}
if h.state.IsLocked(payload.Resource) {
h.logger.Debug().Str("resource", payload.Resource).Msg("resource already locked...")
return nil
}
// allow only known resources
switch payload.Resource {
case "login":
case "control":
case "file_transfer":
default:
h.logger.Debug().Msg("unknown lock resource")
return nil
}
// TODO: Handle locks in sessions as flags.
if payload.Resource == "control" {
h.sessions.SetControlLocked(true)
}
h.state.Lock(payload.Resource, id)
if err := h.sessions.Broadcast(
message.AdminLock{
Event: event.ADMIN_LOCK,
ID: id,
Resource: payload.Resource,
}, nil); err != nil {
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_LOCK)
return err
}
return nil
}
func (h *MessageHandler) adminUnlock(id string, session types.Session, payload *message.AdminLock) error {
if !session.Admin() {
h.logger.Debug().Msg("user not admin")
return nil
}
if !h.state.IsLocked(payload.Resource) {
h.logger.Debug().Str("resource", payload.Resource).Msg("resource not locked...")
return nil
}
// TODO: Handle locks in sessions as flags.
if payload.Resource == "control" {
h.sessions.SetControlLocked(false)
}
h.state.Unlock(payload.Resource)
if err := h.sessions.Broadcast(
message.AdminLock{
Event: event.ADMIN_UNLOCK,
ID: id,
Resource: payload.Resource,
}, nil); err != nil {
h.logger.Warn().Err(err).Msgf("broadcasting event %s has failed", event.ADMIN_UNLOCK)
return err
}
return nil
}
func (h *MessageHandler) adminControl(id string, session types.Session) error { func (h *MessageHandler) adminControl(id string, session types.Session) error {
if !session.Admin() { if !session.Admin() {
h.logger.Debug().Msg("user not admin") h.logger.Debug().Msg("user not admin")

View File

@ -33,12 +33,6 @@ func (h *MessageHandler) controlRelease(id string, session types.Session) error
func (h *MessageHandler) controlRequest(id string, session types.Session) error { func (h *MessageHandler) controlRequest(id string, session types.Session) error {
// check for host // check for host
if !h.sessions.HasHost() { if !h.sessions.HasHost() {
// check if control is locked or user is admin
if h.state.IsLocked("control") && !session.Admin() {
h.logger.Debug().Msg("control is locked")
return nil
}
// set host // set host
err := h.sessions.SetHost(id) err := h.sessions.SetHost(id)
if err != nil { if err != nil {
@ -96,12 +90,6 @@ func (h *MessageHandler) controlGive(id string, session types.Session, payload *
return nil return nil
} }
// check if control is locked or giver is admin
if h.state.IsLocked("control") && !session.Admin() {
h.logger.Debug().Msg("control is locked")
return nil
}
// set host // set host
err := h.sessions.SetHost(payload.ID) err := h.sessions.SetHost(payload.ID)
if err != nil { if err != nil {
@ -124,7 +112,7 @@ func (h *MessageHandler) controlGive(id string, session types.Session, payload *
func (h *MessageHandler) controlClipboard(id string, session types.Session, payload *message.Clipboard) error { func (h *MessageHandler) controlClipboard(id string, session types.Session, payload *message.Clipboard) error {
// check if session can access clipboard // check if session can access clipboard
if (!h.webrtc.ImplicitControl() && !h.sessions.IsHost(id)) || (h.webrtc.ImplicitControl() && !h.sessions.CanControl(id)) { if (!h.webrtc.ImplicitControl() && !h.sessions.IsHost(id)) || h.webrtc.ImplicitControl() {
h.logger.Debug().Str("id", id).Msg("cannot access clipboard") h.logger.Debug().Str("id", id).Msg("cannot access clipboard")
return nil return nil
} }
@ -135,7 +123,7 @@ func (h *MessageHandler) controlClipboard(id string, session types.Session, payl
func (h *MessageHandler) controlKeyboard(id string, session types.Session, payload *message.Keyboard) error { func (h *MessageHandler) controlKeyboard(id string, session types.Session, payload *message.Keyboard) error {
// check if session can control keyboard // check if session can control keyboard
if (!h.webrtc.ImplicitControl() && !h.sessions.IsHost(id)) || (h.webrtc.ImplicitControl() && !h.sessions.CanControl(id)) { if (!h.webrtc.ImplicitControl() && !h.sessions.IsHost(id)) || h.webrtc.ImplicitControl() {
h.logger.Debug().Str("id", id).Msg("cannot control keyboard") h.logger.Debug().Str("id", id).Msg("cannot control keyboard")
return nil return nil
} }

View File

@ -50,11 +50,6 @@ func (h *MessageHandler) Connected(admin bool, address string) (bool, string) {
} }
} }
if h.state.IsLocked("login") && !admin {
h.logger.Debug().Msg("server locked")
return false, "locked"
}
return true, "" return true, ""
} }
@ -155,18 +150,6 @@ func (h *MessageHandler) Message(id string, raw []byte) error {
return errors.Wrapf(h.boradcastDestroy(session), "%s failed", header.Event) return errors.Wrapf(h.boradcastDestroy(session), "%s failed", header.Event)
// Admin Events // Admin Events
case event.ADMIN_LOCK:
payload := &message.AdminLock{}
return errors.Wrapf(
utils.Unmarshal(payload, raw, func() error {
return h.adminLock(id, session, payload)
}), "%s failed", header.Event)
case event.ADMIN_UNLOCK:
payload := &message.AdminLock{}
return errors.Wrapf(
utils.Unmarshal(payload, raw, func() error {
return h.adminUnlock(id, session, payload)
}), "%s failed", header.Event)
case event.ADMIN_CONTROL: case event.ADMIN_CONTROL:
return errors.Wrapf(h.adminControl(id, session), "%s failed", header.Event) return errors.Wrapf(h.adminControl(id, session), "%s failed", header.Event)
case event.ADMIN_RELEASE: case event.ADMIN_RELEASE:

View File

@ -16,7 +16,6 @@ func (h *MessageHandler) SessionCreated(id string, session types.Session) error
if err := session.Send(message.SystemInit{ if err := session.Send(message.SystemInit{
Event: event.SYSTEM_INIT, Event: event.SYSTEM_INIT,
ImplicitHosting: h.webrtc.ImplicitControl(), ImplicitHosting: h.webrtc.ImplicitControl(),
Locks: h.state.AllLocked(),
}); err != nil { }); err != nil {
h.logger.Warn().Str("id", id).Err(err).Msgf("sending event %s has failed", event.SYSTEM_INIT) h.logger.Warn().Str("id", id).Err(err).Msgf("sending event %s has failed", event.SYSTEM_INIT)
return err return err

View File

@ -35,27 +35,3 @@ func (s *State) GetBanned(ip string) (string, bool) {
func (s *State) AllBanned() map[string]string { func (s *State) AllBanned() map[string]string {
return s.banned return s.banned
} }
// Lock
func (s *State) Lock(resource, id string) {
s.locked[resource] = id
}
func (s *State) Unlock(resource string) {
delete(s.locked, resource)
}
func (s *State) IsLocked(resource string) bool {
_, ok := s.locked[resource]
return ok
}
func (s *State) GetLocked(resource string) (string, bool) {
id, ok := s.locked[resource]
return id, ok
}
func (s *State) AllLocked() map[string]string {
return s.locked
}

View File

@ -25,15 +25,6 @@ func New(sessions types.SessionManager, desktop types.DesktopManager, capture ty
state := state.New() state := state.New()
// apply default locks
for _, lock := range conf.Locks {
state.Lock(lock, "") // empty session ID
}
if len(conf.Locks) > 0 {
logger.Info().Msgf("locked resources: %+v", conf.Locks)
}
handler := handler.New( handler := handler.New(
sessions, sessions,
desktop, desktop,
@ -261,7 +252,6 @@ func (ws *WebSocketHandler) Stats() types.Stats {
Members: ws.sessions.Members(), Members: ws.sessions.Members(),
Banned: ws.state.AllBanned(), Banned: ws.state.AllBanned(),
Locked: ws.state.AllLocked(),
ServerStartedAt: ws.serverStartedAt, ServerStartedAt: ws.serverStartedAt,
LastAdminLeftAt: ws.lastAdminLeftAt, LastAdminLeftAt: ws.lastAdminLeftAt,
@ -271,10 +261,6 @@ func (ws *WebSocketHandler) Stats() types.Stats {
} }
} }
func (ws *WebSocketHandler) IsLocked(resource string) bool {
return ws.state.IsLocked(resource)
}
func (ws *WebSocketHandler) IsAdmin(password string) (bool, error) { func (ws *WebSocketHandler) IsAdmin(password string) (bool, error) {
if password == ws.conf.AdminPassword { if password == ws.conf.AdminPassword {
return true, nil return true, nil