aboutsummaryrefslogtreecommitdiff
path: root/client-web/source
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-04-04 11:15:03 +0200
committermetamuffin <metamuffin@disroot.org>2023-04-04 11:15:03 +0200
commit99d1ab55dfb1714d8f574060e618dc93c94f245c (patch)
treeb01f6ccb6b4060f120a71145fbbded0131c9430e /client-web/source
parent84587df365c61297e08d00f28317b452681a4b84 (diff)
parentfe36a0640f2e36baad1f08033f09b49bdd0f1062 (diff)
downloadkeks-meet-99d1ab55dfb1714d8f574060e618dc93c94f245c.tar
keks-meet-99d1ab55dfb1714d8f574060e618dc93c94f245c.tar.bz2
keks-meet-99d1ab55dfb1714d8f574060e618dc93c94f245c.tar.zst
Merge branch 'master' of codeberg.org:metamuffin/keks-meet
Diffstat (limited to 'client-web/source')
-rw-r--r--client-web/source/index.ts59
-rw-r--r--client-web/source/preferences/mod.ts11
-rw-r--r--client-web/source/protocol/mod.ts1
-rw-r--r--client-web/source/room.ts2
-rw-r--r--client-web/source/sw/download_stream.ts6
-rw-r--r--client-web/source/user/remote.ts4
6 files changed, 53 insertions, 30 deletions
diff --git a/client-web/source/index.ts b/client-web/source/index.ts
index 852e48f..3610ead 100644
--- a/client-web/source/index.ts
+++ b/client-web/source/index.ts
@@ -17,18 +17,20 @@ import { Room } from "./room.ts"
export const VERSION = "0.1.12"
export const ROOM_CONTAINER = esection({ class: "room", aria_label: "user list" })
-export const RTC_CONFIG: RTCConfiguration = {
- iceServers: [
- {
- urls: [
- "turn:meet.metamuffin.org:16900",
- "stun:meet.metamuffin.org:16900"
- ],
- username: "keksmeet",
- credential: "ujCmetg6bm0"
- },
- ],
- iceCandidatePoolSize: 10,
+export interface ClientConfig {
+ appearance?: {
+ accent: string
+ accent_dark: string
+ accent_light: string
+ background: string
+ background_dark: string
+ }
+ webrtc: {
+ stun: string,
+ turn?: string,
+ turn_user?: string,
+ turn_cred?: string
+ }
}
export interface User {
@@ -50,27 +52,42 @@ window.onbeforeunload = ev => {
let r: Room;
export async function main() {
- log("*", "starting up")
- document.body.innerHTML = "" // remove existing elements
- const room_name = load_params().rname
+ document.body.append(LOGGER_CONTAINER)
+ log("*", "loading client config")
+ const config_res = await fetch("/config.json")
+ if (!config_res.ok) return log({ scope: "*", error: true }, "cannot load config")
+ const config: ClientConfig = await config_res.json()
+ log("*", "config loaded. starting")
+
+ document.body.querySelectorAll("p").forEach(e => e.remove())
+ const room_secret = load_params().rsecret
if (!globalThis.RTCPeerConnection) return log({ scope: "webrtc", error: true }, "WebRTC not supported.")
if (!globalThis.isSecureContext) log({ scope: "*", warn: true }, "This page is not in a 'Secure Context'")
if (!globalThis.crypto.subtle) return log({ scope: "crypto", error: true }, "SubtleCrypto not availible")
if (!globalThis.navigator.serviceWorker) log({ scope: "*", warn: true }, "Your browser does not support the Service Worker API, some features dont work without it.")
- if (room_name.length < 8) log({ scope: "crypto", warn: true }, "Room name is very short. e2ee is insecure!")
- if (room_name.length == 0) return window.location.href = "/" // send them back to the start page
- if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room name now - e2ee is insecure!")
+ if (room_secret.length < 8) log({ scope: "crypto", warn: true }, "Room name is very short. e2ee is insecure!")
+ if (room_secret.length == 0) return window.location.href = "/" // send them back to the start page
+ if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room secret now - e2ee is insecure!")
+
+ const conn = await (new SignalingConnection().connect(room_secret))
+ const rtc_config: RTCConfiguration = {
+ iceCandidatePoolSize: 10,
+ iceServers: [{
+ urls: [config.webrtc.stun, ...(config.webrtc.turn ? [config.webrtc.turn] : [])],
+ credential: config.webrtc.turn_cred,
+ username: config.webrtc.turn_user,
+ }]
+ }
- const conn = await (new SignalingConnection().connect(room_name))
- r = new Room(conn)
+ r = new Room(conn, rtc_config)
setup_keybinds(r)
r.on_ready = () => {
new BottomMenu(r)
new MenuBr()
}
- document.body.append(ROOM_CONTAINER, OVERLAYS, LOGGER_CONTAINER)
+ document.body.prepend(ROOM_CONTAINER, OVERLAYS)
if (globalThis.navigator.serviceWorker) init_serviceworker()
}
diff --git a/client-web/source/preferences/mod.ts b/client-web/source/preferences/mod.ts
index 5de73eb..8aefb0f 100644
--- a/client-web/source/preferences/mod.ts
+++ b/client-web/source/preferences/mod.ts
@@ -15,6 +15,7 @@ export interface PrefDecl<T> {
optional?: boolean,
hidden?: boolean
allow_url?: boolean
+ require_reload?: boolean,
}
type Type = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
@@ -85,19 +86,19 @@ export function generate_section(): string {
PREFS_EXPLICIT[key as unknown as keyof typeof PREFS_EXPLICIT]
)))
}
- return load_params().rname + "?" + section.join("&")
+ return load_params().rsecret + "?" + section.join("&")
}
-export function load_params(): { raw_params: { [key: string]: string }, rname: string } {
+export function load_params(): { raw_params: { [key: string]: string }, rsecret: string } {
const raw_params: Record<string, string> = {}
- const [rname, param_str] = window.location.hash.substring(1).split("?")
- if (!param_str) return { rname, raw_params: {} }
+ const [rsecret, param_str] = window.location.hash.substring(1).split("?")
+ if (!param_str) return { rsecret, raw_params: {} }
for (const kv of param_str.split("&")) {
const [key, value] = kv.split("=")
if (key == "prototype") continue
raw_params[decodeURIComponent(key)] = decodeURIComponent(value)
}
- return { raw_params, rname }
+ return { raw_params, rsecret }
}
function get_param<T>(ty: string, key: string): T | undefined {
diff --git a/client-web/source/protocol/mod.ts b/client-web/source/protocol/mod.ts
index 3674c08..6d49a17 100644
--- a/client-web/source/protocol/mod.ts
+++ b/client-web/source/protocol/mod.ts
@@ -33,7 +33,6 @@ export class SignalingConnection {
this.on_open()
r()
})
- log("ws", "connection opened")
return this
}
diff --git a/client-web/source/room.ts b/client-web/source/room.ts
index a685f1d..27d2327 100644
--- a/client-web/source/room.ts
+++ b/client-web/source/room.ts
@@ -20,7 +20,7 @@ export class Room {
public on_ready = () => { };
- constructor(public signaling: SignalingConnection) {
+ constructor(public signaling: SignalingConnection, public rtc_config: RTCConfiguration) {
this.signaling.control_handler = (a) => this.control_handler(a)
this.signaling.relay_handler = (a, b) => this.relay_handler(a, b)
}
diff --git a/client-web/source/sw/download_stream.ts b/client-web/source/sw/download_stream.ts
index 52d9fad..35a3c7e 100644
--- a/client-web/source/sw/download_stream.ts
+++ b/client-web/source/sw/download_stream.ts
@@ -1,3 +1,9 @@
+/*
+ This file is part of keks-meet (https://codeberg.org/metamuffin/keks-meet)
+ which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
+ Copyright (C) 2022 metamuffin <metamuffin@disroot.org>
+*/
+/// <reference lib="dom" />
import { log } from "../logger.ts"
import { SW } from "./init.ts"
diff --git a/client-web/source/user/remote.ts b/client-web/source/user/remote.ts
index bd89e0e..5e81cf7 100644
--- a/client-web/source/user/remote.ts
+++ b/client-web/source/user/remote.ts
@@ -7,7 +7,7 @@
import { RelayMessage } from "../../../common/packets.d.ts";
import { notify } from "../helper.ts";
-import { ROOM_CONTAINER, RTC_CONFIG } from "../index.ts"
+import { ROOM_CONTAINER } from "../index.ts"
import { log } from "../logger.ts"
import { PREFS } from "../preferences/mod.ts";
import { new_remote_resource, RemoteResource } from "../resource/mod.ts";
@@ -28,7 +28,7 @@ export class RemoteUser extends User {
room.remote_users.set(id, this)
log("usermodel", `added remote user: ${this.display_name}`)
- this.pc = new RTCPeerConnection(RTC_CONFIG)
+ this.pc = new RTCPeerConnection(room.rtc_config)
this.pc.onicecandidate = ev => {
if (!ev.candidate) return
room.signaling.send_relay({ ice_candidate: ev.candidate.toJSON() }, this.id)